mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
remove trailing dots from the parsed searches from host resolv.conf
This commit is contained in:
parent
0541d0bb79
commit
a215a88d91
@ -230,7 +230,11 @@ func parseResolvConf(reader io.Reader) (nameservers []string, searches []string,
|
||||
}
|
||||
}
|
||||
if fields[0] == "search" {
|
||||
searches = fields[1:]
|
||||
trimTrailingDot := []string{}
|
||||
for _, s := range fields[1:] {
|
||||
trimTrailingDot = append(trimTrailingDot, strings.TrimSuffix(s, "."))
|
||||
}
|
||||
searches = trimTrailingDot
|
||||
}
|
||||
if fields[0] == "options" {
|
||||
options = fields[1:]
|
||||
|
@ -74,6 +74,7 @@ func TestParseResolvConf(t *testing.T) {
|
||||
{"search ", []string{}, []string{}, []string{}, false}, // search empty
|
||||
{"search foo", []string{}, []string{"foo"}, []string{}, false},
|
||||
{"search foo bar", []string{}, []string{"foo", "bar"}, []string{}, false},
|
||||
{"search foo. bar", []string{}, []string{"foo", "bar"}, []string{}, false},
|
||||
{"search foo bar bat\n", []string{}, []string{"foo", "bar", "bat"}, []string{}, false},
|
||||
{"search foo\nsearch bar", []string{}, []string{"bar"}, []string{}, false},
|
||||
{"nameserver 1.2.3.4\nsearch foo bar", []string{"1.2.3.4"}, []string{"foo", "bar"}, []string{}, false},
|
||||
|
Loading…
Reference in New Issue
Block a user