From f4272de5ec77fb57723e2274e4ddc50d73489e1e Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Thu, 3 Sep 2015 17:01:25 +0200 Subject: remove ServerConnectionMixin.reconnect --- libmproxy/proxy/server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libmproxy/proxy/server.py') diff --git a/libmproxy/proxy/server.py b/libmproxy/proxy/server.py index e9e8df09..5d067b45 100644 --- a/libmproxy/proxy/server.py +++ b/libmproxy/proxy/server.py @@ -8,10 +8,10 @@ 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 ..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: -- cgit v1.2.3 From d002371d30e4b0ab7d1d23023236a9446d4c2396 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 7 Sep 2015 13:51:46 +0200 Subject: expose `next_layer` to inline scripts --- libmproxy/proxy/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libmproxy/proxy/server.py') diff --git a/libmproxy/proxy/server.py b/libmproxy/proxy/server.py index 5d067b45..c12bbbfa 100644 --- a/libmproxy/proxy/server.py +++ b/libmproxy/proxy/server.py @@ -137,4 +137,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)) -- cgit v1.2.3 From 30f0ee40c51fc6bc911169f044677e235087161e Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Fri, 11 Sep 2015 00:49:37 +0200 Subject: nicer error messages --- libmproxy/proxy/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libmproxy/proxy/server.py') diff --git a/libmproxy/proxy/server.py b/libmproxy/proxy/server.py index c12bbbfa..91a12df9 100644 --- a/libmproxy/proxy/server.py +++ b/libmproxy/proxy/server.py @@ -116,7 +116,7 @@ class ConnectionHandler(object): except Kill: self.log("Connection killed", "info") except ProtocolException as e: - self.log(e, "info") + self.log(repr(e), "info") # If an error propagates to the topmost level, # we send an HTTP error response, which is both # understandable by HTTP clients and humans. -- cgit v1.2.3 From ffdf143be42490f05cb2b69cdb83e74264d6070a Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Fri, 11 Sep 2015 01:39:33 +0200 Subject: better exception handling --- libmproxy/proxy/server.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'libmproxy/proxy/server.py') diff --git a/libmproxy/proxy/server.py b/libmproxy/proxy/server.py index 91a12df9..c00bb815 100644 --- a/libmproxy/proxy/server.py +++ b/libmproxy/proxy/server.py @@ -3,6 +3,7 @@ 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 @@ -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), e), + sys.exc_info()[2] + ) self.channel = None def start_slave(self, klass, channel): @@ -117,6 +122,7 @@ class ConnectionHandler(object): self.log("Connection killed", "info") except ProtocolException as e: self.log(repr(e), "info") + 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. -- cgit v1.2.3 From dd414e485212e3cab612a66d5d858c1a766ace04 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Fri, 11 Sep 2015 02:17:04 +0200 Subject: better error messages, remove error cause --- libmproxy/proxy/server.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'libmproxy/proxy/server.py') diff --git a/libmproxy/proxy/server.py b/libmproxy/proxy/server.py index c00bb815..88448172 100644 --- a/libmproxy/proxy/server.py +++ b/libmproxy/proxy/server.py @@ -8,7 +8,7 @@ import six from netlib import tcp from netlib.http.http1 import HTTP1Protocol from netlib.tcp import NetLibError -from ..exceptions import ProtocolException, ServerException +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 @@ -42,7 +42,7 @@ class ProxyServer(tcp.TCPServer): except socket.error as e: six.reraise( ServerException, - ServerException('Error starting proxy server: ' + repr(e), e), + ServerException('Error starting proxy server: ' + repr(e)), sys.exc_info()[2] ) self.channel = None @@ -121,8 +121,18 @@ class ConnectionHandler(object): except Kill: self.log("Connection killed", "info") except ProtocolException as e: - self.log(repr(e), "info") - self.log(traceback.format_exc(), "debug") + + 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. -- cgit v1.2.3