make loops in DNSResolver less nested
This commit is contained in:
parent
8bb90bc02f
commit
477caf3c80
1 changed files with 23 additions and 16 deletions
|
@ -276,10 +276,13 @@ class DNSResolver(object):
|
|||
content = f.readlines()
|
||||
for line in content:
|
||||
line = line.strip()
|
||||
if line:
|
||||
if line.startswith(b'nameserver'):
|
||||
if not line and line.startswith(b'nameserver'):
|
||||
continue
|
||||
|
||||
parts = line.split()
|
||||
if len(parts) >= 2:
|
||||
if len(parts) < 2:
|
||||
continue
|
||||
|
||||
server = parts[1]
|
||||
if common.is_ip(server) == socket.AF_INET:
|
||||
if type(server) != str:
|
||||
|
@ -299,9 +302,13 @@ class DNSResolver(object):
|
|||
for line in f.readlines():
|
||||
line = line.strip()
|
||||
parts = line.split()
|
||||
if len(parts) >= 2:
|
||||
if len(parts) < 2:
|
||||
continue
|
||||
|
||||
ip = parts[0]
|
||||
if common.is_ip(ip):
|
||||
if not common.is_ip(ip):
|
||||
continue
|
||||
|
||||
for i in range(1, len(parts)):
|
||||
hostname = parts[i]
|
||||
if hostname:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue