2024-11-26 23:34:27 +01:00
|
|
|
package net
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2025-02-11 13:09:17 +01:00
|
|
|
"strconv"
|
2024-11-26 23:34:27 +01:00
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
|
|
|
|
"github.com/netbirdio/netbird/client/iface/netstack"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
envDisableCustomRouting = "NB_DISABLE_CUSTOM_ROUTING"
|
|
|
|
)
|
|
|
|
|
2025-02-11 13:09:17 +01:00
|
|
|
// 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.
|
2024-11-26 23:34:27 +01:00
|
|
|
func CustomRoutingDisabled() bool {
|
|
|
|
if netstack.IsEnabled() {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2025-02-11 13:09:17 +01:00
|
|
|
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)
|
|
|
|
}
|
2024-11-26 23:34:27 +01:00
|
|
|
}
|
2025-02-11 13:09:17 +01:00
|
|
|
|
|
|
|
return customRoutingDisabled
|
2024-11-26 23:34:27 +01:00
|
|
|
}
|