From 2f454117ce7562df934b20c385c11006f8a1cf8f Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Mon, 18 May 2020 18:46:17 +0300 Subject: [PATCH] - autohosts: support tab character --- util/auto_hosts.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/util/auto_hosts.go b/util/auto_hosts.go index 046e80e3..6e78f1ee 100644 --- a/util/auto_hosts.go +++ b/util/auto_hosts.go @@ -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 }