diff options
author | 2019-01-28 16:36:34 +0000 | |
---|---|---|
committer | 2019-01-28 16:36:34 +0000 | |
commit | e3435566879c6a7ed564fc7108a12c0121ecd56c (patch) | |
tree | ceec2f8c0bb9c2bec55c5a0f77b79788dee74858 /plugin/hosts/hostsfile.go | |
parent | d571fbe04622096081a21935ce4c0bcda90361ce (diff) | |
download | coredns-e3435566879c6a7ed564fc7108a12c0121ecd56c.tar.gz coredns-e3435566879c6a7ed564fc7108a12c0121ecd56c.tar.zst coredns-e3435566879c6a7ed564fc7108a12c0121ecd56c.zip |
plugin/hosts: fix for ipv4-in-ipv6 (#2506)
* fix for ipv4-in-ipv6
* update comment as requested
Diffstat (limited to 'plugin/hosts/hostsfile.go')
-rw-r--r-- | plugin/hosts/hostsfile.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/plugin/hosts/hostsfile.go b/plugin/hosts/hostsfile.go index 8b2ffa0a6..1cce850c3 100644 --- a/plugin/hosts/hostsfile.go +++ b/plugin/hosts/hostsfile.go @@ -185,8 +185,10 @@ func (h *Hostsfile) parse(r io.Reader, override *hostsMap) *hostsMap { } // ipVersion returns what IP version was used textually +// For why the string is parsed end to start, +// see IPv4-Compatible IPv6 addresses - RFC 4291 section 2.5.5 func ipVersion(s string) int { - for i := 0; i < len(s); i++ { + for i := len(s) - 1; i >= 0; i-- { switch s[i] { case '.': return 4 |