bind

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2023 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ICEBind

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

ICEBind is the userspace implementation of WireGuard's conn.Bind interface using ice.UDPMux of the pion/ice library

func NewICEBind

func NewICEBind(transportNet transport.Net) *ICEBind

NewICEBind create a new instance of ICEBind with a given transportNet function. The transportNet can be nil.

func (*ICEBind) Close

func (b *ICEBind) Close() error

Close closes the WireGuard socket and UDPMux

func (*ICEBind) GetICEMux

func (b *ICEBind) GetICEMux() (*UniversalUDPMuxDefault, error)

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

func (*ICEBind) Open

func (b *ICEBind) Open(uport uint16) ([]conn.ReceiveFunc, uint16, error)

Open creates a WireGuard socket and an instance of UDPMux that is used to glue up ICE and WireGuard for hole punching

func (*ICEBind) ParseEndpoint

func (b *ICEBind) ParseEndpoint(s string) (ep conn.Endpoint, err error)

ParseEndpoint creates a new endpoint from a string.

func (*ICEBind) Send

func (b *ICEBind) Send(buff []byte, endpoint conn.Endpoint) error

Send bytes to the remote endpoint (peer)

func (*ICEBind) SetMark

func (b *ICEBind) SetMark(mark uint32) error

SetMark sets the mark for each packet sent through this Bind. This mark is passed to the kernel as the socket option SO_MARK.

type UDPMuxDefault

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

UDPMuxDefault is an implementation of the interface

func NewUDPMuxDefault

func NewUDPMuxDefault(params UDPMuxParams) *UDPMuxDefault

NewUDPMuxDefault creates an implementation of UDPMux

func (*UDPMuxDefault) Close

func (m *UDPMuxDefault) Close() error

Close the mux, no further connections could be created

func (*UDPMuxDefault) GetConn

func (m *UDPMuxDefault) GetConn(ufrag string, addr net.Addr) (net.PacketConn, error)

GetConn returns a PacketConn given the connection's ufrag and network address creates the connection if an existing one can't be found

func (*UDPMuxDefault) GetListenAddresses

func (m *UDPMuxDefault) GetListenAddresses() []net.Addr

GetListenAddresses returns the list of addresses that this mux is listening on

func (*UDPMuxDefault) HandleSTUNMessage

func (m *UDPMuxDefault) HandleSTUNMessage(msg *stun.Message, addr net.Addr) error

HandleSTUNMessage handles STUN packets and forwards them to underlying pion/ice library

func (*UDPMuxDefault) IsClosed

func (m *UDPMuxDefault) IsClosed() bool

IsClosed returns true if the mux had been closed

func (*UDPMuxDefault) LocalAddr

func (m *UDPMuxDefault) LocalAddr() net.Addr

LocalAddr returns the listening address of this UDPMuxDefault

func (*UDPMuxDefault) RemoveConnByUfrag

func (m *UDPMuxDefault) RemoveConnByUfrag(ufrag string)

RemoveConnByUfrag stops and removes the muxed packet connection

type UDPMuxParams

type UDPMuxParams struct {
	Logger  logging.LeveledLogger
	UDPConn net.PacketConn

	// Required for gathering local addresses
	// in case a un UDPConn is passed which does not
	// bind to a specific local address.
	Net             transport.Net
	InterfaceFilter func(interfaceName string) bool
}

UDPMuxParams are parameters for UDPMux.

type UniversalUDPMuxDefault

type UniversalUDPMuxDefault struct {
	*UDPMuxDefault
	// contains filtered or unexported fields
}

UniversalUDPMuxDefault handles STUN and TURN servers packets by wrapping the original UDPConn It then passes packets to the UDPMux that does the actual connection muxing.

func NewUniversalUDPMuxDefault

func NewUniversalUDPMuxDefault(params UniversalUDPMuxParams) *UniversalUDPMuxDefault

NewUniversalUDPMuxDefault creates an implementation of UniversalUDPMux embedding UDPMux

func (*UniversalUDPMuxDefault) GetConnForURL

func (m *UniversalUDPMuxDefault) GetConnForURL(ufrag string, url string, addr net.Addr) (net.PacketConn, error)

GetConnForURL add uniques to the muxed connection by concatenating ufrag and URL (e.g. STUN URL) to be able to support multiple STUN/TURN servers and return a unique connection per server.

func (*UniversalUDPMuxDefault) GetListenAddresses

func (m *UniversalUDPMuxDefault) GetListenAddresses() []net.Addr

GetListenAddresses returns the listen addr of this UDP

func (*UniversalUDPMuxDefault) GetRelayedAddr

func (m *UniversalUDPMuxDefault) GetRelayedAddr(turnAddr net.Addr, deadline time.Duration) (*net.Addr, error)

GetRelayedAddr creates relayed connection to the given TURN service and returns the relayed addr. Not implemented yet.

func (*UniversalUDPMuxDefault) GetXORMappedAddr

func (m *UniversalUDPMuxDefault) GetXORMappedAddr(serverAddr net.Addr, deadline time.Duration) (*stun.XORMappedAddress, error)

GetXORMappedAddr returns *stun.XORMappedAddress if already present for a given STUN server. Makes a STUN binding request to discover mapped address otherwise. Blocks until the stun.XORMappedAddress has been discovered or deadline. Method is safe for concurrent use.

func (*UniversalUDPMuxDefault) HandleSTUNMessage

func (m *UniversalUDPMuxDefault) HandleSTUNMessage(msg *stun.Message, addr net.Addr) error

HandleSTUNMessage discovers STUN packets that carry a XOR mapped address from a STUN server. All other STUN packets will be forwarded to the UDPMux

type UniversalUDPMuxParams

type UniversalUDPMuxParams struct {
	Logger                logging.LeveledLogger
	UDPConn               net.PacketConn
	XORMappedAddrCacheTTL time.Duration
	Net                   transport.Net
}

UniversalUDPMuxParams are parameters for UniversalUDPMux server reflexive.

Jump to

Keyboard shortcuts

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