make connection_strategy=eager the default
This commit is contained in:
parent
89603e5e6f
commit
aa815a5246
|
@ -83,8 +83,11 @@ class Proxyserver:
|
|||
|
||||
def load(self, loader):
|
||||
loader.add_option(
|
||||
"connection_strategy", str, "lazy",
|
||||
"Determine when server connections should be established.",
|
||||
"connection_strategy", str, "eager",
|
||||
"Determine when server connections should be established. When set to lazy, mitmproxy "
|
||||
"tries to defer establishing an upstream connection as long as possible. This makes it possible to "
|
||||
"use server replay while being offline. When set to eager, mitmproxy can detect protocols with "
|
||||
"server-side greetings, as well as accurately mirror TLS ALPN negotiation.",
|
||||
choices=("eager", "lazy")
|
||||
)
|
||||
loader.add_option(
|
||||
|
|
|
@ -23,7 +23,7 @@ class DestinationKnown(layer.Layer, metaclass=ABCMeta):
|
|||
child_layer: layer.Layer
|
||||
|
||||
def finish_start(self) -> layer.CommandGenerator[Optional[str]]:
|
||||
if self.context.options.connection_strategy == "eager":
|
||||
if self.context.options.connection_strategy == "eager" and self.context.server.address:
|
||||
err = yield commands.OpenConnection(self.context.server)
|
||||
if err:
|
||||
self._handle_event = self.done # type: ignore
|
||||
|
|
|
@ -546,6 +546,7 @@ def test_http_proxy_tcp(tctx, mode, close_first):
|
|||
"""Test TCP over HTTP CONNECT."""
|
||||
server = Placeholder(Server)
|
||||
f = Placeholder(TCPFlow)
|
||||
tctx.options.connection_strategy = "lazy"
|
||||
|
||||
if mode == "upstream":
|
||||
tctx.options.mode = "upstream:http://proxy:8080"
|
||||
|
@ -813,6 +814,7 @@ def test_http_server_aborts(tctx, stream):
|
|||
"response", "error"])
|
||||
def test_kill_flow(tctx, when):
|
||||
"""Test that we properly kill flows if instructed to do so"""
|
||||
tctx.options.connection_strategy = "lazy"
|
||||
server = Placeholder(Server)
|
||||
connect_flow = Placeholder(HTTPFlow)
|
||||
flow = Placeholder(HTTPFlow)
|
||||
|
|
|
@ -119,6 +119,7 @@ def test_reverse_proxy(tctx, keep_host_header):
|
|||
"""
|
||||
server = Placeholder(Server)
|
||||
tctx.options.mode = "reverse:http://localhost:8000"
|
||||
tctx.options.connection_strategy = "lazy"
|
||||
tctx.options.keep_host_header = keep_host_header
|
||||
assert (
|
||||
Playbook(modes.ReverseProxy(tctx), hooks=False)
|
||||
|
@ -321,6 +322,7 @@ def test_socks5_success(address: str, packed: bytes, tctx: Context):
|
|||
|
||||
|
||||
def test_socks5_trickle(tctx: Context):
|
||||
tctx.options.connection_strategy = "lazy"
|
||||
playbook = Playbook(modes.Socks5Proxy(tctx))
|
||||
for x in CLIENT_HELLO:
|
||||
playbook >> DataReceived(tctx.client, bytes([x]))
|
||||
|
|
Loading…
Reference in New Issue