# HG changeset patch # User r32rtb # Date 1525783648 14400 # Node ID 7030835bcf5e102284d0f230081e50cb90ee04ab # Parent 1bd3f3f7fe2ac7eab96fad5f3d1022a37768d521 Support for SOCKS5 proxy added user: r32rtb branch 'socks_proxy' changed README.rst changed whois/whois.py diff -r 1bd3f3f7fe2a -r 7030835bcf5e README.rst --- 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? ========= diff -r 1bd3f3f7fe2a -r 7030835bcf5e whois/whois.py --- 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))