diff options
| author | Maximilian Hils <git@maximilianhils.com> | 2016-01-18 16:07:02 +0100 | 
|---|---|---|
| committer | Maximilian Hils <git@maximilianhils.com> | 2016-01-18 16:07:02 +0100 | 
| commit | 4024721c7b1762325d90146044f2fdc01d07caa0 (patch) | |
| tree | 3180434c7af8e7e6c7b398dd08805e6ff0a319b7 /libmproxy | |
| parent | 7eb9bf818c6ab0b4fa341d741ead0a4199805473 (diff) | |
| parent | cb3107fd0eb119ec88265c842f457845fe2a0b4a (diff) | |
| download | mitmproxy-4024721c7b1762325d90146044f2fdc01d07caa0.tar.gz mitmproxy-4024721c7b1762325d90146044f2fdc01d07caa0.tar.bz2 mitmproxy-4024721c7b1762325d90146044f2fdc01d07caa0.zip | |
Merge pull request #879 from snemes/master
Fixed a problem with the bind address not being used as the source address on outgoing TCP packets
Diffstat (limited to 'libmproxy')
| -rw-r--r-- | libmproxy/models/connections.py | 4 | ||||
| -rw-r--r-- | libmproxy/protocol/base.py | 5 | ||||
| -rw-r--r-- | libmproxy/protocol/http_replay.py | 4 | ||||
| -rw-r--r-- | libmproxy/proxy/modes/socks_proxy.py | 3 | 
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 | 
