Documentation ¶
Index ¶
- Constants
- Variables
- func DiscoverNATBehavior(ctx context.Context, address string, timeout time.Duration) (nat.NATType, error)
- func DiscoverNATFiltering(ctx context.Context, address string, timeout time.Duration) (string, error)
- func DiscoverNATMapping(ctx context.Context, address string, timeout time.Duration) (string, error)
- func RacingDiscoverNATBehavior(ctx context.Context, addresses []string, timeout time.Duration) (nat.NATType, error)
- type ConnectionStatusProvider
- type NATProber
Constants ¶
const ( MappingNone = "none" MappingIndependent = "independent" MappingAddressDependent = "address" MappingAddressPortDependent = "addressport" )
Enum of DiscoverNATMapping return values
const ( FilteringIndependent = "independent" FilteringAddress = "address" FilteringAddressPort = "addressport" )
Enum of DiscoverNATFiltering return values
const (
// AppTopicNATTypeDetected represents NAT type detection topic.
AppTopicNATTypeDetected = "NAT-type-detected"
)
const DefaultTimeout = 3 * time.Second
DefaultTimeout for each single STUN request.
Variables ¶
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
var ErrEmptyAddressList = errors.New("empty STUN server list specified")
ErrEmptyAddressList indicates there are no servers to get response from
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 ¶
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 ¶
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.