mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 07:08:10 +00:00
improve self-connect error message (#5192)
This commit is contained in:
parent
3a5550a09c
commit
a9283befad
@ -140,6 +140,7 @@ class Proxyserver:
|
|||||||
except OSError as e:
|
except OSError as e:
|
||||||
ctx.log.error(str(e))
|
ctx.log.error(str(e))
|
||||||
return
|
return
|
||||||
|
# TODO: This is a bit confusing currently for `-p 0`.
|
||||||
addrs = {f"http://{human.format_address(s.getsockname())}" for s in self.server.sockets}
|
addrs = {f"http://{human.format_address(s.getsockname())}" for s in self.server.sockets}
|
||||||
ctx.log.info(f"Proxy server listening at {' and '.join(addrs)}")
|
ctx.log.info(f"Proxy server listening at {' and '.join(addrs)}")
|
||||||
|
|
||||||
@ -208,4 +209,7 @@ class Proxyserver:
|
|||||||
ctx.server.address[0] in ("localhost", "127.0.0.1", "::1", self.options.listen_host)
|
ctx.server.address[0] in ("localhost", "127.0.0.1", "::1", self.options.listen_host)
|
||||||
)
|
)
|
||||||
if self_connect:
|
if self_connect:
|
||||||
ctx.server.error = "Stopped mitmproxy from recursively connecting to itself."
|
ctx.server.error = (
|
||||||
|
"Request destination unknown. "
|
||||||
|
"Unable to figure out where this request should be forwarded to."
|
||||||
|
)
|
||||||
|
@ -171,7 +171,7 @@ def test_self_connect():
|
|||||||
ps.server_connect(
|
ps.server_connect(
|
||||||
server_hooks.ServerConnectionHookData(server, client)
|
server_hooks.ServerConnectionHookData(server, client)
|
||||||
)
|
)
|
||||||
assert server.error == "Stopped mitmproxy from recursively connecting to itself."
|
assert "Request destination unknown" in server.error
|
||||||
|
|
||||||
|
|
||||||
def test_options():
|
def test_options():
|
||||||
|
Loading…
Reference in New Issue
Block a user