macula_nat_connector (macula v0.20.5)

View Source

NAT-aware Peer Connector.

Provides intelligent connection establishment using the optimal strategy based on NAT profiles. Integrates: - NAT coordinator for strategy determination - Hole punch executor for direct connections - Relay fallback when direct fails

Connection Strategy Order: 1. Direct - If target can receive unsolicited (Full Cone NAT) 2. Hole Punch - If NAT profiles indicate feasibility 3. Relay - Fallback via gateway

Usage: connect(TargetNodeId, Opts) to establish connection.

Summary

Functions

Connect to a peer using optimal strategy. Automatically determines best approach based on NAT profiles.

Disconnect from a peer.

Types

connect_opts/0

-type connect_opts() ::
          #{timeout => timeout(), skip_hole_punch => boolean(), relay_endpoint => binary()}.

connect_result/0

-type connect_result() ::
          {ok, quicer:connection_handle(), direct | hole_punch | relay} | {error, term()}.

Functions

connect(LocalNodeId, TargetNodeId)

-spec connect(binary(), binary()) -> connect_result().

Connect to a peer using optimal strategy. Automatically determines best approach based on NAT profiles.

connect(LocalNodeId, TargetNodeId, Opts)

-spec connect(binary(), binary(), connect_opts()) -> connect_result().

Connect with options.

disconnect(Conn)

-spec disconnect(quicer:connection_handle()) -> ok.

Disconnect from a peer.