sans-io compat++

This commit is contained in:
Maximilian Hils 2020-11-17 17:29:17 +01:00
parent 98f060d019
commit 739b5b0b74
3 changed files with 7 additions and 5 deletions

View File

@ -9,7 +9,7 @@ from mitmproxy.utils import human
class TermStatus: class TermStatus:
def running(self): def running(self):
if ctx.options.server: if ctx.master.server.bound:
ctx.log.info( ctx.log.info(
"Proxy server listening at http://{}".format( "Proxy server listening at http://{}".format(
human.format_address(ctx.master.server.address) human.format_address(ctx.master.server.address)

View File

@ -6,6 +6,7 @@ from mitmproxy import connections
from mitmproxy import controller, exceptions # noqa from mitmproxy import controller, exceptions # noqa
from mitmproxy import stateobject from mitmproxy import stateobject
from mitmproxy import version from mitmproxy import version
from mitmproxy.utils import compat
class Error(stateobject.StateObject): class Error(stateobject.StateObject):
@ -63,8 +64,8 @@ class Flow(stateobject.StateObject):
def __init__( def __init__(
self, self,
type: str, type: str,
client_conn: connections.ClientConnection, client_conn: compat.Client,
server_conn: connections.ServerConnection, server_conn: compat.Server,
live: bool=None live: bool=None
) -> None: ) -> None:
self.type = type self.type = type
@ -84,8 +85,8 @@ class Flow(stateobject.StateObject):
_stateobject_attributes = dict( _stateobject_attributes = dict(
id=str, id=str,
error=Error, error=Error,
client_conn=connections.ClientConnection, client_conn=compat.Client,
server_conn=connections.ServerConnection, server_conn=compat.Server,
type=str, type=str,
intercepted=bool, intercepted=bool,
is_replay=str, is_replay=str,

View File

@ -10,6 +10,7 @@ async def test_configure():
ts = termstatus.TermStatus() ts = termstatus.TermStatus()
with taddons.context() as ctx: with taddons.context() as ctx:
ctx.master.server = proxy.DummyServer() ctx.master.server = proxy.DummyServer()
ctx.master.server.bound = True
ctx.configure(ts, server=False) ctx.configure(ts, server=False)
ts.running() ts.running()
ctx.configure(ts, server=True) ctx.configure(ts, server=True)