Skip to content

Commit

Permalink
Added handler for invalid names
Browse files Browse the repository at this point in the history
  • Loading branch information
CalumMc authored Dec 18, 2017
1 parent b8c48c7 commit 26488fd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions generate-zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ def is_valid_ipv6(ip_addr):
return False

def is_valid_domain(name):
if re.match('^([a-zA-Z0-9._-]+\.)*[a-zA-Z0-9._-]+\.?$', name) and len(name) < 64 and name[:1].isalnum():
return True
else:
try:
if re.match('^([a-zA-Z0-9._-]+\.)*[a-zA-Z0-9._-]+\.?$', name) and len(name) < 64 and name[:1].isalnum():
return True
else:
return False
except TypeError:
print("Skipped invalid name: {}".format(name))
return False

def is_valid_txt(txt):
Expand Down

0 comments on commit 26488fd

Please sign in to comment.