From c02fdb24639c8c0fe89534205d48933de832287a Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 2 Apr 2012 13:24:51 +1200 Subject: Refactor proxy.Server to fix a crash when replaying with -n --- libmproxy/proxy.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'libmproxy/proxy.py') diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index 33e50890..c6a68ba3 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -478,6 +478,7 @@ ServerBase.daemon_threads = True # Terminate workers when main thread ter class ProxyServer(ServerBase): request_queue_size = 20 allow_reuse_address = True + bound = True def __init__(self, config, port, address=''): """ Raises ProxyServerError if there's a startup problem. @@ -491,6 +492,10 @@ class ProxyServer(ServerBase): self.certdir = tempfile.mkdtemp(prefix="mitmproxy") config.certdir = self.certdir + def start_slave(self, klass, masterq): + slave = klass(masterq, self) + slave.start() + def set_mqueue(self, q): self.masterq = q @@ -505,6 +510,18 @@ class ProxyServer(ServerBase): pass +class DummyServer: + bound = False + def __init__(self, config): + self.config = config + + def start_slave(self, klass, masterq): + pass + + def shutdown(self): + pass + + # Command-line utils def certificate_option_group(parser): group = optparse.OptionGroup(parser, "SSL") -- cgit v1.2.3