Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require host to be specified for WireGuardConf and set IPV6_V6ONLY #242

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

errorxyz
Copy link
Member

@errorxyz errorxyz commented Mar 5, 2025

Refs mitmproxy/mitmproxy#6671
Socket building logic copied from:

async fn build(

@errorxyz errorxyz changed the title Require host to be specified for WireGuardConf and set IPV6_V6ONLY off Require host to be specified for WireGuardConf and set IPV6_V6ONLY Mar 5, 2025
Copy link
Member

@mhils mhils left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this! Would it make sense to merge both implementations into a common function with an explanatory docstring?

Copy link
Member

@decathorpe decathorpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, reading the PR title / commit message first and the actual code changes second I was very confused what this PR was actually doing 😅

As far as I can tell, you're

  1. dropping the unintended fallback to an IPv6 socket if binding to an IPv4 socket fails
  2. requiring the "host" argument not to be empty, and
  3. setting IPv6 only mode if the address is an IPv6 address.

The changes 1. and 3. look good to me, but I'm not sure I like losing the default behaviour of "if no host is specified, fall back to 0.0.0.0, which is a good default IMO.

Maybe falling back to 0.0.0.0 would be ok if the "host" argument is empty? That should match the current behaviour in all cases except the pathological one where binding to 0.0.0.0 failed but binding to ::1 works for some strange reason.

@mhils
Copy link
Member

mhils commented Mar 6, 2025

I think there's an argument to be made that we should just mirror what std::net::UdpListener does, which also requires "host" to not be empty. What do you think? We could also just take std::net::ToSocketAddrs and be done with it. We don't need special empty string logic. :)

@decathorpe
Copy link
Member

Ok, if the UDP mode already does it this way, it makes sense to have consistent behaviour.

@errorxyz
Copy link
Member Author

errorxyz commented Mar 6, 2025

FWIW, reading the PR title / commit message first and the actual code changes second I was very confused what this PR was actually doing 😅

Totally agreed 😅 I was drafting this in the middle of the night and I guess I just got too tired by the time I submitted the PR. Will make it clearer in the coming days :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants