Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Binding on both IPv4 and IPv6 does not work #23

Closed
ItsShadowCone opened this issue Nov 29, 2022 · 3 comments
Closed

Binding on both IPv4 and IPv6 does not work #23

ItsShadowCone opened this issue Nov 29, 2022 · 3 comments

Comments

@ItsShadowCone
Copy link

Leaving the host empty defaults to binding to both 0.0.0.0 and ::1. However, rust's UDPSocket doesn't bind to both, it binds to the first successful.

Happens here: https://github.com/decathorpe/mitmproxy_wireguard/blob/main/src/server.rs#L125..L135
Documentation here: https://doc.rust-lang.org/std/net/struct.UdpSocket.html#method.bind

Best fix is probably to just support a single listen address, since multiple listen sockets opens another can of worms.

@decathorpe
Copy link
Owner

Oh, I could swear that I read the documentation when I changed this ... (i.e. here b168977 ), but you're right, tokio's UdpSocket binds to the first successful one, so the change I made in that commit was just wrong.

What should be default to if the argument is empty, though? Probably 0.0.0.0? Defaulting to IPv6 doesn't seem like a good idea.

@ItsShadowCone
Copy link
Author

Uh...... either this https://stackoverflow.com/a/1618259, but that's probably effort (dunno if tokio supports it out of the box) (i.e. supply [::1, 0.0.0.0] to the bind + the relevant options to allow ipv4 on the ipv6 bind (if it's successful), and take it from there..... supports ipv4 and ipv6 if possible, and should fall back to ipv4 if ipv6 is disabled)

or just 0.0.0.0, but make it obvious in the log output.

or just don't offer a default, only two examples (for 0.0.0.0 and ::1).

@decathorpe
Copy link
Owner

Sorry for the late response. This project has been superseded by mitmproxy_rs a while ago - but it looks like the same code is still present there: https://github.com/mitmproxy/mitmproxy_rs/blob/main/src/packet_sources/wireguard.rs#L88-L96

I filed a new ticket at https://github.com/mitmproxy/mitmproxy_rs.

@decathorpe decathorpe closed this as not planned Won't fix, can't repro, duplicate, stale Feb 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants