net

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2026 License: Apache-2.0, BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ControlPlaneMark is the fwmark value used to mark packets that should not be routed through the NetBird interface to
	// avoid routing loops.
	// This includes all control plane traffic (mgmt, signal, flows), relay, ICE/stun/turn and everything that is emitted by the wireguard socket.
	// It doesn't collide with the other marks, as the others are used for data plane traffic only.
	ControlPlaneMark = fwmarkBase | offsetControlPlane

	// DataPlaneMarkLower is the lowest value for the data plane range
	DataPlaneMarkLower = fwmarkBase | offsetDataPlaneLower
	// DataPlaneMarkUpper is the highest value for the data plane range
	DataPlaneMarkUpper = fwmarkBase | offsetDataPlaneUpper

	// DataPlaneMarkIn is the mark for inbound data plane traffic.
	DataPlaneMarkIn = fwmarkBase | offsetDataPlaneIn

	// DataPlaneMarkOut is the mark for outbound data plane traffic.
	DataPlaneMarkOut = fwmarkBase | offsetDataPlaneOut

	// PreroutingFwmarkRedirected is applied to packets that were redirected (input -> forward, e.g. by Docker or Podman) for special handling.
	PreroutingFwmarkRedirected = fwmarkBase | offsetRedirected

	// PreroutingFwmarkMasquerade is applied to packets that arrive from the NetBird interface and should be masqueraded.
	PreroutingFwmarkMasquerade = fwmarkBase | offsetMasquerade

	// PreroutingFwmarkMasqueradeReturn is applied to packets that will leave through the NetBird interface and should be masqueraded.
	PreroutingFwmarkMasqueradeReturn = fwmarkBase | offsetMasqueradeReturn
)

Functions

func AdvancedRouting

func AdvancedRouting() bool

AdvancedRouting reports whether routing loops can be avoided without using exclusion routes

func CheckFwmarkSupport

func CheckFwmarkSupport() bool

func CheckRuleOperationsSupport

func CheckRuleOperationsSupport() bool

func CustomRoutingDisabled

func CustomRoutingDisabled() bool

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 GetVPNInterfaceName

func GetVPNInterfaceName() string

GetVPNInterfaceName returns empty string on Linux

func Init

func Init()

func IsDataPlaneMark

func IsDataPlaneMark(fwmark uint32) bool

IsDataPlaneMark determines if a fwmark is in the data plane range.

func SetSocketMark

func SetSocketMark(conn syscall.Conn) error

SetSocketMark sets the SO_MARK option on the given socket connection

func SetVPNInterfaceName

func SetVPNInterfaceName(name string)

SetVPNInterfaceName is a no-op on Linux

Types

type Dialer

type Dialer struct {
	*net.Dialer
}

Dialer extends the standard net.Dialer with the ability to execute hooks before and after connections. This can be used to bypass the VPN for connections using this dialer.

func NewDialer

func NewDialer() *Dialer

NewDialer returns a customized net.Dialer with overridden Control method

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL