Support for SOCKS5 proxy added
user: r32rtb
branch 'socks_proxy'
changed README.rst
changed whois/whois.py
--- a/README.rst Mon Apr 23 18:43:05 2018 +0300
+++ b/README.rst Tue May 08 08:47:28 2018 -0400
@@ -72,6 +72,15 @@
OK
+SOCKS Proxy support requirements:
+
+.. sourcecode:: bash
+
+ $ pip install PySocks
+ ............
+ ---------------------------------------------------------------------
+ $ export SOCKS=socksproxy.someplace.com:8080
+
Problems?
=========
--- a/whois/whois.py Mon Apr 23 18:43:05 2018 +0300
+++ b/whois/whois.py Tue May 08 08:47:28 2018 -0400
@@ -38,7 +38,7 @@
import sys
import socket
import optparse
-
+import os
class NICClient(object):
@@ -97,7 +97,18 @@
there for contact details
"""
response = b''
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ if "SOCKS" in os.environ:
+ try:
+ import socks
+ except Exception as e:
+ print(str(e))
+ print("You need to install the Python socks module. Install PIP (https://bootstrap.pypa.io/get-pip.py). Then 'pip install PySocks' ")
+ sys.exit(0)
+ socksproxy,port = os.environ["SOCKS"].split(":")
+ s = socks.socksocket()
+ s.set_proxy(socks.SOCKS5, socksproxy, int(port))
+ else:
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(10)
s.connect((hostname, 43))