Merge: - autohosts: support tab character

Close #1686

* commit '2f454117ce7562df934b20c385c11006f8a1cf8f':
  - autohosts: support tab character
This commit is contained in:
Simon Zolin 2020-05-18 19:18:48 +03:00
commit 806f81ede9
1 changed files with 11 additions and 4 deletions

View File

@ -154,14 +154,21 @@ func (a *AutoHosts) load(table map[string][]net.IP, tableRev map[string]string,
return
}
line = strings.TrimSpace(line)
if len(line) == 0 || line[0] == '#' {
continue
}
ip := SplitNext(&line, ' ')
ipAddr := net.ParseIP(ip)
fields := strings.Fields(line)
if len(fields) < 2 {
continue
}
ipAddr := net.ParseIP(fields[0])
if ipAddr == nil {
continue
}
for {
host := SplitNext(&line, ' ')
for i := 1; i != len(fields); i++ {
host := fields[i]
if len(host) == 0 {
break
}