naia-lib / naia

a cross-platform (including Wasm!) networking library built in Rust. Intended to make multiplayer game development dead-simple & lightning-fast
Apache License 2.0
878 stars 58 forks source link

`candidate_to_addr` in `wasm_utils` does not detect IPv6 address #51

Closed connorcarpenter closed 2 years ago

connorcarpenter commented 2 years ago

As noted by @FF-AntiK in https://github.com/naia-rs/naia-socket/issues/57:

url_to_socket_addr returns the first address it can find, which could be IPv6: https://github.com/naia-rs/naia-socket/blob/main/shared/src/url_parse.rs#L43

but the regex in candidate_to_addr does not support IPv6 ([::] notation): https://github.com/naia-rs/naia-socket/blob/main/client/src/wasm_utils.rs#L9

FF-AntiK commented 2 years ago

I've added IPv6 support to the regex here: https://github.com/FF-AntiK/naia-1/blob/ipv6_support/socket/client/src/wasm_utils.rs#L8

The regex is a mess and the IPv6 part is just copied from random stackoverflow. But it's working for me ;-) Maybe you can simplify the regex.

Unfortunately this still not works with Firefox. Firefox complains about address type mis-match which makes me believe that at some other point of the naia stack the address is interpreted as IPv4.

connorcarpenter commented 2 years ago

Thank you for this FF-AntiK :pray: will merge soon