package autonat

Import Path
	github.com/libp2p/go-libp2p/p2p/host/autonat (on go.dev)

Dependency Relation
	imports 23 packages, and imported by 3 packages


Package-Level Type Names (total 9)
/* sort by: | */
AddrFunc is a function returning the candidate addresses for the local host. func NewAutoNATClient(h host.Host, addrFunc AddrFunc, mt MetricsTracer) Client func UsingAddresses(addrFunc AddrFunc) Option
AmbientAutoNAT is the implementation of ambient NAT autodiscovery (*AmbientAutoNAT) Close() error Connected is part of the network.Notifiee interface Disconnected is part of the network.Notifiee interface Listen is part of the network.Notifiee interface ListenClose is part of the network.Notifiee interface Status returns the AutoNAT observed reachability status. *AmbientAutoNAT : AutoNAT *AmbientAutoNAT : github.com/libp2p/go-libp2p/core/network.Notifiee *AmbientAutoNAT : github.com/prometheus/common/expfmt.Closer *AmbientAutoNAT : io.Closer
AutoNAT is the interface for NAT autodiscovery ( AutoNAT) Close() error Status returns the current NAT status *AmbientAutoNAT *StaticAutoNAT AutoNAT : github.com/prometheus/common/expfmt.Closer AutoNAT : io.Closer func New(h host.Host, options ...Option) (AutoNAT, error) func github.com/libp2p/go-libp2p/p2p/host/basic.(*BasicHost).GetAutoNat() AutoNAT func github.com/libp2p/go-libp2p/p2p/host/basic.(*BasicHost).SetAutoNat(a AutoNAT)
Client is a stateless client interface to AutoNAT peers DialBack requests from a peer providing AutoNAT services to test dial back and report the address on a successful connection. func NewAutoNATClient(h host.Host, addrFunc AddrFunc, mt MetricsTracer) Client
Error wraps errors signalled by AutoNAT services Status pb.Message_ResponseStatus Text string ( Error) Error() string IsDialError returns true if the error was due to a dial back failure IsDialRefused returns true if the error was due to a refusal to dial back Error : error
( MetricsTracer) NextProbeTime(t time.Time) ( MetricsTracer) OutgoingDialRefused(reason string) ( MetricsTracer) OutgoingDialResponse(status pb.Message_ResponseStatus) ( MetricsTracer) ReachabilityStatus(status network.Reachability) ( MetricsTracer) ReachabilityStatusConfidence(confidence int) ( MetricsTracer) ReceivedDialResponse(status pb.Message_ResponseStatus) func NewMetricsTracer(opts ...MetricsTracerOption) MetricsTracer func NewAutoNATClient(h host.Host, addrFunc AddrFunc, mt MetricsTracer) Client func WithMetricsTracer(mt MetricsTracer) Option
func WithRegisterer(reg prometheus.Registerer) MetricsTracerOption func NewMetricsTracer(opts ...MetricsTracerOption) MetricsTracer
Option is an Autonat option for configuration func EnableService(dialer network.Network) Option func UsingAddresses(addrFunc AddrFunc) Option func WithMetricsTracer(mt MetricsTracer) Option func WithoutStartupDelay() Option func WithoutThrottling() Option func WithPeerThrottling(amount int) Option func WithReachability(reachability network.Reachability) Option func WithSchedule(retryInterval, refreshInterval time.Duration) Option func WithThrottling(amount int, interval time.Duration) Option func New(h host.Host, options ...Option) (AutoNAT, error)
StaticAutoNAT is a simple AutoNAT implementation when a single NAT status is desired. (*StaticAutoNAT) Close() error Status returns the AutoNAT observed reachability status. *StaticAutoNAT : AutoNAT *StaticAutoNAT : github.com/prometheus/common/expfmt.Closer *StaticAutoNAT : io.Closer
Package-Level Functions (total 15)
EnableService specifies that AutoNAT should be allowed to run a NAT service to help other peers determine their own NAT status. The provided Network should not be the default network/dialer of the host passed to `New`, as the NAT system will need to make parallel connections, and as such will modify both the associated peerstore and terminate connections of this dialer. The dialer provided should be compatible (TCP/UDP) however with the transports of the libp2p network.
IsDialError returns true if the AutoNAT peer signalled an error dialing back
IsDialRefused returns true if the AutoNAT peer signalled refusal to dial back
New creates a new NAT autodiscovery system attached to a host
NewAutoNATClient creates a fresh instance of an AutoNATClient If addrFunc is nil, h.Addrs will be used
UsingAddresses allows overriding which Addresses the AutoNAT client believes are "its own". Useful for testing, or for more exotic port-forwarding scenarios where the host may be listening on different ports than it wants to externally advertise or verify connectability on.
WithMetricsTracer uses mt to track autonat metrics
WithoutStartupDelay removes the initial delay the NAT subsystem typically uses as a buffer for ensuring that connectivity and guesses as to the hosts local interfaces have settled down during startup.
WithoutThrottling indicates that this autonat service should not place restrictions on how many peers it is willing to help when acting as a server.
WithPeerThrottling specifies a limit for the maximum number of IP checks this node will provide to an individual peer in each `interval`.
WithReachability overrides autonat to simply report an over-ridden reachability status.
WithSchedule configures how aggressively probes will be made to verify the address of the host. retryInterval indicates how often probes should be made when the host lacks confidence about its address, while refreshInterval is the schedule of periodic probes when the host believes it knows its steady-state reachability.
WithThrottling specifies how many peers (`amount`) it is willing to help ever `interval` amount of time when acting as a server.
Package-Level Constants (total 2)
AutoNATProto identifies the autonat service protocol
const ServiceName = "libp2p.autonat"