Documentation ¶
Index ¶
- Constants
- func AddDialerCloseHook(hook DialerCloseHookFunc)
- func AddDialerHook(hook DialerDialHookFunc)
- func AddListenerCloseHook(hook ListenerCloseHookFunc)
- func AddListenerWriteHook(hook ListenerWriteHookFunc)
- func CustomRoutingDisabled() bool
- func DialTCP(network string, laddr, raddr *net.TCPAddr) (*net.TCPConn, error)
- func DialUDP(network string, laddr, raddr *net.UDPAddr) (*net.UDPConn, error)
- func ListenUDP(network string, laddr *net.UDPAddr) (transport.UDPConn, error)
- func RemoveDialerHooks()
- func RemoveListenerHooks()
- func SetRawSocketMark(conn syscall.RawConn) error
- func SetSocketMark(conn syscall.Conn) error
- func SetSocketOpt(fd int) error
- type Conn
- type ConnectionID
- type Dialer
- type DialerCloseHookFunc
- type DialerDialHookFunc
- type ListenerCloseHookFunc
- type ListenerConfig
- type ListenerWriteHookFunc
- type PacketConn
- type UDPConn
Constants ¶
const (
// NetbirdFwmark is the fwmark value used by Netbird via wireguard
NetbirdFwmark = 0x1BD00
)
Variables ¶
This section is empty.
Functions ¶
func AddDialerCloseHook ¶
func AddDialerCloseHook(hook DialerCloseHookFunc)
AddDialerCloseHook allows adding a new hook to be executed on connection close.
func AddDialerHook ¶
func AddDialerHook(hook DialerDialHookFunc)
AddDialerHook allows adding a new hook to be executed before dialing.
func AddListenerCloseHook ¶
func AddListenerCloseHook(hook ListenerCloseHookFunc)
AddListenerCloseHook allows adding a new hook to be executed upon closing a UDP connection.
func AddListenerWriteHook ¶
func AddListenerWriteHook(hook ListenerWriteHookFunc)
AddListenerWriteHook allows adding a new write hook to be executed before a UDP packet is sent.
func CustomRoutingDisabled ¶
func CustomRoutingDisabled() bool
func ListenUDP ¶
ListenUDP listens on the network address and returns a transport.UDPConn which includes support for write and close hooks.
func SetRawSocketMark ¶
func SetSocketMark ¶
SetSocketMark sets the SO_MARK option on the given socket connection
func SetSocketOpt ¶
Types ¶
type Conn ¶
type Conn struct { net.Conn ID ConnectionID }
Conn wraps a net.Conn to override the Close method
type ConnectionID ¶
type ConnectionID string
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.
func GenerateConnID ¶
func GenerateConnID() ConnectionID
GenerateConnID generates a unique identifier for each connection.
type 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
type DialerCloseHookFunc ¶
type DialerCloseHookFunc func(connID ConnectionID, conn *net.Conn) error
type DialerDialHookFunc ¶
type ListenerCloseHookFunc ¶
type ListenerCloseHookFunc func(connID ConnectionID, conn net.PacketConn) error
ListenerCloseHookFunc defines the function signature for close hooks for PacketConn.
type ListenerConfig ¶
type ListenerConfig struct {
*net.ListenConfig
}
ListenerConfig extends the standard net.ListenConfig with the ability to execute hooks before responding via the socket and after closing. This can be used to bypass the VPN for listeners.
func NewListener ¶
func NewListener() *ListenerConfig
NewListener creates a new ListenerConfig instance.
func (*ListenerConfig) ListenPacket ¶
func (l *ListenerConfig) ListenPacket(ctx context.Context, network, address string) (net.PacketConn, error)
ListenPacket listens on the network address and returns a PacketConn which includes support for write hooks.
type ListenerWriteHookFunc ¶
type ListenerWriteHookFunc func(connID ConnectionID, ip *net.IPAddr, data []byte) error
ListenerWriteHookFunc defines the function signature for write hooks for PacketConn.
type PacketConn ¶
type PacketConn struct { net.PacketConn ID ConnectionID // contains filtered or unexported fields }
PacketConn wraps net.PacketConn to override its WriteTo and Close methods to include hook functionality.
func (*PacketConn) Close ¶
func (c *PacketConn) Close() error
Close overrides the net.PacketConn Close method to execute all registered hooks before closing the connection.
type UDPConn ¶
type UDPConn struct { *net.UDPConn ID ConnectionID // contains filtered or unexported fields }
UDPConn wraps net.UDPConn to override its WriteTo and Close methods to include hook functionality.