[client] Code cleaning in net pkg and fix exit node feature on Android(#2932)

Code cleaning around the util/net package. The goal was to write a more understandable source code but modify nothing on the logic.
Protect the WireGuard UDP listeners with marks.
The implementation can support the VPN permission revocation events in thread safe way. It will be important if we start to support the running time route and DNS update features.

- uniformize the file name convention: [struct_name] _ [functions] _ [os].go
- code cleaning in net_linux.go
- move env variables to env.go file
This commit is contained in:
Zoltan Papp
2024-11-26 23:34:27 +01:00
committed by GitHub
parent 9683da54b0
commit 9203690033
23 changed files with 249 additions and 185 deletions

View File

@@ -2,9 +2,6 @@ package net
import (
"net"
"os"
"github.com/netbirdio/netbird/client/iface/netstack"
"github.com/google/uuid"
)
@@ -16,8 +13,6 @@ const (
PreroutingFwmarkRedirected = 0x1BD01
PreroutingFwmarkMasquerade = 0x1BD11
PreroutingFwmarkMasqueradeReturn = 0x1BD12
envDisableCustomRouting = "NB_DISABLE_CUSTOM_ROUTING"
)
// ConnectionID provides a globally unique identifier for network connections.
@@ -31,10 +26,3 @@ type RemoveHookFunc func(connID ConnectionID) error
func GenerateConnID() ConnectionID {
return ConnectionID(uuid.NewString())
}
func CustomRoutingDisabled() bool {
if netstack.IsEnabled() {
return true
}
return os.Getenv(envDisableCustomRouting) == "true"
}