add "-n" option to disable reverse lookups
This commit is contained in:
parent
d90cc4a8d5
commit
09a67904b1
@ -120,10 +120,11 @@ def main():
|
||||
dest_port = 53
|
||||
hops = 0
|
||||
as_lookup = False
|
||||
should_resolve = True
|
||||
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "aqhc:s:t:w:p:",
|
||||
["help", "output=", "count=", "server=", "quiet", "type=", "wait=", "asn", "port"])
|
||||
opts, args = getopt.getopt(sys.argv[1:], "aqhc:s:t:w:p:n",
|
||||
["help", "count=", "server=", "quiet", "type=", "wait=", "asn", "port"])
|
||||
except getopt.GetoptError as err:
|
||||
# print help information and exit:
|
||||
print(err) # will print something like "option -a not recognized"
|
||||
@ -149,6 +150,8 @@ def main():
|
||||
dnsrecord = a
|
||||
elif o in ("-p", "--port"):
|
||||
dest_port = int(a)
|
||||
elif o in ("-n"):
|
||||
should_resolve = False
|
||||
elif o in ("-a", "--asn"):
|
||||
if has_whois:
|
||||
as_lookup = True
|
||||
@ -168,6 +171,7 @@ def main():
|
||||
ttl = 1
|
||||
reached = False
|
||||
|
||||
if not quiet:
|
||||
print("%s DNS: %s:%d, hostname: %s, rdatatype: %s" % (__PROGNAME__, dnsserver, dest_port, hostname, dnsrecord))
|
||||
|
||||
while True:
|
||||
@ -234,6 +238,7 @@ def main():
|
||||
|
||||
elapsed -= timeout * 1000
|
||||
|
||||
if should_resolve:
|
||||
try:
|
||||
if curr_addr:
|
||||
curr_name = socket.gethostbyaddr(curr_addr)[0]
|
||||
@ -243,6 +248,8 @@ def main():
|
||||
pass
|
||||
except:
|
||||
print("unxpected error: ", sys.exc_info()[0])
|
||||
else:
|
||||
curr_name = curr_addr
|
||||
|
||||
if curr_addr:
|
||||
as_name = ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user