Documentation ¶
Index ¶
- Constants
- Variables
- func IsDialError(e error) bool
- func IsDialRefused(e error) bool
- type AmbientAutoNAT
- func (as *AmbientAutoNAT) ClosedStream(net inet.Network, s inet.Stream)
- func (as *AmbientAutoNAT) Connected(net inet.Network, c inet.Conn)
- func (as *AmbientAutoNAT) Disconnected(net inet.Network, c inet.Conn)
- func (as *AmbientAutoNAT) Listen(net inet.Network, a ma.Multiaddr)
- func (as *AmbientAutoNAT) ListenClose(net inet.Network, a ma.Multiaddr)
- func (as *AmbientAutoNAT) OpenedStream(net inet.Network, s inet.Stream)
- func (as *AmbientAutoNAT) PublicAddr() (ma.Multiaddr, error)
- func (as *AmbientAutoNAT) Status() NATStatus
- type AutoNAT
- type AutoNATClient
- type AutoNATError
- type GetAddrs
- type NATStatus
Constants ¶
View Source
const AutoNATProto = "/libp2p/autonat/1.0.0"
Variables ¶
View Source
var ( AutoNATBootDelay = 15 * time.Second AutoNATRetryInterval = 90 * time.Second AutoNATRefreshInterval = 15 * time.Minute AutoNATRequestTimeout = 60 * time.Second )
View Source
var AutoNATIdentifyDelay = 5 * time.Second
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 inet.Network, s inet.Stream)
func (*AmbientAutoNAT) Connected ¶
func (as *AmbientAutoNAT) Connected(net inet.Network, c inet.Conn)
func (*AmbientAutoNAT) Disconnected ¶
func (as *AmbientAutoNAT) Disconnected(net inet.Network, c inet.Conn)
func (*AmbientAutoNAT) ListenClose ¶
func (as *AmbientAutoNAT) ListenClose(net inet.Network, a ma.Multiaddr)
func (*AmbientAutoNAT) OpenedStream ¶
func (as *AmbientAutoNAT) OpenedStream(net inet.Network, s inet.Stream)
func (*AmbientAutoNAT) PublicAddr ¶
func (as *AmbientAutoNAT) PublicAddr() (ma.Multiaddr, error)
func (*AmbientAutoNAT) Status ¶
func (as *AmbientAutoNAT) Status() NATStatus
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 AutoNATClient ¶
type AutoNATClient 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) }
AutoNATClient is a stateless client interface to AutoNAT peers
func NewAutoNATClient ¶
func NewAutoNATClient(h host.Host, getAddrs GetAddrs) AutoNATClient
NewAutoNATClient creates a fresh instance of an AutoNATClient If getAddrs is nil, h.Addrs will be used
type AutoNATError ¶
type AutoNATError struct { Status pb.Message_ResponseStatus Text string }
AutoNATError is the class of errors signalled by AutoNAT services
func (AutoNATError) Error ¶
func (e AutoNATError) Error() string
func (AutoNATError) IsDialError ¶
func (e AutoNATError) IsDialError() bool
func (AutoNATError) IsDialRefused ¶
func (e AutoNATError) IsDialRefused() bool
type NATStatus ¶
type NATStatus int
NATStatus is the state of NAT as detected by the ambient service.
const ( // NAT status is unknown; 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 // NAT status is publicly dialable NATStatusPublic // NAT status is private network NATStatusPrivate )
Click to show internal directories.
Click to hide internal directories.