Documentation
¶
Index ¶
Constants ¶
View Source
const ( ServiceName = "libp2p.autonatv2" DialBackProtocol = "/libp2p/autonat/2/dial-back" DialProtocol = "/libp2p/autonat/2/dial-request" )
Variables ¶
View Source
var ( // ErrNoPeers is returned when the client knows no autonatv2 servers. ErrNoPeers = errors.New("no peers for autonat v2") // ErrPrivateAddrs is returned when the request has private IP addresses. ErrPrivateAddrs = errors.New("private addresses cannot be verified with autonatv2") )
Functions ¶
func AllowPrivateAddrs ¶ added in v0.49.0
func AllowPrivateAddrs(s *autoNATSettings) error
Types ¶
type AutoNAT ¶
type AutoNAT struct {
// contains filtered or unexported fields
}
AutoNAT implements the AutoNAT v2 client and server. Users can check reachability for their addresses using the CheckReachability method. The server provides amplification attack prevention and rate limiting.
func New ¶
func New(dialerHost host.Host, opts ...AutoNATOption) (*AutoNAT, error)
New returns a new AutoNAT instance. host and dialerHost should have the same dialing capabilities. In case the host doesn't support a transport, dial back requests for address for that transport will be ignored.
func (*AutoNAT) GetReachability ¶
GetReachability makes a single dial request for checking reachability for requested addresses
type AutoNATOption ¶
type AutoNATOption func(s *autoNATSettings) error
func WithMetricsTracer ¶
func WithMetricsTracer(m MetricsTracer) AutoNATOption
func WithServerRateLimit ¶
func WithServerRateLimit(rpm, perPeerRPM, dialDataRPM int, maxConcurrentRequestsPerPeer int) AutoNATOption
type EventDialRequestCompleted ¶
type EventDialRequestCompleted struct {
Error error
ResponseStatus pb.DialResponse_ResponseStatus
DialStatus pb.DialStatus
DialDataRequired bool
DialedAddr ma.Multiaddr
}
type MetricsTracer ¶
type MetricsTracer interface {
CompletedRequest(EventDialRequestCompleted)
ClientCompletedRequest([]Request, Result, error)
}
func NewMetricsTracer ¶
func NewMetricsTracer(reg prometheus.Registerer) MetricsTracer
type Request ¶
type Request struct {
// Addr is the multiaddr to verify
Addr ma.Multiaddr
// SendDialData indicates whether to send dial data if the server requests it for Addr
SendDialData bool
}
Request is the request to verify reachability of a single address
type Result ¶
type Result struct {
// Addr is the dialed address
Addr ma.Multiaddr
// Idx is the index of the address that was dialed
Idx int
// Reachability is the reachability for `Addr`
Reachability network.Reachability
// AllAddrsRefused is true when the server refused to dial all the addresses in the request.
AllAddrsRefused bool
}
Result is the result of the CheckReachability call
Click to show internal directories.
Click to hide internal directories.