| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
LibP2P.NAT
Contents
Description
NAT traversal handler registration (specsautonat, specsrelay, specsrelayDCUtR).
Wires the AutoNAT, Circuit Relay v2, and DCUtR module implementations
into the Switch protocol registry, in the style of
registerIdentifyHandlers:
libp2pautonat/1.0.0 — AutoNAT dial-back server libp2pcircuitrelay0.2.0/hop — Circuit Relay v2 relay server libp2pcircuitrelay0.2.0/stop — Circuit Relay v2 target (inbound relayed streams) libp2pdcutr — DCUtR hole-punch coordination (handler side)
Synopsis
- data NATConfig = NATConfig {
- ncRelayConfig :: !RelayConfig
- ncOnRelayedStream :: !(PeerId -> Maybe RelayLimit -> StreamIO -> IO ())
- defaultNATConfig :: NATConfig
- registerNATHandlers :: Switch -> NATConfig -> IO RelayState
- registerAutoNATHandler :: Switch -> IO ()
- registerRelayHopHandler :: Switch -> RelayState -> IO ()
- registerRelayStopHandler :: Switch -> (PeerId -> Maybe RelayLimit -> StreamIO -> IO ()) -> IO ()
- registerDCUtRHandler :: Switch -> IO ()
Configuration
Configuration for the NAT traversal handlers.
Constructors
| NATConfig | |
Fields
| |
defaultNATConfig :: NATConfig Source #
Default NAT configuration: default relay limits, and inbound relayed streams are left to the remote end (no local consumer).
Registration
registerNATHandlers :: Switch -> NATConfig -> IO RelayState Source #
Register all four NAT protocol handlers on the Switch.
Creates the relay server state from ncRelayConfig and returns it so
callers can inspect reservations/circuits.
registerAutoNATHandler :: Switch -> IO () Source #
Register the AutoNAT server handler (libp2pautonat/1.0.0).
The dial-back deliberately bypasses the connection pool: reusing the requester's existing connection would always report success. Instead a fresh transport dial + upgrade verifies both reachability and identity, and the probe connection is closed immediately (go-libp2p uses a separate dialer host for the same reason).
registerRelayHopHandler :: Switch -> RelayState -> IO () Source #
Register the Circuit Relay v2 hop handler (libp2pcircuitrelay0.2.0/hop): serve RESERVE and CONNECT requests.
registerRelayStopHandler :: Switch -> (PeerId -> Maybe RelayLimit -> StreamIO -> IO ()) -> IO () Source #
Register the Circuit Relay v2 stop handler (libp2pcircuitrelay0.2.0/stop): accept inbound relayed streams and hand them to the application callback.
registerDCUtRHandler :: Switch -> IO () Source #
Register the DCUtR handler (libp2pdcutr).
Answers the CONNECT/SYNC exchange with our listen addresses and dials the initiator's addresses through the Switch for the hole punch.