Skip to content

Commit

Permalink
mitigate impact of missing sockaddr for UDP, refs mitmproxy#6204
Browse files Browse the repository at this point in the history
  • Loading branch information
mhils committed Jun 25, 2023
1 parent e71a766 commit c4676a0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mitmproxy/proxy/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,18 @@ def __init__(
options: moptions.Options,
mode: mode_specs.ProxyMode,
) -> None:
# mitigate impact of https://github.com/mitmproxy/mitmproxy/issues/6204:
# For UDP, we don't get an accurate sockname from the transport when binding to all interfaces,
# however we would later need that to generate matching certificates.
# Until this is fixed properly, we can at least make the localhost case work.
sockname = writer.get_extra_info("sockname")
if sockname == "::":
sockname = "::1"
elif sockname == "0.0.0.0":
sockname = "127.0.0.1"
client = Client(
peername=writer.get_extra_info("peername"),
sockname=writer.get_extra_info("sockname"),
sockname=sockname,
timestamp_start=time.time(),
proxy_mode=mode,
state=ConnectionState.OPEN,
Expand Down

0 comments on commit c4676a0

Please sign in to comment.