aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libmproxy/models/connections.py4
-rw-r--r--libmproxy/protocol/base.py5
-rw-r--r--libmproxy/protocol/http_replay.py4
-rw-r--r--libmproxy/proxy/modes/socks_proxy.py3
4 files changed, 10 insertions, 6 deletions
diff --git a/libmproxy/models/connections.py b/libmproxy/models/connections.py
index 0991955d..f5dabe4e 100644
--- a/libmproxy/models/connections.py
+++ b/libmproxy/models/connections.py
@@ -88,8 +88,8 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
class ServerConnection(tcp.TCPClient, stateobject.StateObject):
- def __init__(self, address):
- tcp.TCPClient.__init__(self, address)
+ def __init__(self, address, source_address=None):
+ tcp.TCPClient.__init__(self, address, source_address)
self.via = None
self.timestamp_start = None
diff --git a/libmproxy/protocol/base.py b/libmproxy/protocol/base.py
index af6b1c3b..d984cadb 100644
--- a/libmproxy/protocol/base.py
+++ b/libmproxy/protocol/base.py
@@ -111,7 +111,7 @@ class ServerConnectionMixin(object):
def __init__(self, server_address=None):
super(ServerConnectionMixin, self).__init__()
- self.server_conn = ServerConnection(server_address)
+ self.server_conn = ServerConnection(server_address, (self.config.host, 0))
self.__check_self_connect()
def __check_self_connect(self):
@@ -157,10 +157,11 @@ class ServerConnectionMixin(object):
"""
self.log("serverdisconnect", "debug", [repr(self.server_conn.address)])
address = self.server_conn.address
+ source_address = self.server_conn.source_address
self.server_conn.finish()
self.server_conn.close()
self.channel.tell("serverdisconnect", self.server_conn)
- self.server_conn = ServerConnection(address)
+ self.server_conn = ServerConnection(address, source_address)
def connect(self):
"""
diff --git a/libmproxy/protocol/http_replay.py b/libmproxy/protocol/http_replay.py
index b7faad07..63870dfb 100644
--- a/libmproxy/protocol/http_replay.py
+++ b/libmproxy/protocol/http_replay.py
@@ -46,7 +46,7 @@ class RequestReplayThread(threading.Thread):
# In all modes, we directly connect to the server displayed
if self.config.mode == "upstream":
server_address = self.config.upstream_server.address
- server = ServerConnection(server_address)
+ server = ServerConnection(server_address, (self.config.host, 0))
server.connect()
if r.scheme == "https":
connect_request = make_connect_request((r.host, r.port))
@@ -68,7 +68,7 @@ class RequestReplayThread(threading.Thread):
r.form_out = "absolute"
else:
server_address = (r.host, r.port)
- server = ServerConnection(server_address)
+ server = ServerConnection(server_address, (self.config.host, 0))
server.connect()
if r.scheme == "https":
server.establish_ssl(
diff --git a/libmproxy/proxy/modes/socks_proxy.py b/libmproxy/proxy/modes/socks_proxy.py
index 264c734a..90788e37 100644
--- a/libmproxy/proxy/modes/socks_proxy.py
+++ b/libmproxy/proxy/modes/socks_proxy.py
@@ -8,6 +8,9 @@ from ...protocol import Layer, ServerConnectionMixin
class Socks5Proxy(Layer, ServerConnectionMixin):
+ def __init__(self, ctx):
+ super(Socks5Proxy, self).__init__(ctx)
+
def __call__(self):
try:
# Parse Client Greeting