Skip to content

Commit 7417cfb

Browse files
doublegateclaude
andcommitted
feat(discovery): add multiple STUN server providers for NAT detection
Expand STUN server list from 2 (Google only) to 5 servers across 4 providers to improve NAT detection success rate. ## STUN Servers Added | Provider | Address | Port | Notes | |------------|----------------------|-------|--------------------------| | Cloudflare | 162.159.207.0 | 3478 | Standard STUN port | | Twilio | 34.203.251.210 | 3478 | AWS-hosted | | Nextcloud | 159.69.191.124 | 443 | HTTPS port (firewall-friendly) | | Google | 74.125.250.129 | 19302 | Primary (existing) | | Google | 74.125.250.130 | 19302 | Secondary (existing) | ## Benefits - Multiple providers: If one is blocked, others may succeed - Multiple ports: 3478, 443, 19302 for firewall bypass - Geographically diverse: Better latency options - Port 443 fallback: Often allowed through restrictive firewalls ## Technical Details - IPs hardcoded for reliability (DNS may be filtered) - Servers tried sequentially until one responds - Graceful fallback to local mode if all fail 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 573c7df commit 7417cfb

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

crates/wraith-discovery/src/nat/types.rs

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,38 @@ pub struct NatDetector {
102102
impl NatDetector {
103103
/// Create a new NAT detector with default STUN servers
104104
///
105-
/// Uses Google's public STUN servers. Note that these IPs are hardcoded
106-
/// and may change. In production, implement DNS resolution for:
107-
/// - stun.l.google.com:19302
108-
/// - stun1.l.google.com:19302
109-
/// - stun2.l.google.com:19302
105+
/// Uses multiple public STUN servers from different providers for redundancy.
106+
/// IPs are hardcoded for reliability (DNS may be blocked/filtered).
110107
///
111-
/// TODO: Implement DNS-based STUN server resolution
108+
/// Providers included:
109+
/// - Cloudflare (stun.cloudflare.com:3478)
110+
/// - Twilio (global.stun.twilio.com:3478)
111+
/// - Nextcloud (stun.nextcloud.com:443)
112+
/// - Google (stun.l.google.com:19302)
113+
///
114+
/// Different ports (3478, 443, 19302) increase chance of bypassing firewalls.
115+
///
116+
/// TODO: Implement DNS-based STUN server resolution as fallback
112117
#[must_use]
113118
pub fn new() -> Self {
114119
Self {
115120
stun_servers: vec![
116-
// Google Public STUN servers (hardcoded IPs)
121+
// Cloudflare STUN (port 3478 - standard STUN port)
122+
// stun.cloudflare.com:3478
123+
"162.159.207.0:3478"
124+
.parse()
125+
.expect("valid STUN server address"),
126+
// Twilio STUN (port 3478)
127+
// global.stun.twilio.com:3478
128+
"34.203.251.210:3478"
129+
.parse()
130+
.expect("valid STUN server address"),
131+
// Nextcloud STUN (port 443 - HTTPS port, often allowed through firewalls)
132+
// stun.nextcloud.com:443
133+
"159.69.191.124:443"
134+
.parse()
135+
.expect("valid STUN server address"),
136+
// Google Public STUN servers (port 19302)
117137
// stun.l.google.com:19302
118138
"74.125.250.129:19302"
119139
.parse()

0 commit comments

Comments
 (0)