mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +00:00
[Protocol] Fix Minecraft Java query not being able to specify a hostname (#91)
* Make initial fix * Fix imports * Rename query_address to hostname and add this to the mc example * Fix master_querant example not compiling * Add extra safety on converting strings to Minecraft Varint strings * Add docs to RequestSettings * Fix formatting
This commit is contained in:
parent
211cd5fd5f
commit
a56ca45de6
8 changed files with 118 additions and 28 deletions
|
|
@ -1,3 +1,4 @@
|
|||
use crate::protocols::minecraft::RequestSettings;
|
||||
use crate::{
|
||||
protocols::minecraft::{self, BedrockResponse, JavaResponse, LegacyGroup},
|
||||
GDErrorKind,
|
||||
|
|
@ -8,7 +9,7 @@ use std::net::{IpAddr, SocketAddr};
|
|||
/// Query with all the protocol variants one by one (Java -> Bedrock -> Legacy
|
||||
/// (1.6 -> 1.4 -> Beta 1.8)).
|
||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<JavaResponse> {
|
||||
if let Ok(response) = query_java(address, port) {
|
||||
if let Ok(response) = query_java(address, port, None) {
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
|
|
@ -24,8 +25,16 @@ pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<JavaResponse> {
|
|||
}
|
||||
|
||||
/// Query a Java Server.
|
||||
pub fn query_java(address: &IpAddr, port: Option<u16>) -> GDResult<JavaResponse> {
|
||||
minecraft::query_java(&SocketAddr::new(*address, port_or_java_default(port)), None)
|
||||
pub fn query_java(
|
||||
address: &IpAddr,
|
||||
port: Option<u16>,
|
||||
request_settings: Option<RequestSettings>,
|
||||
) -> GDResult<JavaResponse> {
|
||||
minecraft::query_java(
|
||||
&SocketAddr::new(*address, port_or_java_default(port)),
|
||||
None,
|
||||
request_settings,
|
||||
)
|
||||
}
|
||||
|
||||
/// Query a (Java) Legacy Server (1.6 -> 1.4 -> Beta 1.8).
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ pub fn query_with_timeout(
|
|||
Protocol::Minecraft(version) => {
|
||||
match version {
|
||||
Some(protocols::minecraft::Server::Java) => {
|
||||
protocols::minecraft::query_java(&socket_addr, timeout_settings).map(Box::new)?
|
||||
protocols::minecraft::query_java(&socket_addr, timeout_settings, None).map(Box::new)?
|
||||
}
|
||||
Some(protocols::minecraft::Server::Bedrock) => {
|
||||
protocols::minecraft::query_bedrock(&socket_addr, timeout_settings).map(Box::new)?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue