aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/tcp.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2014-09-07 12:47:49 +1200
committerAldo Cortesi <aldo@corte.si>2014-09-07 12:47:49 +1200
commit754b62793702ab1f9197f2fad1f52d3758667d72 (patch)
tree24efb6d22a7cc35bcbdac844631e941bfcefe155 /netlib/tcp.py
parentf4013dcd406c731c08c02789f80ccb364844c0ff (diff)
parentf98989b075fb2669f342a51389fa5db1bc21a059 (diff)
downloadmitmproxy-754b62793702ab1f9197f2fad1f52d3758667d72.tar.gz
mitmproxy-754b62793702ab1f9197f2fad1f52d3758667d72.tar.bz2
mitmproxy-754b62793702ab1f9197f2fad1f52d3758667d72.zip
Merge pull request #48 from mitmproxy/mitmproxy_issue_341
Adjust netlib to mitmproxy changes
Diffstat (limited to 'netlib/tcp.py')
-rw-r--r--netlib/tcp.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/netlib/tcp.py b/netlib/tcp.py
index a5b9af22..2704eeae 100644
--- a/netlib/tcp.py
+++ b/netlib/tcp.py
@@ -216,10 +216,16 @@ class Address(object):
def use_ipv6(self, b):
self.family = socket.AF_INET6 if b else socket.AF_INET
+ def __repr__(self):
+ return repr(self.address)
+
def __eq__(self, other):
other = Address.wrap(other)
return (self.address, self.family) == (other.address, other.family)
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
class _Connection(object):
def get_current_cipher(self):
@@ -313,6 +319,8 @@ class TCPClient(_Connection):
if self.source_address:
connection.bind(self.source_address())
connection.connect(self.address())
+ if not self.source_address:
+ self.source_address = Address(connection.getsockname())
self.rfile = Reader(connection.makefile('rb', self.rbufsize))
self.wfile = Writer(connection.makefile('wb', self.wbufsize))
except (socket.error, IOError), err: