minor refactoring
This commit is contained in:
parent
5a323807eb
commit
74f88e6601
@ -39,7 +39,7 @@ import dns.resolver
|
|||||||
|
|
||||||
__VERSION__ = 1.1
|
__VERSION__ = 1.1
|
||||||
__PROGNAME__ = os.path.basename(sys.argv[0])
|
__PROGNAME__ = os.path.basename(sys.argv[0])
|
||||||
should_stop = False
|
shutdown = False
|
||||||
|
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
@ -63,7 +63,7 @@ usage: %s [-h] [-q] [-v] [-s server] [-p port] [-P port] [-S address] [-c count]
|
|||||||
|
|
||||||
|
|
||||||
def signal_handler(sig, frame):
|
def signal_handler(sig, frame):
|
||||||
global should_stop
|
global shutdown
|
||||||
if should_stop: # pressed twice, so exit immediately
|
if should_stop: # pressed twice, so exit immediately
|
||||||
exit(0)
|
exit(0)
|
||||||
should_stop = True # pressed once, exit gracefully
|
should_stop = True # pressed once, exit gracefully
|
||||||
@ -163,7 +163,7 @@ def main():
|
|||||||
print("%s DNS: %s:%d, hostname: %s, rdatatype: %s" % (__PROGNAME__, dnsserver, dst_port, hostname, dnsrecord))
|
print("%s DNS: %s:%d, hostname: %s, rdatatype: %s" % (__PROGNAME__, dnsserver, dst_port, hostname, dnsrecord))
|
||||||
|
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if should_stop:
|
if shutdown:
|
||||||
break
|
break
|
||||||
try:
|
try:
|
||||||
stime = time.time()
|
stime = time.time()
|
||||||
|
@ -71,7 +71,7 @@ class Colors(object):
|
|||||||
|
|
||||||
|
|
||||||
# Globarl Variables
|
# Globarl Variables
|
||||||
should_stop = False
|
shutdown = False
|
||||||
|
|
||||||
|
|
||||||
def whoisrecord(ip):
|
def whoisrecord(ip):
|
||||||
@ -119,7 +119,7 @@ def usage():
|
|||||||
|
|
||||||
|
|
||||||
def signal_handler(sig, frame):
|
def signal_handler(sig, frame):
|
||||||
global should_stop
|
global shutdown
|
||||||
if should_stop: # pressed twice, so exit immediately
|
if should_stop: # pressed twice, so exit immediately
|
||||||
exit(0)
|
exit(0)
|
||||||
should_stop = True # pressed once, exit gracefully
|
should_stop = True # pressed once, exit gracefully
|
||||||
@ -270,7 +270,7 @@ def main():
|
|||||||
print("%s DNS: %s:%d, hostname: %s, rdatatype: %s" % (__PROGNAME__, dnsserver, dest_port, hostname, dnsrecord))
|
print("%s DNS: %s:%d, hostname: %s, rdatatype: %s" % (__PROGNAME__, dnsserver, dest_port, hostname, dnsrecord))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
if should_stop:
|
if shutdown:
|
||||||
break
|
break
|
||||||
|
|
||||||
# some platforms permit opening a DGRAM socket for ICMP without root permission
|
# some platforms permit opening a DGRAM socket for ICMP without root permission
|
||||||
@ -336,7 +336,7 @@ def main():
|
|||||||
if ASN and ASN.asn != "NA":
|
if ASN and ASN.asn != "NA":
|
||||||
as_name = "[%s %s] " % (ASN.asn, ASN.owner)
|
as_name = "[%s %s] " % (ASN.asn, ASN.owner)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
if should_stop:
|
if shutdown:
|
||||||
exit(0)
|
exit(0)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -361,7 +361,7 @@ def main():
|
|||||||
if (hops >= count) or (curr_addr == dnsserver) or reached:
|
if (hops >= count) or (curr_addr == dnsserver) or reached:
|
||||||
break
|
break
|
||||||
|
|
||||||
if expert_mode and not should_stop:
|
if expert_mode and not shutdown:
|
||||||
expert_report(trace_path, color_mode)
|
expert_report(trace_path, color_mode)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user