diff options
author | smill <smill@cuckoo.sh> | 2016-09-05 10:49:39 +0000 |
---|---|---|
committer | smill <smill@cuckoo.sh> | 2016-09-05 10:49:39 +0000 |
commit | 2ecd89fc51676a98c25a80857584923aae9248a1 (patch) | |
tree | 377bf4b51642fb112d07ec18604eb9e80501462c /netlib/tcp.py | |
parent | e278ce6455b63eb9da61f0e92d7f25cbdf881d8b (diff) | |
download | mitmproxy-2ecd89fc51676a98c25a80857584923aae9248a1.tar.gz mitmproxy-2ecd89fc51676a98c25a80857584923aae9248a1.tar.bz2 mitmproxy-2ecd89fc51676a98c25a80857584923aae9248a1.zip |
Made it possible to modify the server_conn.connection attribute,
using the serverconnect stub.
Diffstat (limited to 'netlib/tcp.py')
-rw-r--r-- | netlib/tcp.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/netlib/tcp.py b/netlib/tcp.py index 1fd0164f..c3b8a407 100644 --- a/netlib/tcp.py +++ b/netlib/tcp.py @@ -729,10 +729,15 @@ class TCPClient(_Connection): def connect(self): try: - connection = socket.socket(self.address.family, socket.SOCK_STREAM) + if not self.connection: + connection = socket.socket(self.address.family, socket.SOCK_STREAM) + else: + connection = self.connection + if self.spoof_source_address: try: - connection.setsockopt(socket.SOL_IP, 19, 1) + if not connection.getsockopt(socket.SOL_IP, 19): + connection.setsockopt(socket.SOL_IP, 19, 1) except socket.error as e: raise exceptions.ProtocolException( "Failed to spoof the source address: " + e.strerror) |