surban / aggligator

Aggregates multiple links (TCP, Bluetooth, USB or similar) into one connection having their combined bandwidth and provides resiliency against failure of individual links.
https://crates.io/crates/aggligator
Other
129 stars 8 forks source link

Listen to both IPv4 and IPv6 on Windows #4

Closed PaperStrike closed 6 months ago

PaperStrike commented 6 months ago

Hello, surban! This is a great project and I really feel epic when seeing the bandwidth combined, a Big Thank You!

I guess you haven't tried agg-tunnel on Windows, but I can confirm that it works smoothly, with a small modification. It's that IPv6 listeners don't get IPv4 connections by default on Windows. So most of the time agg-tunnel just catches nothing.

My solution to this (https://github.com/PaperStrike/aggligator/commit/5f154988cb020bff5ef1c4b231992b03479bfc60) is to set the only_v6 flag with socket2. Per https://github.com/tokio-rs/tokio/pull/6171, tokio seems not liking having the option. In client mode, I set it true, open up two sockets, one for IPv4, one for IPv6, and merge their "accept" together. This is because 127.0.0.1 doesn't get mapped to ::1 and the socket don't catch 127.0.0.1 on Win even with only_v6 set to false, unless with global mode on which uses Ipv6Addr::UNSPECIFIED. In server mode, I simply set only_v6 false.

This issue can also be solved by differentiating platforms and use different code path. Note some Linux also default only_v6 to true, and the default value is configurable. It can also be solved by extending the --ipv4/--ipv6 option usage or introducing new ones. I have no idea which way is better.

This seems irrelevant to what this project is about, but it's relevant to Rust. AFAIK, Java and Python has made their decisions to unify the default behavior across platforms, one binds sockets to both, one binds to only v4 or only v6. Rust/Go/Node.js is still standing in the middle and requires adjustments per project.

I am new to Rust, apologize if I misunderstand anything. Thank you again for your amazing work!

surban commented 6 months ago

Could you verify that it works in the latest release?

PaperStrike commented 6 months ago

@surban Sure! I've checked that the client loopback mode now works, but it still doesn't work with client global mode and server mode, I believe it's because the only_v6 flag is only effective before the socket was bound. Hope it helps.

surban commented 6 months ago

Could you try again with version 0.13.0?

PaperStrike commented 6 months ago

@surban Yes, I can confirm that every mode (client loopback, client global and server) now works smoothly. I haven't got the chance to test ethernet / usb connections, though. I only have WiFi available on my computer recently.

Cheers!