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()
|
content = f.readlines()
|
||||||
for line in content:
|
for line in content:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if line:
|
if not line and line.startswith(b'nameserver'):
|
||||||
if line.startswith(b'nameserver'):
|
continue
|
||||||
|
|
||||||
parts = line.split()
|
parts = line.split()
|
||||||
if len(parts) >= 2:
|
if len(parts) < 2:
|
||||||
|
continue
|
||||||
|
|
||||||
server = parts[1]
|
server = parts[1]
|
||||||
if common.is_ip(server) == socket.AF_INET:
|
if common.is_ip(server) == socket.AF_INET:
|
||||||
if type(server) != str:
|
if type(server) != str:
|
||||||
|
@ -299,9 +302,13 @@ class DNSResolver(object):
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
parts = line.split()
|
parts = line.split()
|
||||||
if len(parts) >= 2:
|
if len(parts) < 2:
|
||||||
|
continue
|
||||||
|
|
||||||
ip = parts[0]
|
ip = parts[0]
|
||||||
if common.is_ip(ip):
|
if not common.is_ip(ip):
|
||||||
|
continue
|
||||||
|
|
||||||
for i in range(1, len(parts)):
|
for i in range(1, len(parts)):
|
||||||
hostname = parts[i]
|
hostname = parts[i]
|
||||||
if hostname:
|
if hostname:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue