From 739b5b0b740631164c6834229a6e050a12abb821 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 17 Nov 2020 17:29:17 +0100 Subject: [PATCH] sans-io compat++ --- mitmproxy/addons/termstatus.py | 2 +- mitmproxy/flow.py | 9 +++++---- test/mitmproxy/addons/test_termstatus.py | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/mitmproxy/addons/termstatus.py b/mitmproxy/addons/termstatus.py index c3c912838..da436d01d 100644 --- a/mitmproxy/addons/termstatus.py +++ b/mitmproxy/addons/termstatus.py @@ -9,7 +9,7 @@ from mitmproxy.utils import human class TermStatus: def running(self): - if ctx.options.server: + if ctx.master.server.bound: ctx.log.info( "Proxy server listening at http://{}".format( human.format_address(ctx.master.server.address) diff --git a/mitmproxy/flow.py b/mitmproxy/flow.py index 21ce0eac3..b58fc0e4d 100644 --- a/mitmproxy/flow.py +++ b/mitmproxy/flow.py @@ -6,6 +6,7 @@ from mitmproxy import connections from mitmproxy import controller, exceptions # noqa from mitmproxy import stateobject from mitmproxy import version +from mitmproxy.utils import compat class Error(stateobject.StateObject): @@ -63,8 +64,8 @@ class Flow(stateobject.StateObject): def __init__( self, type: str, - client_conn: connections.ClientConnection, - server_conn: connections.ServerConnection, + client_conn: compat.Client, + server_conn: compat.Server, live: bool=None ) -> None: self.type = type @@ -84,8 +85,8 @@ class Flow(stateobject.StateObject): _stateobject_attributes = dict( id=str, error=Error, - client_conn=connections.ClientConnection, - server_conn=connections.ServerConnection, + client_conn=compat.Client, + server_conn=compat.Server, type=str, intercepted=bool, is_replay=str, diff --git a/test/mitmproxy/addons/test_termstatus.py b/test/mitmproxy/addons/test_termstatus.py index c48021022..96221e4b3 100644 --- a/test/mitmproxy/addons/test_termstatus.py +++ b/test/mitmproxy/addons/test_termstatus.py @@ -10,6 +10,7 @@ async def test_configure(): ts = termstatus.TermStatus() with taddons.context() as ctx: ctx.master.server = proxy.DummyServer() + ctx.master.server.bound = True ctx.configure(ts, server=False) ts.running() ctx.configure(ts, server=True)