pub struct NatTraversalConfig {
pub role: EndpointRole,
pub bootstrap_nodes: Vec<SocketAddr>,
pub max_candidates: usize,
pub coordination_timeout: Duration,
pub enable_symmetric_nat: bool,
pub enable_relay_fallback: bool,
pub max_concurrent_attempts: usize,
pub bind_addr: Option<SocketAddr>,
pub prefer_rfc_nat_traversal: bool,
pub timeouts: TimeoutConfig,
}
Expand description
Configuration for NAT traversal behavior
This configuration controls various aspects of NAT traversal including security, performance, and reliability settings. Recent improvements in version 0.6.1 include enhanced security through protocol obfuscation and robust error handling.
§Security Features (Added in v0.6.1)
- Protocol Obfuscation: Random port binding prevents fingerprinting attacks
- Robust Error Handling: Panic-free operation with graceful error recovery
- Input Validation: Enhanced validation of configuration parameters
§Example
use ant_quic::nat_traversal_api::{NatTraversalConfig, EndpointRole};
use std::time::Duration;
use std::net::SocketAddr;
// Recommended secure configuration
let config = NatTraversalConfig {
role: EndpointRole::Client,
bootstrap_nodes: vec!["127.0.0.1:9000".parse::<SocketAddr>().unwrap()],
max_candidates: 10,
coordination_timeout: Duration::from_secs(10),
enable_symmetric_nat: true,
enable_relay_fallback: false,
max_concurrent_attempts: 5,
bind_addr: None, // Auto-select for security
prefer_rfc_nat_traversal: true,
timeouts: Default::default(),
};
Fields§
§role: EndpointRole
Role of this endpoint in the network
bootstrap_nodes: Vec<SocketAddr>
Bootstrap nodes for coordination and candidate discovery
max_candidates: usize
Maximum number of address candidates to maintain
coordination_timeout: Duration
Timeout for coordination rounds
enable_symmetric_nat: bool
Enable symmetric NAT prediction algorithms
enable_relay_fallback: bool
Enable automatic relay fallback
max_concurrent_attempts: usize
Maximum concurrent NAT traversal attempts
bind_addr: Option<SocketAddr>
Bind address for the endpoint
Some(addr)
: Bind to the specified addressNone
: Auto-select random port for enhanced security (recommended)
When None
, the system uses an internal method to automatically
select a random available port, providing protocol obfuscation and improved
security through port randomization.
§Security Benefits of None (Auto-Select)
- Protocol Obfuscation: Makes endpoint detection harder for attackers
- Port Randomization: Each instance gets a different port
- Fingerprinting Resistance: Reduces predictable network patterns
§Added in Version 0.6.1
Enhanced security through automatic random port selection
prefer_rfc_nat_traversal: bool
Prefer RFC-compliant NAT traversal frame format When true, will send RFC-compliant frames if the peer supports it
timeouts: TimeoutConfig
Timeout configuration for NAT traversal operations
Trait Implementations§
Source§impl Clone for NatTraversalConfig
impl Clone for NatTraversalConfig
Source§fn clone(&self) -> NatTraversalConfig
fn clone(&self) -> NatTraversalConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more