avoid DNS lookup of IP addresses
authorRichard Penman
Fri, 21 Mar 2014 12:09:00 -0400
changeset 25 f3c0a9a442aa
parent 24 16f17c400a70
child 26 e0b929723473
avoid DNS lookup of IP addresses
whois/__init__.py
--- a/whois/__init__.py	Wed Mar 05 15:41:49 2014 -0500
+++ b/whois/__init__.py	Fri Mar 21 12:09:00 2014 -0400
@@ -8,7 +8,11 @@
 
 def whois(url):
     # clean domain to expose netloc
-    domain = extract_domain(url)
+    ip_match = re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$", url)
+    if ip_match:
+        domain = url
+    else:
+        domain = extract_domain(url)
     try:
         # try native whois command first
         r = subprocess.Popen(['whois', domain], stdout=subprocess.PIPE)