From 3a734113754e6c7bbc8e177b461531ec445babc2 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Wed, 7 Mar 2018 17:40:39 -1000 Subject: [PATCH] Proxy: Test & document localhost. name resolution. (#531) * Proxy: Test & document localhost. name resolution. Closes #358. Signed-off-by: Brian Smith --- proxy/src/fully_qualified_authority.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/proxy/src/fully_qualified_authority.rs b/proxy/src/fully_qualified_authority.rs index 2d4440f1b..1a01e3057 100644 --- a/proxy/src/fully_qualified_authority.rs +++ b/proxy/src/fully_qualified_authority.rs @@ -209,6 +209,30 @@ mod tests { assert_eq!("name.namespace.svc.cluster.local", local("name.namespace.svc.cluster.local.", "namespace")); + // Irrespective of how other absolute names are resolved, "localhost." + // absolute names aren't ever resolved through the destination service, + // as prescribed by https://tools.ietf.org/html/rfc6761#section-6.3: + // + // The domain "localhost." and any names falling within ".localhost." + // are special in the following ways: [...] + // + // Name resolution APIs and libraries SHOULD recognize localhost + // names as special and SHOULD always return the IP loopback address + // for address queries [...] Name resolution APIs SHOULD NOT send + // queries for localhost names to their configured caching DNS server(s). + external("localhost.", "namespace"); + external("name.localhost.", "namespace"); + external("name.namespace.svc.localhost.", "namespace"); + + // Although it probably isn't the desired behavior in almost any circumstance, match + // standard behavior for non-absolute "localhost" and names that end with + // ".localhost" at least until we're comfortable implementing + // https://wiki.tools.ietf.org/html/draft-ietf-dnsop-let-localhost-be-localhost. + assert_eq!("localhost.namespace.svc.cluster.local", + local("localhost", "namespace")); + assert_eq!("name.localhost.svc.cluster.local", + local("name.localhost", "namespace")); + // Ports are preserved. assert_eq!("name.namespace.svc.cluster.local:1234", local("name:1234", "namespace"));