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 ( ErrNoValidPeers = errors.New("no valid peers for autonat v2") ErrDialRefused = errors.New("dial refused") )
Functions ¶
This section is empty.
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 ¶
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) 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)
}
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 // Reachability of the dialed address Reachability network.Reachability // Status is the outcome of the dialback Status pb.DialStatus }
Result is the result of the CheckReachability call
Source Files ¶
Click to show internal directories.
Click to hide internal directories.