diff --git a/README.md b/README.md index d7ff14c..8f1c95b 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ Example use case with the `sockshandler` urllib2 handler. Note that you must imp import socks from sockshandler import SocksiPyHandler - opener = urllib2.build_opener(SocksiPyHandler(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9050)) + opener = urllib2.build_opener(SocksiPyHandler(socks.SOCKS5, "127.0.0.1", 9050)) print opener.open("http://www.somesite.com/") # All requests made by the opener will pass through the SOCKS proxy -------------------------------------------- diff --git a/setup.py b/setup.py index 90719ff..59a3084 100755 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from distutils.core import setup -VERSION = "1.5.4" +VERSION = "1.5.5" setup( name = "PySocks", diff --git a/socks.py b/socks.py index 1cc3ef8..106d9c6 100644 --- a/socks.py +++ b/socks.py @@ -1,6 +1,6 @@ """ SocksiPy - Python SOCKS module. -Version 1.5.4 +Version 1.5.5 Copyright 2006 Dan-Haim. All rights reserved. @@ -52,7 +52,7 @@ -Various small bug fixes """ -__version__ = "1.5.4" +__version__ = "1.5.5" import socket import struct @@ -167,6 +167,8 @@ def create_connection(dest_pair, proxy_type=None, proxy_addr=None, if proxy_type is not None: sock.set_proxy(proxy_type, proxy_addr, proxy_port, proxy_rdns, proxy_username, proxy_password) + if source_address is not None: + sock.bind(source_address) sock.connect(dest_pair) return sock @@ -625,11 +627,11 @@ def connect(self, dest_pair): dest_pair - 2-tuple of (IP/hostname, port). """ - if len(dest_pair) != 2: + if len(dest_pair) != 2 or dest_pair[0].startswith("["): # Probably IPv6, not supported -- raise an error, and hope # Happy Eyeballs (RFC6555) makes sure at least the IPv4 # connection works... - raise socket.error("SocksPy doesn't support IPv6") + raise socket.error("PySocks doesn't support IPv6") dest_addr, dest_port = dest_pair