Documentation ¶
Index ¶
- Constants
- Variables
- type NATPinger
- type NoopPinger
- func (np *NoopPinger) PingConsumerPeer(ctx context.Context, id, ip string, localPorts, remotePorts []int, ...) (conns []*net.UDPConn, err error)
- func (np *NoopPinger) PingPeer(ip string, localPorts, remotePorts []int, initialTTL int, n int) (conns []*net.UDPConn, err error)
- func (np *NoopPinger) PingProviderPeer(ctx context.Context, localIP, remoteIP string, localPorts, remotePorts []int, ...) (conns []*net.UDPConn, err error)
- func (np *NoopPinger) Stop()
- func (np *NoopPinger) StopNATProxy()
- type PingConfig
- type Pinger
- func (p *Pinger) PingConsumerPeer(ctx context.Context, id string, remoteIP string, localPorts, remotePorts []int, ...) ([]*net.UDPConn, error)
- func (p *Pinger) PingProviderPeer(ctx context.Context, localIP, remoteIP string, localPorts, remotePorts []int, ...) ([]*net.UDPConn, error)
- func (p *Pinger) Valid() bool
- type PortSupplier
Constants ¶
const StageName = "hole_punching"
StageName represents hole-punching stage of NAT traversal
Variables ¶
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
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.
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.
type PortSupplier ¶
PortSupplier provides port needed to run a service on