Skip to content

Commit a9283be

Browse files
authored
improve self-connect error message (#5192)
1 parent 3a5550a commit a9283be

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

mitmproxy/addons/proxyserver.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ async def refresh_server(self):
140140
except OSError as e:
141141
ctx.log.error(str(e))
142142
return
143+
# TODO: This is a bit confusing currently for `-p 0`.
143144
addrs = {f"http://{human.format_address(s.getsockname())}" for s in self.server.sockets}
144145
ctx.log.info(f"Proxy server listening at {' and '.join(addrs)}")
145146

@@ -208,4 +209,7 @@ def server_connect(self, ctx: server_hooks.ServerConnectionHookData):
208209
ctx.server.address[0] in ("localhost", "127.0.0.1", "::1", self.options.listen_host)
209210
)
210211
if self_connect:
211-
ctx.server.error = "Stopped mitmproxy from recursively connecting to itself."
212+
ctx.server.error = (
213+
"Request destination unknown. "
214+
"Unable to figure out where this request should be forwarded to."
215+
)

test/mitmproxy/addons/test_proxyserver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def test_self_connect():
171171
ps.server_connect(
172172
server_hooks.ServerConnectionHookData(server, client)
173173
)
174-
assert server.error == "Stopped mitmproxy from recursively connecting to itself."
174+
assert "Request destination unknown" in server.error
175175

176176

177177
def test_options():

0 commit comments

Comments
 (0)