mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-16 07:16:38 +00:00
- Move `util/grpc` and `util/net` to `client` so `internal` packages can be accessed - Add methods to return the next best interface after the NetBird interface. - Use `IP_UNICAST_IF` sock opt to force the outgoing interface for the NetBird `net.Dialer` and `net.ListenerConfig` to avoid routing loops. The interface is picked by the new route lookup method. - Some refactoring to avoid import cycles - Old behavior is available through `NB_USE_LEGACY_ROUTING=true` env var
36 lines
912 B
Go
36 lines
912 B
Go
package net
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
"github.com/netbirdio/netbird/client/iface/netstack"
|
|
)
|
|
|
|
const (
|
|
envDisableCustomRouting = "NB_DISABLE_CUSTOM_ROUTING"
|
|
envUseLegacyRouting = "NB_USE_LEGACY_ROUTING"
|
|
)
|
|
|
|
// CustomRoutingDisabled returns true if custom routing is disabled.
|
|
// This will fall back to the operation mode before the exit node functionality was implemented.
|
|
// In particular exclusion routes won't be set up and all dialers and listeners will use net.Dial and net.Listen, respectively.
|
|
func CustomRoutingDisabled() bool {
|
|
if netstack.IsEnabled() {
|
|
return true
|
|
}
|
|
|
|
var customRoutingDisabled bool
|
|
if val := os.Getenv(envDisableCustomRouting); val != "" {
|
|
var err error
|
|
customRoutingDisabled, err = strconv.ParseBool(val)
|
|
if err != nil {
|
|
log.Warnf("failed to parse %s: %v", envDisableCustomRouting, err)
|
|
}
|
|
}
|
|
|
|
return customRoutingDisabled
|
|
}
|