Minor cleanups.

This commit is contained in:
Aldo Cortesi 2014-03-02 22:15:53 +13:00
parent 875f5f8cb6
commit 32af668814
6 changed files with 13 additions and 16 deletions

View File

@ -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)
return _handler(conntype, connection_handler).handle_error(error)

View File

@ -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()
dst.wfile.flush()

View File

@ -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.

View File

@ -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"

View File

@ -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

View File

@ -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()