mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +00:00
Catch and log SSL connection errors. Improve log format.
This commit is contained in:
parent
f32258e8f7
commit
15aab74ddb
@ -13,10 +13,14 @@ class PathodHandler(tcp.BaseHandler):
|
|||||||
|
|
||||||
def handle(self):
|
def handle(self):
|
||||||
if self.server.ssloptions:
|
if self.server.ssloptions:
|
||||||
self.convert_to_ssl(
|
try:
|
||||||
self.server.ssloptions["certfile"],
|
self.convert_to_ssl(
|
||||||
self.server.ssloptions["keyfile"],
|
self.server.ssloptions["certfile"],
|
||||||
)
|
self.server.ssloptions["keyfile"],
|
||||||
|
)
|
||||||
|
except tcp.NetLibError, v:
|
||||||
|
logging.debug("%s: %s"%(self.client_address, str(v)))
|
||||||
|
self.finish()
|
||||||
|
|
||||||
while not self.finished:
|
while not self.finished:
|
||||||
line = self.rfile.readline()
|
line = self.rfile.readline()
|
||||||
@ -47,21 +51,21 @@ class PathodHandler(tcp.BaseHandler):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if crafted:
|
if crafted:
|
||||||
ret = crafted.serve(self.wfile)
|
response_log = crafted.serve(self.wfile)
|
||||||
if ret["disconnect"]:
|
if response_log["disconnect"]:
|
||||||
self.finish()
|
self.finish()
|
||||||
ret["request"] = dict(
|
request_log = dict(
|
||||||
path = path,
|
path = path,
|
||||||
method = method,
|
method = method,
|
||||||
headers = headers.lst,
|
headers = headers.lst,
|
||||||
sni = self.sni,
|
sni = self.sni,
|
||||||
#remote_address = self.request.connection.address,
|
remote_address = self.client_address,
|
||||||
#full_url = self.request.full_url(),
|
#full_url = self.request.full_url(),
|
||||||
#query = self.request.query,
|
#query = self.request.query,
|
||||||
httpversion = httpversion,
|
httpversion = httpversion,
|
||||||
#uri = self.request.uri,
|
#uri = self.request.uri,
|
||||||
)
|
)
|
||||||
self.server.add_log(ret)
|
self.server.add_log(dict(request=request_log, response=response_log))
|
||||||
else:
|
else:
|
||||||
cc = wsgi.ClientConn(self.client_address)
|
cc = wsgi.ClientConn(self.client_address)
|
||||||
req = wsgi.Request(cc, "http", method, path, headers, content)
|
req = wsgi.Request(cc, "http", method, path, headers, content)
|
||||||
@ -73,6 +77,11 @@ class PathodHandler(tcp.BaseHandler):
|
|||||||
version.NAMEVERSION
|
version.NAMEVERSION
|
||||||
)
|
)
|
||||||
app.serve(req, self.wfile)
|
app.serve(req, self.wfile)
|
||||||
|
# FIXME: Tear down the connection. We have some problem with
|
||||||
|
# connection termination that causes some clients (e.g. Chrome)
|
||||||
|
# to hang. It appears to be related to responses that have no
|
||||||
|
# Content-Length header.
|
||||||
|
self.finish()
|
||||||
|
|
||||||
|
|
||||||
class Pathod(tcp.TCPServer):
|
class Pathod(tcp.TCPServer):
|
||||||
|
Loading…
Reference in New Issue
Block a user