From 1a0799150828cf49f90b15a52c986367cba25528 Mon Sep 17 00:00:00 2001 From: ivulit Date: Thu, 19 Feb 2026 00:15:42 +0300 Subject: [PATCH] Extend IPv6 STUN connect error handling to cover more unreachable cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In addition to ENETUNREACH, also treat HostUnreachable, Unsupported and NetworkDown as non-fatal when probing IPv6 — all indicate the family is unavailable. Guard is limited to IpFamily::V6 so any IPv4 connect failure still propagates as an error. --- src/network/stun.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/network/stun.rs b/src/network/stun.rs index e796858..6a93339 100644 --- a/src/network/stun.rs +++ b/src/network/stun.rs @@ -52,7 +52,13 @@ pub async fn stun_probe_family(stun_addr: &str, family: IpFamily) -> Result {} - Err(e) if e.kind() == std::io::ErrorKind::NetworkUnreachable => return Ok(None), + 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 {