}
case "search": // set search path to given servers
- conf.search = make([]string, len(f)-1)
- for i := 0; i < len(conf.search); i++ {
- conf.search[i] = ensureRooted(f[i+1])
+ conf.search = make([]string, 0, len(f)-1)
+ for i := 1; i < len(f); i++ {
+ name := ensureRooted(f[i])
+ if name == "." {
+ continue
+ }
+ conf.search = append(conf.search, name)
}
case "options": // magic options
attempts: 2,
},
},
+ {
+ name: "testdata/search-single-dot-resolv.conf",
+ want: &dnsConfig{
+ servers: []string{"8.8.8.8:53"},
+ search: []string{},
+ ndots: 1,
+ timeout: 5 * time.Second,
+ attempts: 2,
+ },
+ },
{
name: "testdata/empty-resolv.conf",
want: &dnsConfig{
getHostname = func() (string, error) { return "host.domain.local", nil }
for _, tt := range dnsReadConfigTests {
+ if len(tt.want.search) == 0 {
+ tt.want.search = append(tt.want.search, dnsDefaultSearch()...)
+ }
conf := dnsReadConfig(tt.name)
if conf.err != nil {
t.Fatal(conf.err)