deal with empty lines in input file (fix #15)

This commit is contained in:
Babak Farrokhi 2016-05-16 14:17:39 +04:30
parent d0db0c62aa
commit c7a602ae4e
Signed by: farrokhi
GPG Key ID: 6B267AD85D632E9A

View File

@ -34,9 +34,9 @@ import sys
import time import time
from statistics import stdev from statistics import stdev
import dns.flags
import dns.rdatatype import dns.rdatatype
import dns.resolver import dns.resolver
import dns.flags
__VERSION__ = 1.0 __VERSION__ = 1.0
__PROGNAME__ = os.path.basename(sys.argv[0]) __PROGNAME__ = os.path.basename(sys.argv[0])
@ -179,6 +179,9 @@ def main():
print((70 + width) * '-') print((70 + width) * '-')
for server in f: for server in f:
# check if we have a valid dns server address # check if we have a valid dns server address
if server.lstrip() == '': # deal with empty lines
continue
try: try:
ipaddress.ip_address(server) ipaddress.ip_address(server)
except ValueError: # so it is not a valid IPv4 or IPv6 address, so try to resolve host name except ValueError: # so it is not a valid IPv4 or IPv6 address, so try to resolve host name