From e614a1c3f1ca825c6f5c67c2a408a483b9157136 Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 14:29:29 +0300 Subject: [PATCH] Probe localhost at the IPv4 loopback in the discovery test discover::tests::without_records_the_gateway_itself_is_asked starts a server on 127.0.0.1 and has the discovery ask the gateway at "127.0.0.1", "127.0.0.1:9987" and "localhost". The probe connected to the name through the system's resolver, and on a machine that resolves localhost to ::1 only (this one) nothing listens there: the third address found no gateway. The test helper that makes the probe, probing, connects to localhost at 127.0.0.1 instead. What the test checks is that the gateway is asked at the name localhost, not what the resolver makes of it, so it no longer depends on the resolver. Co-Authored-By: Claude Sonnet 5.5 --- crates/voelin-core/src/discover.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/voelin-core/src/discover.rs b/crates/voelin-core/src/discover.rs index e1da0cb..170f4f7 100644 --- a/crates/voelin-core/src/discover.rs +++ b/crates/voelin-core/src/discover.rs @@ -453,10 +453,15 @@ mod tests { lookups } - /// `lookups` asking the real `/.well-known/tsgw` at `port`. + /// `lookups` asking the real `/.well-known/tsgw` at `port`. A name is + /// connected to through the system's resolver, except `localhost`: the + /// servers of the tests listen on 127.0.0.1, and some machines resolve + /// `localhost` to `::1` only. (The test cares that the gateway is asked at + /// the name `localhost`, not what the resolver makes of it.) fn probing(mut lookups: Lookups, port: u16) -> Lookups { lookups.probe = Arc::new(move |name| { - async move { timeout(PROBE_TIMEOUT, well_known(&name, port)).await.ok()?.ok() }.boxed() + let host = if name == "localhost" { "127.0.0.1".to_owned() } else { name }; + async move { timeout(PROBE_TIMEOUT, well_known(&host, port)).await.ok()?.ok() }.boxed() }); lookups }