';' in resolv.conf also means comment
Skip ';'-prefixed lines in /etc/resolv.conf as well.
This commit is contained in:
parent
179eee87e1
commit
f2d9d153ce
2 changed files with 3 additions and 1 deletions
|
@ -38,7 +38,7 @@ func GetSystemNameServers() ([]net.IP, error) {
|
|||
lines := strings.Split(string(file), "\n")
|
||||
for l := range lines {
|
||||
trimmed := strings.TrimSpace(lines[l])
|
||||
if strings.HasPrefix(trimmed, "#") {
|
||||
if len(trimmed) == 0 || trimmed[0] == '#' || trimmed[0] == ';' {
|
||||
continue
|
||||
}
|
||||
fields := strings.Fields(trimmed)
|
||||
|
|
|
@ -40,6 +40,8 @@ func TestGetDNSServers(t *testing.T) {
|
|||
defer os.Remove(file.Name())
|
||||
|
||||
ioutil.WriteFile(file.Name(), []byte(`
|
||||
# comment
|
||||
; comment
|
||||
nameserver 2001:4860:4860::8844
|
||||
nameserver 2001:4860:4860::8888
|
||||
nameserver 8.8.8.8
|
||||
|
|
Loading…
Reference in a new issue