macula_nat_system (macula v0.20.5)

View Source

NAT Traversal System Supervisor.

Supervises the NAT traversal subsystem which provides: - NAT type detection using NATCracker methodology - NAT information caching with stale-while-revalidate - (Future phases) Hole punching coordination, port prediction, distributed relay, and connection quality monitoring

Architecture:

   macula_nat_system (this supervisor)
   +-- macula_nat_cache       - NAT profile caching with TTL
   +-- macula_nat_detector    - Fast NAT type detection
   +-- macula_nat_coordinator - Hole punch coordination (Phase 2)
   

Supervision Strategy: - one_for_one: Each child is independent, failures don't cascade - NAT cache failure doesn't require detector restart (and vice versa)

Phase 1 Implementation (v0.12.0): - NAT type detection (mapping, filtering, allocation policies) - NAT profile caching with 5-minute TTL - DHT integration for NAT profile advertisement

Future Phases: - Phase 2: Hole punching (macula_hole_punch, macula_nat_coordinator) - COMPLETED - Phase 3: Port prediction (macula_port_predictor) - COMPLETED - Phase 4: Distributed relay (macula_relay_registry, macula_relay_node) - COMPLETED

Summary

Functions

Initialize the supervisor with child specifications.

Start the NAT system supervisor with default options.

Start the NAT system supervisor with given options. Options: cache_max_entries - Max NAT profiles in cache (default: 10000) cache_ttl_seconds - NAT profile TTL in seconds (default: 300) detection_timeout_ms - NAT detection timeout in ms (default: 2000)

Functions

init(Opts)

-spec init(map()) -> {ok, {supervisor:sup_flags(), [supervisor:child_spec()]}}.

Initialize the supervisor with child specifications.

start_link()

-spec start_link() -> {ok, pid()} | {error, term()}.

Start the NAT system supervisor with default options.

start_link(Opts)

-spec start_link(map()) -> {ok, pid()} | {error, term()}.

Start the NAT system supervisor with given options. Options: cache_max_entries - Max NAT profiles in cache (default: 10000) cache_ttl_seconds - NAT profile TTL in seconds (default: 300) detection_timeout_ms - NAT detection timeout in ms (default: 2000)