Add support for more than 1 host on a given line
This commit is contained in:
parent
3f37fcf8fa
commit
8809ef02a1
@ -228,16 +228,13 @@ class HostBlocker:
|
|||||||
parts = line.split()
|
parts = line.split()
|
||||||
if len(parts) == 1:
|
if len(parts) == 1:
|
||||||
# "one host per line" format
|
# "one host per line" format
|
||||||
host = parts[0]
|
hosts = [parts[0]]
|
||||||
elif len(parts) == 2:
|
|
||||||
# /etc/hosts format
|
|
||||||
host = parts[1]
|
|
||||||
else:
|
else:
|
||||||
log.misc.error("Failed to parse: {!r}".format(line))
|
hosts = parts[1:]
|
||||||
return False
|
|
||||||
|
|
||||||
if '.' in host and not host.endswith('.localdomain'):
|
for host in hosts:
|
||||||
self._blocked_hosts.add(host)
|
if '.' in host and not host.endswith('.localdomain'):
|
||||||
|
self._blocked_hosts.add(host)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user