Documentation ¶
Index ¶
- Constants
- Variables
- func IsDialError(e error) bool
- func IsDialRefused(e error) bool
- type AmbientAutoNAT
- func (as *AmbientAutoNAT) ClosedStream(net network.Network, s network.Stream)
- func (as *AmbientAutoNAT) Connected(net network.Network, c network.Conn)
- func (as *AmbientAutoNAT) Disconnected(net network.Network, c network.Conn)
- func (as *AmbientAutoNAT) Listen(net network.Network, a ma.Multiaddr)
- func (as *AmbientAutoNAT) ListenClose(net network.Network, a ma.Multiaddr)
- func (as *AmbientAutoNAT) OpenedStream(net network.Network, s network.Stream)
- func (as *AmbientAutoNAT) PublicAddr() (ma.Multiaddr, error)
- func (as *AmbientAutoNAT) Status() NATStatus
- type AutoNAT
- type Error
- type GetAddrs
- type NATClient
- type NATStatus
Constants ¶
const AutoNATProto = "/libp2p/autonat/1.0.0"
AutoNATProto is the libp2p autonat protocol name
Variables ¶
var ( // AutoNATBootDelay defines the boot delay AutoNATBootDelay = 15 * time.Second // AutoNATRetryInterval defines the retry interval AutoNATRetryInterval = 90 * time.Second // AutoNATRefreshInterval defines the refresh interval AutoNATRefreshInterval = 15 * time.Minute // AutoNATRequestTimeout defines the request timeout AutoNATRequestTimeout = 30 * time.Second )
var AutoNATIdentifyDelay = 5 * time.Second
AutoNATIdentifyDelay is the default delay before running autonat identification
Functions ¶
func IsDialError ¶
IsDialError returns true if the AutoNAT peer signalled an error dialing back
func IsDialRefused ¶
IsDialRefused returns true if the AutoNAT peer signalled refusal to dial back
Types ¶
type AmbientAutoNAT ¶
type AmbientAutoNAT struct {
// contains filtered or unexported fields
}
AmbientAutoNAT is the implementation of ambient NAT autodiscovery
func (*AmbientAutoNAT) ClosedStream ¶
func (as *AmbientAutoNAT) ClosedStream(net network.Network, s network.Stream)
ClosedStream satisfies the network.Notifiee interface
func (*AmbientAutoNAT) Connected ¶
func (as *AmbientAutoNAT) Connected(net network.Network, c network.Conn)
Connected satisfies the network.Notifiee interface
func (*AmbientAutoNAT) Disconnected ¶
func (as *AmbientAutoNAT) Disconnected(net network.Network, c network.Conn)
Disconnected satisfies the network.Notifiee interface
func (*AmbientAutoNAT) Listen ¶
func (as *AmbientAutoNAT) Listen(net network.Network, a ma.Multiaddr)
Listen satisfies the network.Notifiee interface
func (*AmbientAutoNAT) ListenClose ¶
func (as *AmbientAutoNAT) ListenClose(net network.Network, a ma.Multiaddr)
ListenClose satisfies the network.Notifiee interface
func (*AmbientAutoNAT) OpenedStream ¶
func (as *AmbientAutoNAT) OpenedStream(net network.Network, s network.Stream)
OpenedStream satisfies the network.Notifiee interface
func (*AmbientAutoNAT) PublicAddr ¶
func (as *AmbientAutoNAT) PublicAddr() (ma.Multiaddr, error)
PublicAddr returns the publicly accessibel address for this autonat instance
func (*AmbientAutoNAT) Status ¶
func (as *AmbientAutoNAT) Status() NATStatus
Status returns the autonat status
type AutoNAT ¶
type AutoNAT interface { // Status returns the current NAT status Status() NATStatus // PublicAddr returns the public dial address when NAT status is public and an // error otherwise PublicAddr() (ma.Multiaddr, error) }
AutoNAT is the interface for ambient NAT autodiscovery
type Error ¶
type Error struct { Status pb.Message_ResponseStatus Text string }
Error is the class of errors signalled by AutoNAT services
func (Error) IsDialError ¶
IsDialError returns whether or not the error is a dial error
func (Error) IsDialRefused ¶
IsDialRefused returns whether or not the error is a dial refused error
type NATClient ¶
type NATClient interface { // DialBack requests from a peer providing AutoNAT services to test dial back // and report the address on a successful connection. DialBack(ctx context.Context, p peer.ID) (ma.Multiaddr, error) }
NATClient is a stateless client interface to AutoNAT peers
type NATStatus ¶
type NATStatus int
NATStatus is the state of NAT as detected by the ambient service.
const ( // NATStatusUnknown this means that the ambient service has not been // able to decide the presence of NAT in the most recent attempt to test // dial through known autonat peers. initial state. NATStatusUnknown NATStatus = iota // NATStatusPublic indicates the peer is on a publicly accessible network NATStatusPublic // NATStatusPrivate indicates the peer is not on a publicly accessible network NATStatusPrivate )