libp2p-hs-0.1.0.0: Haskell implementation of the libp2p networking stack
Safe HaskellNone
LanguageGHC2021

Network.LibP2P.NAT.AutoNAT.AutoNAT

Description

AutoNAT v1 service: detect NAT status by asking remote peers to dial back.

Protocol: libp2pautonat/1.0.0 Flow: Client sends DIAL with addresses, server dials back, responds with result.

Security rules (from docs/10-nat-traversal.md): - Server MUST NOT dial addresses unless they match the requester's observed IP - Server MUST NOT accept dial requests over relayed connections

Synopsis

Types

data NATStatus Source #

Detected NAT status.

Instances

Instances details
Show NATStatus Source # 
Instance details

Defined in Network.LibP2P.NAT.AutoNAT.AutoNAT

Eq NATStatus Source # 
Instance details

Defined in Network.LibP2P.NAT.AutoNAT.AutoNAT

data AutoNATConfig Source #

AutoNAT configuration.

Constructors

AutoNATConfig 

Fields

Server

handleAutoNAT :: AutoNATConfig -> StreamIO -> PeerId -> Multiaddr -> IO () Source #

Server handler: receive DIAL, validate, dial back, respond.

Security: - Rejects requests from relayed connections (P2PCircuit in observed addr) - Filters dial-back addresses to match observed IP

Client

requestAutoNAT :: StreamIO -> PeerId -> [Multiaddr] -> IO (Either String AutoNATDialResponse) Source #

Client: send DIAL with local addresses, receive response.

NAT status aggregation

probeNATStatusPure :: Int -> [Either String AutoNATDialResponse] -> NATStatus Source #

Pure aggregation of AutoNAT results into a NAT status. Counts OK responses as "public" votes, all other results as "private" votes.