[Protocol] Enable the use of Ipv6 addresses (#41)

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 examples/*"
and fixing the errors.
This commit is contained in:
Tom 2023-05-29 08:10:21 +00:00 committed by GitHub
parent e620398615
commit 3f654e0dfd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
60 changed files with 155 additions and 162 deletions

View file

@ -1,4 +1,4 @@
use std::net::Ipv4Addr;
use std::net::IpAddr;
use crate::protocols::types::TimeoutSettings;
use crate::protocols::valve::{Engine, Environment, Server, ValveProtocol};
use crate::GDResult;
@ -43,11 +43,11 @@ pub struct Response {
pub time_left: u16,
}
pub fn query(address: &Ipv4Addr, port: Option<u16>) -> GDResult<Response> {
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response> {
query_with_timeout(address, port, TimeoutSettings::default())
}
pub fn query_with_timeout(address: &Ipv4Addr, port: Option<u16>, timeout_settings: TimeoutSettings) -> GDResult<Response> {
pub fn query_with_timeout(address: &IpAddr, port: Option<u16>, timeout_settings: TimeoutSettings) -> GDResult<Response> {
let mut client = ValveProtocol::new(address, port.unwrap_or(5478), Some(timeout_settings))?;
let mut buffer = client.get_request_data(
&Engine::GoldSrc(true),