[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,7 +1,7 @@
// This file has code that has been documented by the NodeJS GameDig library
// (MIT) from https://github.com/gamedig/node-gamedig/blob/master/protocols/minecraftbedrock.js
use std::net::Ipv4Addr;
use std::net::IpAddr;
use crate::{
bufferer::{Bufferer, Endianess},
protocols::{
@ -19,7 +19,7 @@ pub struct Bedrock {
}
impl Bedrock {
fn new(address: &Ipv4Addr, port: u16, timeout_settings: Option<TimeoutSettings>) -> GDResult<Self> {
fn new(address: &IpAddr, port: u16, timeout_settings: Option<TimeoutSettings>) -> GDResult<Self> {
let socket = UdpSocket::new(address, port)?;
socket.apply_timeout(timeout_settings)?;
@ -93,7 +93,7 @@ impl Bedrock {
})
}
pub fn query(address: &Ipv4Addr, port: u16, timeout_settings: Option<TimeoutSettings>) -> GDResult<BedrockResponse> {
pub fn query(address: &IpAddr, port: u16, timeout_settings: Option<TimeoutSettings>) -> GDResult<BedrockResponse> {
Bedrock::new(address, port, timeout_settings)?.get_info()
}
}