mirror of
https://github.com/Tribufu/rust-gamedig
synced 2026-08-09 07:01:06 +00:00
[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:
parent
e620398615
commit
3f654e0dfd
60 changed files with 155 additions and 162 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use std::net::Ipv4Addr;
|
||||
use std::net::IpAddr;
|
||||
use crate::{
|
||||
protocols::minecraft::{self, BedrockResponse, JavaResponse, LegacyGroup},
|
||||
GDError,
|
||||
|
|
@ -7,7 +7,7 @@ use crate::{
|
|||
|
||||
/// Query with all the protocol variants one by one (Java -> Bedrock -> Legacy
|
||||
/// (1.6 -> 1.4 -> Beta 1.8)).
|
||||
pub fn query(address: &Ipv4Addr, port: Option<u16>) -> GDResult<JavaResponse> {
|
||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<JavaResponse> {
|
||||
if let Ok(response) = query_java(address, port) {
|
||||
return Ok(response);
|
||||
}
|
||||
|
|
@ -24,22 +24,22 @@ pub fn query(address: &Ipv4Addr, port: Option<u16>) -> GDResult<JavaResponse> {
|
|||
}
|
||||
|
||||
/// Query a Java Server.
|
||||
pub fn query_java(address: &Ipv4Addr, port: Option<u16>) -> GDResult<JavaResponse> {
|
||||
pub fn query_java(address: &IpAddr, port: Option<u16>) -> GDResult<JavaResponse> {
|
||||
minecraft::query_java(address, port_or_java_default(port), None)
|
||||
}
|
||||
|
||||
/// Query a (Java) Legacy Server (1.6 -> 1.4 -> Beta 1.8).
|
||||
pub fn query_legacy(address: &Ipv4Addr, port: Option<u16>) -> GDResult<JavaResponse> {
|
||||
pub fn query_legacy(address: &IpAddr, port: Option<u16>) -> GDResult<JavaResponse> {
|
||||
minecraft::query_legacy(address, port_or_java_default(port), None)
|
||||
}
|
||||
|
||||
/// Query a specific (Java) Legacy Server.
|
||||
pub fn query_legacy_specific(group: LegacyGroup, address: &Ipv4Addr, port: Option<u16>) -> GDResult<JavaResponse> {
|
||||
pub fn query_legacy_specific(group: LegacyGroup, address: &IpAddr, port: Option<u16>) -> GDResult<JavaResponse> {
|
||||
minecraft::query_legacy_specific(group, address, port_or_java_default(port), None)
|
||||
}
|
||||
|
||||
/// Query a Bedrock Server.
|
||||
pub fn query_bedrock(address: &Ipv4Addr, port: Option<u16>) -> GDResult<BedrockResponse> {
|
||||
pub fn query_bedrock(address: &IpAddr, port: Option<u16>) -> GDResult<BedrockResponse> {
|
||||
minecraft::query_bedrock(address, port_or_bedrock_default(port), None)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue