Proxy: Test & document localhost. name resolution. (#531)

* Proxy: Test & document localhost. name resolution.

Closes #358.

Signed-off-by: Brian Smith <brian@briansmith.org>
This commit is contained in:
Brian Smith 2018-03-07 17:40:39 -10:00 committed by GitHub
parent 7aa1d0b26d
commit 3a73411375
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 0 deletions

View File

@ -209,6 +209,30 @@ mod tests {
assert_eq!("name.namespace.svc.cluster.local", assert_eq!("name.namespace.svc.cluster.local",
local("name.namespace.svc.cluster.local.", "namespace")); 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. // Ports are preserved.
assert_eq!("name.namespace.svc.cluster.local:1234", assert_eq!("name.namespace.svc.cluster.local:1234",
local("name:1234", "namespace")); local("name:1234", "namespace"));