behavior

package
v0.0.0-...-365054f Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MappingNone                 = "none"
	MappingIndependent          = "independent"
	MappingAddressDependent     = "address"
	MappingAddressPortDependent = "addressport"
)

Enum of DiscoverNATMapping return values

View Source
const (
	FilteringIndependent = "independent"
	FilteringAddress     = "address"
	FilteringAddressPort = "addressport"
)

Enum of DiscoverNATFiltering return values

View Source
const (
	// AppTopicNATTypeDetected represents NAT type detection topic.
	AppTopicNATTypeDetected = "NAT-type-detected"
)
View Source
const DefaultTimeout = 3 * time.Second

DefaultTimeout for each single STUN request.

Variables

View Source
var (
	ErrResponseMessage = errors.New("error reading from response message channel")
	ErrNoXorAddress    = errors.New("no XOR-MAPPED-ADDRESS in message")
	ErrNoOtherAddress  = errors.New("no OTHER-ADDRESS in message")
)

STUN protocol compatibility errors

View Source
var ErrEmptyAddressList = errors.New("empty STUN server list specified")

ErrEmptyAddressList indicates there are no servers to get response from

View Source
var ErrInappropriateState = errors.New("NAT probing is impossible at this connection state")

ErrInappropriateState error is returned by gatedNATProber when connection is active

Functions

func DiscoverNATBehavior

func DiscoverNATBehavior(ctx context.Context, address string, timeout time.Duration) (nat.NATType, error)

DiscoverNATBehavior returns either one of NATType* constants describing NAT behavior in practical sense for P2P connections or error

func DiscoverNATFiltering

func DiscoverNATFiltering(ctx context.Context, address string, timeout time.Duration) (string, error)

DiscoverNATFiltering returns either one of FILTERING_* constants describing NAT filtering behavior or error

func DiscoverNATMapping

func DiscoverNATMapping(ctx context.Context, address string, timeout time.Duration) (string, error)

DiscoverNATMapping returns either one of Mapping* constants describing NAT mapping behavior or error

func RacingDiscoverNATBehavior

func RacingDiscoverNATBehavior(ctx context.Context, addresses []string, timeout time.Duration) (nat.NATType, error)

RacingDiscoverNATBehavior implements concurrent NAT discovery against multiple STUN servers in parallel. First successful response is returned, other probing sessions are cancelled.

Types

type ConnectionStatusProvider

type ConnectionStatusProvider interface {
	Status(int) connectionstate.Status
}

ConnectionStatusProvider is a subset of connection.Manager methods to provide gatedNATProber with current connection status

type NATProber

type NATProber interface {
	Probe(context.Context) (nat.NATType, error)
}

NATProber is an abstaction over instances capable probing NAT and returning either it's type or error.

func NewNATProber

func NewNATProber(connStatusProvider ConnectionStatusProvider, eventbus eventbus.Publisher) NATProber

NewNATProber constructs some suitable NATProber without any implementation guarantees.

Jump to

Keyboard shortcuts

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