Previous behaviour only picked the first entry (official hostname) but not the aliases.
R=rsc
CC=golang-dev
https://golang.org/cl/193092
if len(f) < 2 || ParseIP(f[0]) == nil {
continue
}
- h := f[1]
- old, _ := hs[h]
- hs[h] = appendHost(old, f[0])
+ for i := 1; i < len(f); i++ {
+ h := f[i]
+ old, _ := hs[h]
+ hs[h] = appendHost(old, f[0])
+ }
}
// Update the data cache.
hosts.time, _, _ = os.Time()
IPv4(127, 1, 1, 1),
}},
hostTest{"loki", []IP{}},
+ hostTest{"ullr", []IP{
+ IPv4(127, 1, 1, 2),
+ }},
+ hostTest{"ullrhost", []IP{
+ IPv4(127, 1, 1, 2),
+ }},
}
func TestLookupStaticHost(t *testing.T) {
127.0.0.3 odin # inline comment
::2 odin
127.1.1.1 thor
+# aliases
+127.1.1.2 ullr ullrhost
# Bogus entries that must be ignored.
123.123.123 loki
321.321.321.321