From 517e5e66885c79879938d618bfc9da23eba85c0d Mon Sep 17 00:00:00 2001 From: Matthias Urlichs Date: Thu, 12 Dec 2013 09:22:55 +0100 Subject: [PATCH] handle a hook changing connection parameters --- libmproxy/proxy.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index 1d2386974..38356a93f 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -140,11 +140,15 @@ class ProxyHandler(tcp.BaseHandler): single server connection - no multiplexing. If this assumption ever breaks, we'll have to do something different with the SNI host variable on the handler object. + + `conn_info` holds the initial connection's parameters. + The hook might change them. """ sc = self.server_conn if not sni: sni = host - if sc and (scheme, host, port, sni) != (sc.scheme, sc.host, sc.port, sc.sni): + conn_info = (scheme, host, port, sni) + if sc and conn_info != sc.conn_info: sc.terminate() self.server_conn = None self.log( @@ -160,6 +164,7 @@ class ProxyHandler(tcp.BaseHandler): try: self.server_conn = ServerConnection(self.config, scheme, host, port, sni) self.server_conn.request = request # the hook might need it + self.server_conn.conn_info = conn_info self.channel.ask(self.server_conn) self.server_conn.connect() except tcp.NetLibError, v: