aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Urlichs <matthias@urlichs.de>2013-12-12 07:54:13 +0100
committerMatthias Urlichs <matthias@urlichs.de>2013-12-12 07:56:40 +0100
commit7b6057fa64af6cd6becd1ce6b55a2c10f6bb3c85 (patch)
tree0ae22dbf300c2297f514fc952ae221246738736e
parent39ffe103349439d8e8eef26b81de6e5156e526d9 (diff)
downloadmitmproxy-7b6057fa64af6cd6becd1ce6b55a2c10f6bb3c85.tar.gz
mitmproxy-7b6057fa64af6cd6becd1ce6b55a2c10f6bb3c85.tar.bz2
mitmproxy-7b6057fa64af6cd6becd1ce6b55a2c10f6bb3c85.zip
serverconnect hook: Set sc.request
The serverconnect hook script might need to examine the incoming request in order to set up the server connection. Example use: bind to a distinct source IPv6 address for each client.
-rw-r--r--libmproxy/proxy.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py
index 73b7f0a3..1d238697 100644
--- a/libmproxy/proxy.py
+++ b/libmproxy/proxy.py
@@ -133,7 +133,7 @@ class ProxyHandler(tcp.BaseHandler):
self.server_conn = None
tcp.BaseHandler.__init__(self, connection, client_address, server)
- def get_server_connection(self, cc, scheme, host, port, sni):
+ def get_server_connection(self, cc, scheme, host, port, sni, request=None):
"""
When SNI is in play, this means we have an SSL-encrypted
connection, which means that the entire handler is dedicated to a
@@ -159,6 +159,7 @@ class ProxyHandler(tcp.BaseHandler):
if not self.server_conn:
try:
self.server_conn = ServerConnection(self.config, scheme, host, port, sni)
+ self.server_conn.request = request # the hook might need it
self.channel.ask(self.server_conn)
self.server_conn.connect()
except tcp.NetLibError, v:
@@ -223,7 +224,7 @@ class ProxyHandler(tcp.BaseHandler):
# the case, we want to reconnect without sending an error
# to the client.
while 1:
- sc = self.get_server_connection(cc, scheme, host, port, self.sni)
+ sc = self.get_server_connection(cc, scheme, host, port, self.sni, request=request)
sc.send(request)
if sc.requestcount == 1: # add timestamps only for first request (others are not directly affected)
request.tcp_setup_timestamp = sc.tcp_setup_timestamp