diff options
author | Maximilian Hils <git@maximilianhils.com> | 2015-09-11 12:13:39 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2015-09-11 12:13:39 +0200 |
commit | 7c186a4edbb0c6bc1f471d0db62dfc60008160a2 (patch) | |
tree | 89fb7e5b14cdfe9a0b61da828ddac8f355a3cdd0 /libmproxy/proxy/server.py | |
parent | b62498e125191beca3b49841eb5f1fb9a93a868a (diff) | |
parent | dd414e485212e3cab612a66d5d858c1a766ace04 (diff) | |
download | mitmproxy-7c186a4edbb0c6bc1f471d0db62dfc60008160a2.tar.gz mitmproxy-7c186a4edbb0c6bc1f471d0db62dfc60008160a2.tar.bz2 mitmproxy-7c186a4edbb0c6bc1f471d0db62dfc60008160a2.zip |
Merge branch 'master' into contentviews
Diffstat (limited to 'libmproxy/proxy/server.py')
-rw-r--r-- | libmproxy/proxy/server.py | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/libmproxy/proxy/server.py b/libmproxy/proxy/server.py index e9e8df09..88448172 100644 --- a/libmproxy/proxy/server.py +++ b/libmproxy/proxy/server.py @@ -3,15 +3,16 @@ from __future__ import (absolute_import, print_function, division) import traceback import sys import socket +import six from netlib import tcp from netlib.http.http1 import HTTP1Protocol from netlib.tcp import NetLibError -from ..exceptions import ProtocolException, ServerException -from ..protocol import Log, Kill +from ..exceptions import ProtocolException, ServerException, ClientHandshakeException +from ..protocol import Kill from ..models import ClientConnection, make_error_response from .modes import HttpUpstreamProxy, HttpProxy, ReverseProxy, TransparentProxy, Socks5Proxy -from .root_context import RootContext +from .root_context import RootContext, Log class DummyServer: @@ -39,7 +40,11 @@ class ProxyServer(tcp.TCPServer): try: super(ProxyServer, self).__init__((config.host, config.port)) except socket.error as e: - raise ServerException('Error starting proxy server: ' + repr(e), e) + six.reraise( + ServerException, + ServerException('Error starting proxy server: ' + repr(e)), + sys.exc_info()[2] + ) self.channel = None def start_slave(self, klass, channel): @@ -116,7 +121,18 @@ class ConnectionHandler(object): except Kill: self.log("Connection killed", "info") except ProtocolException as e: - self.log(e, "info") + + if isinstance(e, ClientHandshakeException): + self.log( + "Client Handshake failed. " + "The client may not trust the proxy's certificate for {}.".format(e.server), + "error" + ) + self.log(repr(e), "debug") + else: + self.log(repr(e), "error") + + self.log(traceback.format_exc(), "debug") # If an error propagates to the topmost level, # we send an HTTP error response, which is both # understandable by HTTP clients and humans. @@ -137,4 +153,4 @@ class ConnectionHandler(object): def log(self, msg, level): msg = "{}: {}".format(repr(self.client_conn.address), msg) - self.channel.tell("log", Log(msg, level))
\ No newline at end of file + self.channel.tell("log", Log(msg, level)) |