pub trait NatStrategy: Send + Sync {
// Required method
fn select_tier(
&self,
relay_port: u16,
) -> Pin<Box<dyn Future<Output = Result<ReachabilityTier, NodeError>> + Send + '_>>;
}Expand description
Strategy for NAT probing and tier selection (spec section 10.12.8).
Abstracted as a trait to enable mock implementations in tests.
Production code uses DefaultNatStrategy; tests provide
pre-computed results.
Required Methods§
Sourcefn select_tier(
&self,
relay_port: u16,
) -> Pin<Box<dyn Future<Output = Result<ReachabilityTier, NodeError>> + Send + '_>>
fn select_tier( &self, relay_port: u16, ) -> Pin<Box<dyn Future<Output = Result<ReachabilityTier, NodeError>> + Send + '_>>
Probes NAT type and selects the best reachability tier.
Steps per §10.12.8:
- Probe NAT type via STUN.
- Attempt Tier 1 (UPnP/NAT-PMP).
- If Tier 1 fails and NAT is non-symmetric, attempt Tier 2 (STUN).
- If Tier 2 fails or NAT is symmetric, attempt Tier 3 (bridge).