improve whois
This commit is contained in:
parent
380c357e5f
commit
f167739ea2
@ -29,6 +29,7 @@ import concurrent.futures
|
|||||||
import getopt
|
import getopt
|
||||||
import ipaddress
|
import ipaddress
|
||||||
import os
|
import os
|
||||||
|
import pickle
|
||||||
import signal
|
import signal
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
@ -36,21 +37,17 @@ import time
|
|||||||
|
|
||||||
import dns.rdatatype
|
import dns.rdatatype
|
||||||
import dns.resolver
|
import dns.resolver
|
||||||
|
from cymruwhois import cymruwhois
|
||||||
|
|
||||||
__author__ = 'Babak Farrokhi (babak@farrokhi.net)'
|
__author__ = 'Babak Farrokhi (babak@farrokhi.net)'
|
||||||
__license__ = 'BSD'
|
__license__ = 'BSD'
|
||||||
__version__ = 1.3
|
__version__ = 1.3
|
||||||
|
|
||||||
|
|
||||||
def test_import():
|
def test_import():
|
||||||
|
# passing this test means imports were successful
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# http://pythonhosted.org/cymruwhois/
|
|
||||||
try:
|
|
||||||
import cymruwhois
|
|
||||||
|
|
||||||
has_whois = True
|
|
||||||
except ImportError:
|
|
||||||
has_whois = False
|
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
__PROGNAME__ = os.path.basename(sys.argv[0])
|
__PROGNAME__ = os.path.basename(sys.argv[0])
|
||||||
@ -76,10 +73,6 @@ class Colors(object):
|
|||||||
# Globarl Variables
|
# Globarl Variables
|
||||||
should_stop = False
|
should_stop = False
|
||||||
|
|
||||||
if has_whois:
|
|
||||||
from cymruwhois import cymruwhois
|
|
||||||
import pickle
|
|
||||||
|
|
||||||
|
|
||||||
def whoisrecord(ip):
|
def whoisrecord(ip):
|
||||||
try:
|
try:
|
||||||
@ -255,10 +248,7 @@ def main():
|
|||||||
elif o in ("-n"):
|
elif o in ("-n"):
|
||||||
should_resolve = False
|
should_resolve = False
|
||||||
elif o in ("-a", "--asn"):
|
elif o in ("-a", "--asn"):
|
||||||
if has_whois:
|
|
||||||
as_lookup = True
|
as_lookup = True
|
||||||
else:
|
|
||||||
print('Warning: cymruwhois module cannot be loaded. AS Lookup disabled.')
|
|
||||||
else:
|
else:
|
||||||
usage()
|
usage()
|
||||||
|
|
||||||
@ -339,7 +329,7 @@ def main():
|
|||||||
|
|
||||||
if curr_addr:
|
if curr_addr:
|
||||||
as_name = ""
|
as_name = ""
|
||||||
if has_whois and as_lookup:
|
if as_lookup:
|
||||||
ASN = whoisrecord(curr_addr)
|
ASN = whoisrecord(curr_addr)
|
||||||
as_name = ''
|
as_name = ''
|
||||||
try:
|
try:
|
||||||
@ -379,6 +369,5 @@ if __name__ == '__main__':
|
|||||||
try:
|
try:
|
||||||
main()
|
main()
|
||||||
finally:
|
finally:
|
||||||
if has_whois:
|
|
||||||
pkl_file = open(WHOIS_CACHE, 'wb')
|
pkl_file = open(WHOIS_CACHE, 'wb')
|
||||||
pickle.dump(whois, pkl_file)
|
pickle.dump(whois, pkl_file)
|
||||||
|
2
setup.py
2
setup.py
@ -1,7 +1,7 @@
|
|||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
setup(
|
setup(
|
||||||
name = "dnsdiag",
|
name = "dnsdiag",
|
||||||
version = "1.3.1",
|
version = "1.3.2",
|
||||||
packages = find_packages(),
|
packages = find_packages(),
|
||||||
scripts = ['dnsping.py', 'dnstraceroute.py', 'dnseval.py'],
|
scripts = ['dnsping.py', 'dnstraceroute.py', 'dnseval.py'],
|
||||||
classifiers=[
|
classifiers=[
|
||||||
|
Loading…
x
Reference in New Issue
Block a user