netbird/util/net/net.go

32 lines
766 B
Go
Raw Normal View History

package net
2024-04-12 16:53:11 +02:00
import (
"github.com/netbirdio/netbird/iface/netstack"
2024-04-12 16:53:11 +02:00
"os"
"github.com/google/uuid"
)
const (
// NetbirdFwmark is the fwmark value used by Netbird via wireguard
NetbirdFwmark = 0x1BD00
2024-04-12 16:53:11 +02:00
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
// GenerateConnID generates a unique identifier for each connection.
func GenerateConnID() ConnectionID {
return ConnectionID(uuid.NewString())
}
2024-04-12 16:53:11 +02:00
func CustomRoutingDisabled() bool {
if netstack.IsEnabled() {
return true
}
2024-04-12 16:53:11 +02:00
return os.Getenv(envDisableCustomRouting) == "true"
}