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 AddHookFunc
- type Conn
- type ConnectionID
- type Dialer
- type DialerCloseHookFunc
- type DialerDialHookFunc
- type ListenerCloseHookFunc
- type ListenerConfig
- type ListenerWriteHookFunc
- type PacketConn
- type RemoveHookFunc
- type UDPConn
Constants ¶
const ( // NetbirdFwmark is the fwmark value used by Netbird via wireguard NetbirdFwmark = 0x1BD00 PreroutingFwmarkRedirected = 0x1BD01 PreroutingFwmarkMasquerade = 0x1BD11 PreroutingFwmarkMasqueradeReturn = 0x1BD12 )
Variables ¶
This section is empty.
Functions ¶
func AddDialerCloseHook ¶ added in v0.27.0
func AddDialerCloseHook(hook DialerCloseHookFunc)
AddDialerCloseHook allows adding a new hook to be executed on connection close.
func AddDialerHook ¶ added in v0.27.0
func AddDialerHook(hook DialerDialHookFunc)
AddDialerHook allows adding a new hook to be executed before dialing.
func AddListenerCloseHook ¶ added in v0.27.0
func AddListenerCloseHook(hook ListenerCloseHookFunc)
AddListenerCloseHook allows adding a new hook to be executed upon closing a UDP connection.
func AddListenerWriteHook ¶ added in v0.27.0
func AddListenerWriteHook(hook ListenerWriteHookFunc)
AddListenerWriteHook allows adding a new write hook to be executed before a UDP packet is sent.
func CustomRoutingDisabled ¶ added in v0.27.3
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 RemoveDialerHooks ¶ added in v0.27.0
func RemoveDialerHooks()
RemoveDialerHooks removes all dialer hooks.
func RemoveListenerHooks ¶ added in v0.27.0
func RemoveListenerHooks()
RemoveListenerHooks removes all dialer hooks.
func SetRawSocketMark ¶
func SetSocketMark ¶
SetSocketMark sets the SO_MARK option on the given socket connection
func SetSocketOpt ¶ added in v0.27.3
Types ¶
type AddHookFunc ¶ added in v0.28.0
type AddHookFunc func(connID ConnectionID, IP net.IP) error
type Conn ¶ added in v0.27.0
type Conn struct { net.Conn ID ConnectionID }
Conn wraps a net.Conn to override the Close method
type ConnectionID ¶ added in v0.27.0
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 ¶ added in v0.27.0
func GenerateConnID() ConnectionID
GenerateConnID generates a unique identifier for each connection.
type Dialer ¶ added in v0.27.0
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 ¶ added in v0.27.0
type DialerCloseHookFunc func(connID ConnectionID, conn *net.Conn) error
type DialerDialHookFunc ¶ added in v0.27.0
type ListenerCloseHookFunc ¶ added in v0.27.0
type ListenerCloseHookFunc func(connID ConnectionID, conn net.PacketConn) error
ListenerCloseHookFunc defines the function signature for close hooks for PacketConn.
type ListenerConfig ¶ added in v0.27.0
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 ¶ added in v0.27.0
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 ¶ added in v0.27.0
type ListenerWriteHookFunc func(connID ConnectionID, ip *net.IPAddr, data []byte) error
ListenerWriteHookFunc defines the function signature for write hooks for PacketConn.
type PacketConn ¶ added in v0.27.0
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 ¶ added in v0.27.0
func (c *PacketConn) Close() error
Close overrides the net.PacketConn Close method to execute all registered hooks before closing the connection.
type RemoveHookFunc ¶ added in v0.28.0
type RemoveHookFunc func(connID ConnectionID) error
type UDPConn ¶ added in v0.27.0
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.