Skip to content

Commit

Permalink
Throw if we don't find hosts in a file
Browse files Browse the repository at this point in the history
  • Loading branch information
ndfred committed Apr 27, 2019
1 parent 6ea70a3 commit c7d2ed7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions build_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,25 @@ def parse_domain_line(line):
if domain in INVALID_DOMAINS:
domain = None

# Uncomment to visually debug unmatched lines and make sure we parse all hosts
# if original_line and domain is None and not original_line.startswith('#'):
# print original_line.decode('utf8')

return domain

def parse_host_file(url):
found_domains = False

for line in download_file(url).split('\n'):
domain = parse_domain_line(line)

if domain:
found_domains = True
yield domain

if not found_domains:
raise Exception('Couldn\'t find any domains in that URL')

def output_rules(configuration_script_path):
prefix = 'service dns forwarding blacklist'
domains_buffer = []
Expand Down

0 comments on commit c7d2ed7

Please sign in to comment.