diff --git a/output/IOutput.py b/output/IOutput.py index 84b2601..d3dd3a1 100644 --- a/output/IOutput.py +++ b/output/IOutput.py @@ -43,6 +43,9 @@ class IOutput(): def other_output(self, message_type: str, message_raw: bytes): ... + def debug_output(self, message_type: str, message_raw: str): + ... + def error_output(self, message_type: str, message_raw: bytes, exception: Exception): ... diff --git a/output/manager.py b/output/manager.py index 79519c7..40a5c4c 100644 --- a/output/manager.py +++ b/output/manager.py @@ -122,7 +122,8 @@ class OutputManager(): self.decode_payload(message) def terminate(self): - self._should_exit.set() + if self._should_exit: + self._should_exit.set() MESSAGE_QUEUE.put(None) for writer in self._writer: diff --git a/proxy/manager.py b/proxy/manager.py index 41d2617..d8f4b3a 100644 --- a/proxy/manager.py +++ b/proxy/manager.py @@ -18,6 +18,7 @@ _manager: "Optional[ProxyManager]" = None class ProxyManager: def __init__(self): self._mitm_instance = None + self._loop: "Optional[asyncio.AbstractEventLoop]" = None opts = Options( listen_host=config()['mitm']['host'], listen_port=config()['mitm']['port'], @@ -34,6 +35,9 @@ class ProxyManager: self.terminate() def terminate(self): + if self._loop: + if self._loop.is_running(): + self._loop.stop() if self._mitm_instance: self._mitm_instance.shutdown() @@ -42,6 +46,7 @@ class ProxyManager: def _start(self): loop = asyncio.new_event_loop() + self._loop = loop asyncio.set_event_loop(loop) self._mitm_instance.run()