| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
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
- data NATStatus
- data AutoNATConfig = AutoNATConfig {
- natThreshold :: !Int
- natDialBack :: !(PeerId -> [Multiaddr] -> IO (Either String ()))
- handleAutoNAT :: AutoNATConfig -> StreamIO -> PeerId -> Multiaddr -> IO ()
- requestAutoNAT :: StreamIO -> PeerId -> [Multiaddr] -> IO (Either String AutoNATDialResponse)
- probeNATStatusPure :: Int -> [Either String AutoNATDialResponse] -> NATStatus
Types
Detected NAT status.
Constructors
| NATPublic | |
| NATPrivate | |
| NATUnknown |
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.