Handle IPv6 ENETUNREACH in STUN probe gracefully

When IPv6 is unavailable on the host, treat NetworkUnreachable at
connect() as Ok(None) instead of propagating an error, so the dual
STUN probe succeeds with just the IPv4 result and no spurious WARN.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Igor 2026-02-18 21:28:30 +03:00
parent 28a5bcbd5c
commit 17b3c612a1
1 changed files with 5 additions and 4 deletions

View File

@ -50,10 +50,11 @@ pub async fn stun_probe_family(stun_addr: &str, family: IpFamily) -> Result<Opti
let target_addr = resolve_stun_addr(stun_addr, family).await?;
if let Some(addr) = target_addr {
socket
.connect(addr)
.await
.map_err(|e| ProxyError::Proxy(format!("STUN connect failed: {e}")))?;
match socket.connect(addr).await {
Ok(()) => {}
Err(e) if e.kind() == std::io::ErrorKind::NetworkUnreachable => return Ok(None),
Err(e) => return Err(ProxyError::Proxy(format!("STUN connect failed: {e}"))),
}
} else {
return Ok(None);
}