Skip to content

Commit

Permalink
Support loading blocklists from local files
Browse files Browse the repository at this point in the history
  • Loading branch information
Trellmor committed Sep 30, 2019
1 parent d73180c commit 00c61e3
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions update-zonefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,26 @@ def check_domain(domain, origin):

return True

def read_list(filename):
path = Path(filename)
if path.exists:
with path.open('r', encoding='utf8') as f:
return f.read()


def parse_lists(origin):
domains = set()
origin_name = dns.name.from_text(origin)
for l in lists:
data = download_list(l['url'])
if data:
print(l["url"])
data = None
if 'url' in l:
print(l['url'])
data = download_list(l['url'])
elif 'file' in l:
print(l['file'])
data = read_list(l['file'])

if data:
lines = data.splitlines()
print("\t{} lines".format(len(lines)))

Expand Down

0 comments on commit 00c61e3

Please sign in to comment.