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 }