mirror of
https://github.com/mitmproxy/mitmproxy.git
synced 2024-11-23 21:30:04 +00:00
improve logging
This commit is contained in:
parent
2b2d21aff0
commit
5a2a5760d0
@ -990,24 +990,36 @@ class HTTPHandler(ProtocolHandler):
|
||||
def handle_error(self, error, flow=None):
|
||||
|
||||
message = repr(error)
|
||||
if "tlsv1 alert unknown ca" in message:
|
||||
message += " The client does not trust the proxy's certificate."
|
||||
message_debug = None
|
||||
|
||||
if isinstance(error, tcp.NetLibDisconnect):
|
||||
self.c.log("TCP connection closed unexpectedly.", "debug")
|
||||
else:
|
||||
self.c.log("error: %s" % message, level="info")
|
||||
message = None
|
||||
message_debug = "TCP connection closed unexpectedly."
|
||||
elif "tlsv1 alert unknown ca" in message:
|
||||
message = "TLSv1 Alert Unknown CA: The client does not trust the proxy's certificate."
|
||||
elif "handshake error" in message:
|
||||
message_debug = message
|
||||
message = "SSL handshake error: The client may not trust the proxy's certificate."
|
||||
|
||||
if message:
|
||||
self.c.log(message, level="info")
|
||||
if message_debug:
|
||||
self.c.log(message, level="debug")
|
||||
|
||||
if flow:
|
||||
# TODO: no flows without request or with both request and response at the moment.
|
||||
if flow.request and not flow.response:
|
||||
flow.error = Error(message)
|
||||
flow.error = Error(message or message_debug)
|
||||
self.c.channel.ask("error", flow)
|
||||
|
||||
try:
|
||||
code = getattr(error, "code", 502)
|
||||
headers = getattr(error, "headers", None)
|
||||
self.send_error(code, message, headers)
|
||||
|
||||
html_message = message or ""
|
||||
if message_debug:
|
||||
html_message += "<pre>%s</pre>" % message_debug
|
||||
self.send_error(code, html_message, headers)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user