gamedig / rust-gamedig

Game Server Query Library.
https://crates.io/crates/gamedig
MIT License
38 stars 11 forks source link

Enable the use of Ipv6 addresses #41

Closed Douile closed 1 year ago

Douile commented 1 year ago

Replace usages of Ipv4Addr with IpAddr which allows the use of either Ipv4 or Ipv6.

This patch essentially consists of running: "sed -i 's/Ipv4Addr/IpAddr/g' src/*/.rs" and fixing the errors.

Closes #39

Douile commented 1 year ago

Sorry for all the force pushes, had some problems with my editor auto-formatting code I didn't want to touch.

CosminPerRam commented 1 year ago

Looks great, thanks!

cainthebest commented 1 year ago

Looking back at this, it could be a improvement to use std::net::SocketAddr, This would support IPv4 + 6 and it would include the port so that the address is contained in 1.

Ref: https://doc.rust-lang.org/std/net/enum.SocketAddr.html

Douile commented 1 year ago

Very true, that would also allow removing this conversion from ip address + port num -> string -> SocketAddress. https://github.com/gamedig/rust-gamedig/blob/main/src/socket.rs#L32

CosminPerRam commented 1 year ago

Agreed, I will take care of this tomorrow if someone doesnt until then.