coop-deluxe / sm64coopdx

An official continuation of https://github.com/djoslin0/sm64ex-coop on sm64coopdx for the enhancements and progress it already has.
https://sm64coopdx.com
286 stars 41 forks source link

Update sockets and structs for full IPv6 support #198

Open RoddyDev opened 1 month ago

RoddyDev commented 1 month ago

Resolves #172

Trying to connect to this updated version from v1.0 connects normally on Windows, showing "Version mismatch". Trying to connect to this updated version from v1.0 causes a crash on Linux, but it connects normally when using the same updated version. The updated version was only tested on Linux. Couldn't get the compiler to work on Windows, even after following the compilation guide. Might need to get someone to test it for me on Windows before merging.

RoddyDev commented 1 month ago

https://github.com/coop-deluxe/sm64coopdx/assets/45442056/7cddbc78-57b0-4d07-a22e-d59fa3f79f1e

Video of it in action (very low quality to fit in 10 MB) IPv6-only server for testing: mariocoop.roddydev.com

RoddyDev commented 1 month ago

Finally got the compiler to work on Windows and can confirm that it can connect normally to any server hosted on either Windows or Linux systems. I'm unable to test on macOS but it should also work the same way.

https://github.com/user-attachments/assets/ba6352e1-32b2-4cc9-bba9-5a4cd3870c8f

Here's a Windows client connecting to a server hosted on Linux.

EmeraldLoc commented 1 month ago

Tested this on macOS, works fine!

RoddyDev commented 1 month ago

Tested this on macOS, works fine!

Thank you so much for testing.

RoddyDev commented 1 month ago

I don't think there's anything else to add here anymore. Everything works perfectly in all platforms.

The only requirement is that IPv6 needs to be enabled in your network adapter settings. (Does not require actual IPv6 connectivity + it's enabled by default in all operating systems today). Maybe we should add a fallback to AF_INET socket or show an error on screen if binding to an AF_INET6 socket fails (which means IPv6 is disabled on the system).

Edit: Guess it's not really a requirement? Tried to host with IPv6 disabled on the network adapter settings on both Windows and Linux, and it still bound to all addresses without any issues. Unless the IPv6 stack is completely absent from the system like some do with Linux? Not sure.

Coopnet is untouched and also works perfectly normal. I don't know if the edits in the translation files are really necessary, so feel free to edit these back to what it was if you want. For now, I call this final. Waiting for further testing from the maintainers.

Isaac0-dev commented 1 month ago

imo there should still be a way for ipv4 to be used, what is the current behavior if ipv6 fails?

RoddyDev commented 1 month ago

imo there should still be a way for ipv4 to be used, what is the current behavior if ipv6 fails?

Having IPv6 support doesn't mean that IPv4 support will be removed, you can still use it. When hosting a server using Direct Connection, it creates an AF_INET6 socket with IPV6_V6ONLY disabled so it does have IPv4+IPv6 support when binding to all addresses (in6addr_any). In my testings, neither Windows nor Linux complains when IPv6 is disabled on the network adapter and can still host.

When joining, getaddrinfo() returns an address depending if IPv6 connection is working or not. If it is, return IPv6 addresses first, if not, return IPv4 addresses first.

What I want to say is: If you don't have an IPv6 enabled network, it won't break! The AF_INET6 socket will still work. You just will only be reachable over IPv4. In an IPv6-only network: Coopnet will still be unreachable, but you will now be able to host and join direct connection servers.

EmeraldLoc commented 1 month ago

neither Windows nor Linux complains when IPv6 is disabled on the network adapter and can still host.

can confirm macOS also doesn’t complain, and connects just fine.

AgentXLP commented 1 month ago

You only have the English and Portuguese language translations, I'd need you to get translations for other languages before I can merge this.

RoddyDev commented 1 month ago

Uploaded the translations. Cannot guarantee that the translations are accurate except English, Portuguese and German, because these three were translated from native speakers.

RoddyDev commented 1 week ago

If the translations are the problem that this isn't being merged, I can just revert them to what it was before. I just wanted to let the user know that both protocols are supported.