bind

package
v0.64.2 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUDPMUXNotSupported = fmt.Errorf("UDPMUX is not supported in WASM")
)

Functions

func EndpointToUDPAddr added in v0.59.0

func EndpointToUDPAddr(e Endpoint) *net.UDPAddr

Types

type ActivityRecorder added in v0.50.0

type ActivityRecorder struct {
	// contains filtered or unexported fields
}

func NewActivityRecorder added in v0.50.0

func NewActivityRecorder() *ActivityRecorder

func (*ActivityRecorder) GetLastActivities added in v0.50.0

func (r *ActivityRecorder) GetLastActivities() map[string]monotime.Time

GetLastActivities returns a snapshot of peer last activity

func (*ActivityRecorder) Remove added in v0.50.0

func (r *ActivityRecorder) Remove(publicKey string)

func (*ActivityRecorder) UpsertAddress added in v0.50.0

func (r *ActivityRecorder) UpsertAddress(publicKey string, address netip.AddrPort)

UpsertAddress adds or updates the address for a publicKey

type DualStackPacketConn added in v0.64.1

type DualStackPacketConn struct {
	// contains filtered or unexported fields
}

DualStackPacketConn wraps IPv4 and IPv6 UDP connections and routes writes to the appropriate connection based on the destination address. ReadFrom is not used in the hot path - ICEBind receives packets via BatchReader.ReadBatch() directly. This is only used by udpMux for sending.

func NewDualStackPacketConn added in v0.64.1

func NewDualStackPacketConn(ipv4Conn, ipv6Conn net.PacketConn) *DualStackPacketConn

NewDualStackPacketConn creates a new dual-stack packet connection.

func (*DualStackPacketConn) Close added in v0.64.1

func (d *DualStackPacketConn) Close() error

Close closes both connections.

func (*DualStackPacketConn) LocalAddr added in v0.64.1

func (d *DualStackPacketConn) LocalAddr() net.Addr

LocalAddr returns the local address of the IPv4 connection if available, otherwise the IPv6 connection.

func (*DualStackPacketConn) ReadFrom added in v0.64.1

func (d *DualStackPacketConn) ReadFrom(b []byte) (n int, addr net.Addr, err error)

ReadFrom reads from the available connection (preferring IPv4). NOTE: This method is NOT used in the data path. ICEBind receives packets via BatchReader.ReadBatch() directly for both IPv4 and IPv6, which is much more efficient. This implementation exists only to satisfy the net.PacketConn interface for the udpMux, but the udpMux only uses WriteTo() for sending STUN responses - it never calls ReadFrom() because STUN packets are filtered and forwarded via HandleSTUNMessage() from the receive path.

func (*DualStackPacketConn) SetDeadline added in v0.64.1

func (d *DualStackPacketConn) SetDeadline(t time.Time) error

SetDeadline sets the deadline for both connections.

func (*DualStackPacketConn) SetReadDeadline added in v0.64.1

func (d *DualStackPacketConn) SetReadDeadline(t time.Time) error

SetReadDeadline sets the read deadline for both connections.

func (*DualStackPacketConn) SetWriteDeadline added in v0.64.1

func (d *DualStackPacketConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the write deadline for both connections.

func (*DualStackPacketConn) WriteTo added in v0.64.1

func (d *DualStackPacketConn) WriteTo(b []byte, addr net.Addr) (n int, err error)

WriteTo writes to the appropriate connection based on the address type.

type Endpoint added in v0.30.3

type Endpoint = wgConn.StdNetEndpoint

type ICEBind

type ICEBind struct {
	*wgConn.StdNetBind
	// contains filtered or unexported fields
}

ICEBind is a bind implementation with two main features: 1. filter out STUN messages and handle them 2. forward the received packets to the WireGuard interface from the relayed connection

ICEBind.endpoints var is a map that stores the connection for each relayed peer. Fake address is just an IP address without port, in the format of 127.1.x.x where x.x is the last two octets of the peer address. We try to avoid to use the port because in the Send function the wgConn.Endpoint the port info is not exported.

func NewICEBind

func NewICEBind(transportNet transport.Net, filterFn udpmux.FilterFn, address wgaddr.Address, mtu uint16) *ICEBind

func (*ICEBind) ActivityRecorder added in v0.50.0

func (s *ICEBind) ActivityRecorder() *ActivityRecorder

func (*ICEBind) Close added in v0.30.3

func (s *ICEBind) Close() error

func (*ICEBind) GetICEMux

func (s *ICEBind) GetICEMux() (*udpmux.UniversalUDPMuxDefault, error)

GetICEMux returns the ICE UDPMux that was created and used by ICEBind

func (*ICEBind) Open added in v0.30.3

func (s *ICEBind) Open(uport uint16) ([]wgConn.ReceiveFunc, uint16, error)

func (*ICEBind) ReceiveFromEndpoint added in v0.59.0

func (b *ICEBind) ReceiveFromEndpoint(ctx context.Context, ep *Endpoint, buf []byte)

func (*ICEBind) RemoveEndpoint added in v0.30.3

func (b *ICEBind) RemoveEndpoint(fakeIP netip.Addr)

func (*ICEBind) Send added in v0.30.3

func (b *ICEBind) Send(bufs [][]byte, ep wgConn.Endpoint) error

func (*ICEBind) SetEndpoint added in v0.30.3

func (b *ICEBind) SetEndpoint(fakeIP netip.Addr, conn net.Conn)

type PeerRecord added in v0.50.0

type PeerRecord struct {
	Address      netip.AddrPort
	LastActivity atomic.Int64 // UnixNano timestamp
}

type RelayBindJS added in v0.59.0

type RelayBindJS struct {
	*conn.StdNetBind
	// contains filtered or unexported fields
}

RelayBindJS is a conn.Bind implementation for WebAssembly environments. Do not limit to build only js, because we want to be able to run tests

func NewRelayBindJS added in v0.59.0

func NewRelayBindJS() *RelayBindJS

func (*RelayBindJS) ActivityRecorder added in v0.59.0

func (s *RelayBindJS) ActivityRecorder() *ActivityRecorder

func (*RelayBindJS) Close added in v0.59.0

func (s *RelayBindJS) Close() error

func (*RelayBindJS) GetICEMux added in v0.59.0

func (s *RelayBindJS) GetICEMux() (*udpmux.UniversalUDPMuxDefault, error)

GetICEMux returns the ICE UDPMux that was created and used by ICEBind

func (*RelayBindJS) Open added in v0.59.0

func (s *RelayBindJS) Open(uport uint16) ([]conn.ReceiveFunc, uint16, error)

Open creates a receive function for handling relay packets in WASM.

func (*RelayBindJS) ReceiveFromEndpoint added in v0.59.0

func (s *RelayBindJS) ReceiveFromEndpoint(ctx context.Context, ep *Endpoint, buf []byte)

func (*RelayBindJS) RemoveEndpoint added in v0.59.0

func (s *RelayBindJS) RemoveEndpoint(fakeIP netip.Addr)

func (*RelayBindJS) Send added in v0.59.0

func (s *RelayBindJS) Send(bufs [][]byte, ep conn.Endpoint) error

Send forwards packets through the relay connection for WASM.

func (*RelayBindJS) SetEndpoint added in v0.59.0

func (b *RelayBindJS) SetEndpoint(fakeIP netip.Addr, conn net.Conn)

Jump to

Keyboard shortcuts

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