fix server reconnect

This commit is contained in:
Maximilian Hils 2014-01-31 01:44:55 +01:00
parent 6ce1470631
commit 30a44cbb41
3 changed files with 9 additions and 6 deletions

View File

@ -988,7 +988,7 @@ class HTTPHandler(ProtocolHandler):
self.c.channel.ask("error" if LEGACY else "httperror",
flow.error if LEGACY else flow)
else:
pass # FIXME: Is there any use case for persisting errors that occur outside of flows?
pass # FIXME: Is there any use case for persisting errors that occur outside of flows?
if code:
try:

View File

@ -15,10 +15,12 @@ class TCPHandler(ProtocolHandler):
for rfile in r:
if self.c.client_conn.rfile == rfile:
src, dst = self.c.client_conn, self.c.server_conn
src_str, dst_str = "client", "server"
direction = "-> tcp ->"
dst_str = "%s:%s" % self.c.server_conn.address()[:2]
else:
dst, src = self.c.client_conn, self.c.server_conn
dst_str, src_str = "client", "server"
direction = "<- tcp <-"
dst_str = "client"
data = StringIO()
while range(4096):
@ -52,6 +54,6 @@ class TCPHandler(ProtocolHandler):
self.c.close = True
break
self.c.log("%s -> %s" % (src_str, dst_str), ["\r\n" + data])
self.c.log("%s %s" % (direction, dst_str), ["\r\n" + data])
dst.wfile.write(data)
dst.wfile.flush()

View File

@ -234,6 +234,7 @@ class ConnectionHandler:
try:
protocol.handle_messages(self.conntype, self)
except protocol.ConnectionTypeChange:
self.log("Connection Type Changed: %s" % self.conntype)
continue
# FIXME: Do we want to persist errors?
@ -279,7 +280,7 @@ class ConnectionHandler:
self.server_conn.connect()
except tcp.NetLibError, v:
raise ProxyError(502, v)
self.log("serverconnect", ["%s:%s" % address])
self.log("serverconnect", ["%s:%s" % address[:2]])
self.channel.tell("serverconnect", self)
def establish_ssl(self, client=False, server=False):
@ -307,7 +308,7 @@ class ConnectionHandler:
def server_reconnect(self, no_ssl=False):
had_ssl, sni = self.server_conn.ssl_established, self.sni
self.log("server reconnect (ssl: %s, sni: %s)" % (had_ssl, sni))
self.establish_server_connection(self.server_conn.address)
self.establish_server_connection(self.server_conn.address())
if had_ssl and not no_ssl:
self.sni = sni
self.establish_ssl(server=True)