diff options
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 |