From fe77dd35c67a0dfbd3004fefe97c689f8cfd3291 Mon Sep 17 00:00:00 2001 From: Sandor Nemes Date: Fri, 8 Jan 2016 15:46:59 +0100 Subject: Fixed a problem with the bind address not being used as the source address on outgoing TCP packets --- libmproxy/proxy/modes/http_proxy.py | 1 + libmproxy/proxy/modes/reverse_proxy.py | 1 + libmproxy/proxy/modes/socks_proxy.py | 4 ++++ libmproxy/proxy/modes/transparent_proxy.py | 1 + 4 files changed, 7 insertions(+) (limited to 'libmproxy/proxy') diff --git a/libmproxy/proxy/modes/http_proxy.py b/libmproxy/proxy/modes/http_proxy.py index c7502c24..27da57dd 100644 --- a/libmproxy/proxy/modes/http_proxy.py +++ b/libmproxy/proxy/modes/http_proxy.py @@ -16,6 +16,7 @@ class HttpProxy(Layer, ServerConnectionMixin): class HttpUpstreamProxy(Layer, ServerConnectionMixin): def __init__(self, ctx, server_address): super(HttpUpstreamProxy, self).__init__(ctx, server_address=server_address) + self.server_conn.source_address = (ctx.config.host, 0) def __call__(self): layer = self.ctx.next_layer(self) diff --git a/libmproxy/proxy/modes/reverse_proxy.py b/libmproxy/proxy/modes/reverse_proxy.py index 28f4e6f8..3ff22b6c 100644 --- a/libmproxy/proxy/modes/reverse_proxy.py +++ b/libmproxy/proxy/modes/reverse_proxy.py @@ -6,6 +6,7 @@ from ...protocol import Layer, ServerConnectionMixin class ReverseProxy(Layer, ServerConnectionMixin): def __init__(self, ctx, server_address, server_tls): super(ReverseProxy, self).__init__(ctx, server_address=server_address) + self.server_conn.source_address = (ctx.config.host, 0) self.server_tls = server_tls def __call__(self): diff --git a/libmproxy/proxy/modes/socks_proxy.py b/libmproxy/proxy/modes/socks_proxy.py index 264c734a..6e0b927b 100644 --- a/libmproxy/proxy/modes/socks_proxy.py +++ b/libmproxy/proxy/modes/socks_proxy.py @@ -8,6 +8,10 @@ from ...protocol import Layer, ServerConnectionMixin class Socks5Proxy(Layer, ServerConnectionMixin): + def __init__(self, ctx): + super(Socks5Proxy, self).__init__(ctx) + self.server_conn.source_address = (ctx.config.host, 0) + def __call__(self): try: # Parse Client Greeting diff --git a/libmproxy/proxy/modes/transparent_proxy.py b/libmproxy/proxy/modes/transparent_proxy.py index da1d4632..995e4bd9 100644 --- a/libmproxy/proxy/modes/transparent_proxy.py +++ b/libmproxy/proxy/modes/transparent_proxy.py @@ -8,6 +8,7 @@ from ...protocol import Layer, ServerConnectionMixin class TransparentProxy(Layer, ServerConnectionMixin): def __init__(self, ctx): super(TransparentProxy, self).__init__(ctx) + self.server_conn.source_address = (ctx.config.host, 0) self.resolver = platform.resolver() def __call__(self): -- cgit v1.2.3