traversal

package
v0.0.0-...-c97221a Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const StageName = "hole_punching"

StageName represents hole-punching stage of NAT traversal

Variables

View Source
var ErrTooFew = errors.New("too few connections were built")

ErrTooFew indicates there were too few successful ping responses to build requested number of connections

Functions

This section is empty.

Types

type NATPinger

type NATPinger interface {
	PingProviderPeer(ctx context.Context, localIP, remoteIP string, localPorts, remotePorts []int, initialTTL int, n int) (conns []*net.UDPConn, err error)
	PingConsumerPeer(ctx context.Context, id string, remoteIP string, localPorts, remotePorts []int, initialTTL int, n int) (conns []*net.UDPConn, err error)
}

NATPinger is responsible for pinging nat holes

func NewPinger

func NewPinger(pingConfig *PingConfig, publisher eventbus.Publisher) NATPinger

NewPinger returns Pinger instance

type NoopPinger

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

NoopPinger does nothing

func NewNoopPinger

func NewNoopPinger(publisher eventbus.Publisher) *NoopPinger

NewNoopPinger returns noop nat pinger

func (*NoopPinger) PingConsumerPeer

func (np *NoopPinger) PingConsumerPeer(ctx context.Context, id, ip string, localPorts, remotePorts []int, initialTTL int, n int) (conns []*net.UDPConn, err error)

PingConsumerPeer does nothing.

func (*NoopPinger) PingPeer

func (np *NoopPinger) PingPeer(ip string, localPorts, remotePorts []int, initialTTL int, n int) (conns []*net.UDPConn, err error)

PingPeer does nothing.

func (*NoopPinger) PingProviderPeer

func (np *NoopPinger) PingProviderPeer(ctx context.Context, localIP, remoteIP string, localPorts, remotePorts []int, initialTTL int, n int) (conns []*net.UDPConn, err error)

PingProviderPeer does nothing.

func (*NoopPinger) Stop

func (np *NoopPinger) Stop()

Stop does nothing

func (*NoopPinger) StopNATProxy

func (np *NoopPinger) StopNATProxy()

StopNATProxy does nothing

type PingConfig

type PingConfig struct {
	Interval            time.Duration
	Timeout             time.Duration
	SendConnACKInterval time.Duration
}

PingConfig represents NAT pinger config.

func DefaultPingConfig

func DefaultPingConfig() *PingConfig

DefaultPingConfig returns default NAT pinger config.

type Pinger

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

Pinger represents NAT pinger structure

func (*Pinger) PingConsumerPeer

func (p *Pinger) PingConsumerPeer(ctx context.Context, id string, remoteIP string, localPorts, remotePorts []int, initialTTL int, n int) ([]*net.UDPConn, error)

PingConsumerPeer pings remote peer with a defined configuration and notifies peer which connections will be used. It returns n connections if possible or error.

func (*Pinger) PingProviderPeer

func (p *Pinger) PingProviderPeer(ctx context.Context, localIP, remoteIP string, localPorts, remotePorts []int, initialTTL int, n int) ([]*net.UDPConn, error)

PingProviderPeer pings remote peer with a defined configuration and waits for peer to send ack with connection selected ids. It returns n connections if possible or error.

func (*Pinger) Valid

func (p *Pinger) Valid() bool

Valid returns that this pinger is a valid pinger

type PortSupplier

type PortSupplier interface {
	Acquire() (port.Port, error)
}

PortSupplier provides port needed to run a service on

Jump to

Keyboard shortcuts

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