From e54dce53663cbe3291dfbcd0d8af97d8caa45113 Mon Sep 17 00:00:00 2001 From: ivulit Date: Wed, 18 Feb 2026 23:22:31 +0300 Subject: [PATCH] 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. --- src/network/stun.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/network/stun.rs b/src/network/stun.rs index 251454e..6a93339 100644 --- a/src/network/stun.rs +++ b/src/network/stun.rs @@ -50,10 +50,17 @@ pub async fn stun_probe_family(stun_addr: &str, family: IpFamily) -> Result {} + Err(e) if family == IpFamily::V6 && matches!( + e.kind(), + std::io::ErrorKind::NetworkUnreachable + | std::io::ErrorKind::HostUnreachable + | std::io::ErrorKind::Unsupported + | std::io::ErrorKind::NetworkDown + ) => return Ok(None), + Err(e) => return Err(ProxyError::Proxy(format!("STUN connect failed: {e}"))), + } } else { return Ok(None); }