From 32af66881465ae98a53665c8ddd42c02aaf492f7 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 2 Mar 2014 22:15:53 +1300 Subject: [PATCH] Minor cleanups. --- libmproxy/protocol/__init__.py | 5 +++-- libmproxy/protocol/tcp.py | 13 ++++++------- libmproxy/proxy.py | 2 -- setup.py | 2 +- test/test_server.py | 3 --- test/tservers.py | 4 +++- 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/libmproxy/protocol/__init__.py b/libmproxy/protocol/__init__.py index 580d693c5..2c2e72859 100644 --- a/libmproxy/protocol/__init__.py +++ b/libmproxy/protocol/__init__.py @@ -35,7 +35,6 @@ class TemporaryServerChangeMixin(object): This mixin allows safe modification of the target server, without any need to expose the ConnectionHandler to the Flow. """ - def change_server(self, address, ssl): if address == self.c.server_conn.address(): return @@ -98,4 +97,6 @@ def handle_messages(conntype, connection_handler): def handle_error(conntype, connection_handler, error): - return _handler(conntype, connection_handler).handle_error(error) \ No newline at end of file + return _handler(conntype, connection_handler).handle_error(error) + + diff --git a/libmproxy/protocol/tcp.py b/libmproxy/protocol/tcp.py index df7e6692f..1591eb042 100644 --- a/libmproxy/protocol/tcp.py +++ b/libmproxy/protocol/tcp.py @@ -32,12 +32,11 @@ class TCPHandler(ProtocolHandler): if d == "": # connection closed break data.write(d) - - """ - OpenSSL Connections have an internal buffer that might contain data altough everything is read - from the socket. Thankfully, connection.pending() returns the amount of bytes in this buffer, - so we can read it completely at once. - """ + # OpenSSL Connections have an internal buffer that might + # contain data altough everything is read from the socket. + # Thankfully, connection.pending() returns the amount of + # bytes in this buffer, so we can read it completely at + # once. if src.ssl_established: data.write(rfile.read(src.connection.pending())) else: # no data left, but not closed yet @@ -57,4 +56,4 @@ class TCPHandler(ProtocolHandler): self.c.log("%s %s\r\n%s" % (direction, dst_str,data)) dst.wfile.write(data) - dst.wfile.flush() \ No newline at end of file + dst.wfile.flush() diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index b787386a3..b0fb94495 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -387,7 +387,6 @@ class ConnectionHandler: if self.client_conn.ssl_established: raise ProxyError(502, "SSL to Client already established.") dummycert = self.find_cert() - print self.config.ciphers self.client_conn.convert_to_ssl( dummycert, self.config.keyfile or self.config.cacert, @@ -469,7 +468,6 @@ class ProxyServerError(Exception): class ProxyServer(tcp.TCPServer): allow_reuse_address = True bound = True - def __init__(self, config, port, host='', server_version=version.NAMEVERSION): """ Raises ProxyServerError if there's a startup problem. diff --git a/setup.py b/setup.py index d8e256600..624a1a609 100644 --- a/setup.py +++ b/setup.py @@ -102,7 +102,7 @@ setup( "netlib>=%s"%version.VERSION, "urwid>=1.1", "pyasn1>0.1.2", - "pyopenssl>=0.13", + "pyopenssl>=0.14", "Pillow>=2.3.0", "lxml", "flask" diff --git a/test/test_server.py b/test/test_server.py index e31fb589a..2714ef52a 100644 --- a/test/test_server.py +++ b/test/test_server.py @@ -377,7 +377,6 @@ class TestTransparentResolveError(tservers.TransparentProxTest): assert self.pathod("304").status_code == 502 - class MasterIncomplete(tservers.TestMaster): def handle_request(self, m): resp = tutils.tresp() @@ -390,5 +389,3 @@ class TestIncompleteResponse(tservers.HTTPProxTest): def test_incomplete(self): assert self.pathod("200").status_code == 502 - - diff --git a/test/tservers.py b/test/tservers.py index a0f37c985..540cda605 100644 --- a/test/tservers.py +++ b/test/tservers.py @@ -28,7 +28,6 @@ class TestMaster(flow.FlowMaster): self.apps.add(testapp, "testapp", 80) self.apps.add(errapp, "errapp", 80) self.clear_log() - self.start_app(APP_HOST, APP_PORT, False) def handle_request(self, m): flow.FlowMaster.handle_request(self, m) @@ -77,6 +76,7 @@ class ProxTestBase(object): no_upstream_cert = False authenticator = None masterclass = TestMaster + externalapp = False @classmethod def setupAll(cls): cls.server = libpathod.test.Daemon(ssl=cls.ssl, ssloptions=cls.ssloptions) @@ -89,6 +89,7 @@ class ProxTestBase(object): **pconf ) tmaster = cls.masterclass(config) + tmaster.start_app(APP_HOST, APP_PORT, cls.externalapp) cls.proxy = ProxyThread(tmaster) cls.proxy.start() @@ -266,6 +267,7 @@ class ChainProxTest(ProxTestBase): cls.chain[-1].port ) tmaster = cls.masterclass(config) + tmaster.start_app(APP_HOST, APP_PORT, cls.externalapp) cls.chain.append(ProxyThread(tmaster)) cls.chain[-1].start()