macula_relay_node (macula v0.20.5)
View SourcePeer Relay Node.
Provides relay functionality for peers that cannot establish direct connections due to NAT restrictions. A relay node:
- Accepts connections from peers behind restrictive NATs - Forwards traffic between connected peers - Manages relay sessions with bandwidth limits - Auto-registers with relay registry when capable
Relay Protocol: 1. Peer A connects to relay with RELAY_REQUEST(target_id) 2. Relay checks if target is reachable and accepts 3. Relay establishes/reuses connection to target 4. Relay forwards bidirectional traffic 5. Either peer can close the relay session
Resource Limits: - Max concurrent relay sessions (default: 100) - Per-session bandwidth limit (default: 1 MB/s) - Session timeout (default: 30 minutes)
Summary
Functions
Close a relay session.
Disable relay functionality.
Enable relay functionality on this node.
Enable relay with options. Options: node_id - This node's ID endpoint - This node's endpoint for relay registry capacity - Max concurrent sessions
Get active relay sessions.
Get relay statistics.
Check if relay is enabled.
Request a relay session to target. Returns session ID on success.
Start the relay node server.
Types
-type relay_stats() :: #{enabled := boolean(), max_sessions := pos_integer(), active_sessions := non_neg_integer(), total_bytes_relayed := non_neg_integer(), total_sessions_created := non_neg_integer()}.
Functions
-spec close_relay(binary()) -> ok.
Close a relay session.
-spec disable() -> ok.
Disable relay functionality.
-spec enable() -> ok | {error, term()}.
Enable relay functionality on this node.
Enable relay with options. Options: node_id - This node's ID endpoint - This node's endpoint for relay registry capacity - Max concurrent sessions
-spec get_sessions() -> [relay_session()].
Get active relay sessions.
-spec get_stats() -> relay_stats().
Get relay statistics.
-spec is_enabled() -> boolean().
Check if relay is enabled.
Request a relay session to target. Returns session ID on success.
Start the relay node server.