mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-14 02:41:34 +01:00
09bdd271f1
- Update nftables library to v0.2.0 - Mark traffic that was originally destined for local and applies the input rules in the forward chain if said traffic was redirected (e.g. by Docker) - Add nft rules to internal map only if flush was successful - Improve error message if handle is 0 (= not found or hasn't been refreshed) - Add debug logging when route rules are added - Replace nftables userdata (rule ID) with a rule hash
38 lines
925 B
Go
38 lines
925 B
Go
package net
|
|
|
|
import (
|
|
"net"
|
|
"os"
|
|
|
|
"github.com/netbirdio/netbird/client/iface/netstack"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const (
|
|
// NetbirdFwmark is the fwmark value used by Netbird via wireguard
|
|
NetbirdFwmark = 0x1BD00
|
|
PreroutingFwmark = 0x1BD01
|
|
|
|
envDisableCustomRouting = "NB_DISABLE_CUSTOM_ROUTING"
|
|
)
|
|
|
|
// ConnectionID provides a globally unique identifier for network connections.
|
|
// It's used to track connections throughout their lifecycle so the close hook can correlate with the dial hook.
|
|
type ConnectionID string
|
|
|
|
type AddHookFunc func(connID ConnectionID, IP net.IP) error
|
|
type RemoveHookFunc func(connID ConnectionID) error
|
|
|
|
// GenerateConnID generates a unique identifier for each connection.
|
|
func GenerateConnID() ConnectionID {
|
|
return ConnectionID(uuid.NewString())
|
|
}
|
|
|
|
func CustomRoutingDisabled() bool {
|
|
if netstack.IsEnabled() {
|
|
return true
|
|
}
|
|
return os.Getenv(envDisableCustomRouting) == "true"
|
|
}
|