Documentation ¶
Index ¶
- Variables
- func Listen(port int, filter BPFFilter) (net.PacketConn, error)
- type BPFFilter
- type IncomingSTUNFilter
- type SharedSocket
- func (s *SharedSocket) Close() error
- func (s *SharedSocket) LocalAddr() net.Addr
- func (s *SharedSocket) ReadFrom(b []byte) (n int, addr net.Addr, err error)
- func (s *SharedSocket) SetDeadline(t time.Time) error
- func (s *SharedSocket) SetReadDeadline(t time.Time) error
- func (s *SharedSocket) SetWriteDeadline(t time.Time) error
- func (s *SharedSocket) WriteTo(buf []byte, rAddr net.Addr) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
ErrSharedSockStopped indicates that shared socket has been stopped
Functions ¶
Types ¶
type BPFFilter ¶
type BPFFilter interface { // GetInstructions returns raw BPF instructions for ipv4 and ipv6 GetInstructions(port uint32) (ipv4 []bpf.RawInstruction, ipv6 []bpf.RawInstruction, err error) }
BPFFilter is a generic filter that provides ipv4 and ipv6 BPF instructions
func NewIncomingSTUNFilter ¶
func NewIncomingSTUNFilter() BPFFilter
NewIncomingSTUNFilter creates an instance of a IncomingSTUNFilter
type IncomingSTUNFilter ¶
type IncomingSTUNFilter struct { }
IncomingSTUNFilter implements BPFFilter and filters out anything but incoming STUN packets to a specified destination port. Other packets (non STUN) will be forwarded to the process that own the port (e.g., WireGuard).
func (*IncomingSTUNFilter) GetInstructions ¶
func (filter *IncomingSTUNFilter) GetInstructions(dstPort uint32) (raw4 []bpf.RawInstruction, raw6 []bpf.RawInstruction, err error)
GetInstructions returns raw BPF instructions for ipv4 and ipv6 that filter out anything but STUN packets
type SharedSocket ¶
type SharedSocket struct {
// contains filtered or unexported fields
}
SharedSocket is a net.PacketConn that initiates two raw sockets (ipv4 and ipv6) and listens to UDP packets filtered by BPF instructions (e.g., IncomingSTUNFilter that checks and sends only STUN packets to the listeners (ReadFrom)). It is meant to be used when sharing a port with some other process.
func (*SharedSocket) Close ¶
func (s *SharedSocket) Close() error
Close closes the underlying ipv4 and ipv6 conn sockets
func (*SharedSocket) LocalAddr ¶
func (s *SharedSocket) LocalAddr() net.Addr
LocalAddr returns an IPv4 address using the supplied port
func (*SharedSocket) SetDeadline ¶
func (s *SharedSocket) SetDeadline(t time.Time) error
SetDeadline sets both the read and write deadlines associated with the ipv4 and ipv6 Conn sockets
func (*SharedSocket) SetReadDeadline ¶
func (s *SharedSocket) SetReadDeadline(t time.Time) error
SetReadDeadline sets the read deadline associated with the ipv4 and ipv6 Conn sockets
func (*SharedSocket) SetWriteDeadline ¶
func (s *SharedSocket) SetWriteDeadline(t time.Time) error
SetWriteDeadline sets the write deadline associated with the ipv4 and ipv6 Conn sockets