add serverconnect script hook

This commit is contained in:
Maximilian Hils 2013-11-18 17:25:52 +01:00
parent 38a1135ab8
commit 675518f873
2 changed files with 8 additions and 0 deletions

View File

@ -1580,6 +1580,13 @@ class FlowMaster(controller.Master):
self.run_script_hook("clientdisconnect", r) self.run_script_hook("clientdisconnect", r)
r.reply() r.reply()
def handle_serverconnection(self, sc):
# To unify the mitmproxy script API, we call the script hook "serverconnect" rather than "serverconnection".
# As things are handled differently in libmproxy (ClientConnect + ClientDisconnect vs ServerConnection class),
# there is no "serverdisonnect" event at the moment.
self.run_script_hook("serverconnect", sc)
sc.reply()
def handle_error(self, r): def handle_error(self, r):
f = self.state.add_error(r) f = self.state.add_error(r)
if f: if f:

View File

@ -158,6 +158,7 @@ class ProxyHandler(tcp.BaseHandler):
if not self.server_conn: if not self.server_conn:
try: try:
self.server_conn = ServerConnection(self.config, scheme, host, port, sni) self.server_conn = ServerConnection(self.config, scheme, host, port, sni)
self.channel.ask(self.server_conn)
self.server_conn.connect() self.server_conn.connect()
except tcp.NetLibError, v: except tcp.NetLibError, v:
raise ProxyError(502, v) raise ProxyError(502, v)