mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +00:00
[Crate] Enforce formatting in CI (#46)
* [CI] Check formatting * Format all files
This commit is contained in:
parent
a6279177bb
commit
b95b2abe0f
76 changed files with 251 additions and 170 deletions
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
|
|
@ -28,3 +28,10 @@ jobs:
|
||||||
override: true
|
override: true
|
||||||
- name: Run MSRV
|
- name: Run MSRV
|
||||||
run: cargo build
|
run: cargo build
|
||||||
|
- name: Install nightly
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: nightly
|
||||||
|
components: rustfmt
|
||||||
|
- name: Run formatting check
|
||||||
|
run: cargo +nightly fmt --check --verbose
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,62 @@
|
||||||
use gamedig::protocols::{gamespy, quake};
|
|
||||||
use gamedig::protocols::minecraft::LegacyGroup;
|
use gamedig::protocols::minecraft::LegacyGroup;
|
||||||
use gamedig::protocols::valve;
|
use gamedig::protocols::valve;
|
||||||
use gamedig::protocols::valve::Engine;
|
use gamedig::protocols::valve::Engine;
|
||||||
use gamedig::{aliens, aoc, arma2oa, ase, asrd, avorion, bat1944, bb2, bf1942, bm, bo, ccure, cosu, cs, cscz, csgo, css, dod, dods, doi, dst, ffow, gm, hl2dm, hldms, ins, insmic, inss, l4d, l4d2, mc, ohd, onset, pz, ror2, rust, sc, sdtd, ss, tf, tf2, tfc, ts, unturned, ut, vr, GDResult, cw, quake2, quake1, quake3a, hll, sof2};
|
use gamedig::protocols::{gamespy, quake};
|
||||||
|
use gamedig::{
|
||||||
|
aliens,
|
||||||
|
aoc,
|
||||||
|
arma2oa,
|
||||||
|
ase,
|
||||||
|
asrd,
|
||||||
|
avorion,
|
||||||
|
bat1944,
|
||||||
|
bb2,
|
||||||
|
bf1942,
|
||||||
|
bm,
|
||||||
|
bo,
|
||||||
|
ccure,
|
||||||
|
cosu,
|
||||||
|
cs,
|
||||||
|
cscz,
|
||||||
|
csgo,
|
||||||
|
css,
|
||||||
|
cw,
|
||||||
|
dod,
|
||||||
|
dods,
|
||||||
|
doi,
|
||||||
|
dst,
|
||||||
|
ffow,
|
||||||
|
gm,
|
||||||
|
hl2dm,
|
||||||
|
hldms,
|
||||||
|
hll,
|
||||||
|
ins,
|
||||||
|
insmic,
|
||||||
|
inss,
|
||||||
|
l4d,
|
||||||
|
l4d2,
|
||||||
|
mc,
|
||||||
|
ohd,
|
||||||
|
onset,
|
||||||
|
pz,
|
||||||
|
quake1,
|
||||||
|
quake2,
|
||||||
|
quake3a,
|
||||||
|
ror2,
|
||||||
|
rust,
|
||||||
|
sc,
|
||||||
|
sdtd,
|
||||||
|
sof2,
|
||||||
|
ss,
|
||||||
|
tf,
|
||||||
|
tf2,
|
||||||
|
tfc,
|
||||||
|
ts,
|
||||||
|
unturned,
|
||||||
|
ut,
|
||||||
|
vr,
|
||||||
|
GDResult,
|
||||||
|
};
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::net::{IpAddr, SocketAddr};
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use gamedig::games::tf2;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let response = tf2::query(&"127.0.0.1".parse().unwrap(), None);
|
let response = tf2::query(&"127.0.0.1".parse().unwrap(), None);
|
||||||
// or Some(27015), None is the default protocol port (which is 27015)
|
// or Some(27015), None is the default protocol port (which is 27015)
|
||||||
|
|
||||||
match response {
|
match response {
|
||||||
// Result type, must check what it is...
|
// Result type, must check what it is...
|
||||||
|
|
|
||||||
|
|
@ -108,13 +108,9 @@ impl Bufferer {
|
||||||
Ok(value)
|
Ok(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_string_utf8(&mut self) -> GDResult<String> {
|
pub fn get_string_utf8(&mut self) -> GDResult<String> { self.get_string_utf8_until(0) }
|
||||||
self.get_string_utf8_until(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_string_utf8_newline(&mut self) -> GDResult<String> {
|
pub fn get_string_utf8_newline(&mut self) -> GDResult<String> { self.get_string_utf8_until(10) }
|
||||||
self.get_string_utf8_until(10)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_string_utf8_optional(&mut self) -> GDResult<String> {
|
pub fn get_string_utf8_optional(&mut self) -> GDResult<String> {
|
||||||
match self.get_string_utf8() {
|
match self.get_string_utf8() {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDError::TypeParse,
|
GDError::TypeParse,
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let mut valve_response = valve::query(
|
let mut valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::protocols::gamespy;
|
use crate::protocols::gamespy;
|
||||||
use crate::protocols::gamespy::one::Response;
|
use crate::protocols::gamespy::one::Response;
|
||||||
use crate::GDResult;
|
use crate::GDResult;
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response> {
|
||||||
gamespy::one::query(&SocketAddr::new(*address, port.unwrap_or(23000)), None)
|
gamespy::one::query(&SocketAddr::new(*address, port.unwrap_or(23000)), None)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::protocols::gamespy;
|
use crate::protocols::gamespy;
|
||||||
use crate::protocols::gamespy::three::Response;
|
use crate::protocols::gamespy::three::Response;
|
||||||
use crate::GDResult;
|
use crate::GDResult;
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response> {
|
||||||
gamespy::three::query(&SocketAddr::new(*address, port.unwrap_or(64100)), None)
|
gamespy::three::query(&SocketAddr::new(*address, port.unwrap_or(64100)), None)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::protocols::types::TimeoutSettings;
|
use crate::protocols::types::TimeoutSettings;
|
||||||
use crate::protocols::valve::{Engine, Environment, Server, ValveProtocol};
|
use crate::protocols::valve::{Engine, Environment, Server, ValveProtocol};
|
||||||
use crate::GDResult;
|
use crate::GDResult;
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
/// The query response.
|
/// The query response.
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
|
@ -47,8 +47,15 @@ pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response> {
|
||||||
query_with_timeout(address, port, TimeoutSettings::default())
|
query_with_timeout(address, port, TimeoutSettings::default())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query_with_timeout(address: &IpAddr, port: Option<u16>, timeout_settings: TimeoutSettings) -> GDResult<Response> {
|
pub fn query_with_timeout(
|
||||||
let mut client = ValveProtocol::new(&SocketAddr::new(*address, port.unwrap_or(5478)), Some(timeout_settings))?;
|
address: &IpAddr,
|
||||||
|
port: Option<u16>,
|
||||||
|
timeout_settings: TimeoutSettings,
|
||||||
|
) -> GDResult<Response> {
|
||||||
|
let mut client = ValveProtocol::new(
|
||||||
|
&SocketAddr::new(*address, port.unwrap_or(5478)),
|
||||||
|
Some(timeout_settings),
|
||||||
|
)?;
|
||||||
let mut buffer = client.get_request_data(
|
let mut buffer = client.get_request_data(
|
||||||
&Engine::GoldSrc(true),
|
&Engine::GoldSrc(true),
|
||||||
0,
|
0,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::minecraft::{self, BedrockResponse, JavaResponse, LegacyGroup},
|
protocols::minecraft::{self, BedrockResponse, JavaResponse, LegacyGroup},
|
||||||
GDError,
|
GDError,
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
/// Query with all the protocol variants one by one (Java -> Bedrock -> Legacy
|
/// Query with all the protocol variants one by one (Java -> Bedrock -> Legacy
|
||||||
/// (1.6 -> 1.4 -> Beta 1.8)).
|
/// (1.6 -> 1.4 -> Beta 1.8)).
|
||||||
|
|
@ -35,12 +35,19 @@ pub fn query_legacy(address: &IpAddr, port: Option<u16>) -> GDResult<JavaRespons
|
||||||
|
|
||||||
/// Query a specific (Java) Legacy Server.
|
/// Query a specific (Java) Legacy Server.
|
||||||
pub fn query_legacy_specific(group: LegacyGroup, address: &IpAddr, port: Option<u16>) -> GDResult<JavaResponse> {
|
pub fn query_legacy_specific(group: LegacyGroup, address: &IpAddr, port: Option<u16>) -> GDResult<JavaResponse> {
|
||||||
minecraft::query_legacy_specific(group, &SocketAddr::new(*address, port_or_java_default(port)), None)
|
minecraft::query_legacy_specific(
|
||||||
|
group,
|
||||||
|
&SocketAddr::new(*address, port_or_java_default(port)),
|
||||||
|
None,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Query a Bedrock Server.
|
/// Query a Bedrock Server.
|
||||||
pub fn query_bedrock(address: &IpAddr, port: Option<u16>) -> GDResult<BedrockResponse> {
|
pub fn query_bedrock(address: &IpAddr, port: Option<u16>) -> GDResult<BedrockResponse> {
|
||||||
minecraft::query_bedrock(&SocketAddr::new(*address, port_or_bedrock_default(port)), None)
|
minecraft::query_bedrock(
|
||||||
|
&SocketAddr::new(*address, port_or_bedrock_default(port)),
|
||||||
|
None,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn port_or_java_default(port: Option<u16>) -> u16 { port.unwrap_or(25565) }
|
fn port_or_java_default(port: Option<u16>) -> u16 { port.unwrap_or(25565) }
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@ pub mod cscz;
|
||||||
pub mod csgo;
|
pub mod csgo;
|
||||||
/// Counter-Strike: Source
|
/// Counter-Strike: Source
|
||||||
pub mod css;
|
pub mod css;
|
||||||
|
/// Crysis Wars
|
||||||
|
pub mod cw;
|
||||||
/// Day of Defeat
|
/// Day of Defeat
|
||||||
pub mod dod;
|
pub mod dod;
|
||||||
/// Day of Defeat: Source
|
/// Day of Defeat: Source
|
||||||
|
|
@ -50,6 +52,8 @@ pub mod gm;
|
||||||
pub mod hl2dm;
|
pub mod hl2dm;
|
||||||
/// Half-Life Deathmatch: Source
|
/// Half-Life Deathmatch: Source
|
||||||
pub mod hldms;
|
pub mod hldms;
|
||||||
|
/// Hell Let Loose
|
||||||
|
pub mod hll;
|
||||||
/// Insurgency
|
/// Insurgency
|
||||||
pub mod ins;
|
pub mod ins;
|
||||||
/// Insurgency: Modern Infantry Combat
|
/// Insurgency: Modern Infantry Combat
|
||||||
|
|
@ -68,6 +72,12 @@ pub mod ohd;
|
||||||
pub mod onset;
|
pub mod onset;
|
||||||
/// Project Zomboid
|
/// Project Zomboid
|
||||||
pub mod pz;
|
pub mod pz;
|
||||||
|
/// Quake 1
|
||||||
|
pub mod quake1;
|
||||||
|
/// Quake 2
|
||||||
|
pub mod quake2;
|
||||||
|
/// Quake 3: Arena
|
||||||
|
pub mod quake3a;
|
||||||
/// Risk of Rain 2
|
/// Risk of Rain 2
|
||||||
pub mod ror2;
|
pub mod ror2;
|
||||||
/// Rust
|
/// Rust
|
||||||
|
|
@ -76,6 +86,8 @@ pub mod rust;
|
||||||
pub mod sc;
|
pub mod sc;
|
||||||
/// 7 Days To Die
|
/// 7 Days To Die
|
||||||
pub mod sdtd;
|
pub mod sdtd;
|
||||||
|
/// Soldier of Fortune 2
|
||||||
|
pub mod sof2;
|
||||||
/// Serious Sam
|
/// Serious Sam
|
||||||
pub mod ss;
|
pub mod ss;
|
||||||
/// The Forest
|
/// The Forest
|
||||||
|
|
@ -92,15 +104,3 @@ pub mod unturned;
|
||||||
pub mod ut;
|
pub mod ut;
|
||||||
/// V Rising
|
/// V Rising
|
||||||
pub mod vr;
|
pub mod vr;
|
||||||
/// Crysis Wars
|
|
||||||
pub mod cw;
|
|
||||||
/// Quake 2
|
|
||||||
pub mod quake2;
|
|
||||||
/// Quake 1
|
|
||||||
pub mod quake1;
|
|
||||||
/// Quake 3: Arena
|
|
||||||
pub mod quake3a;
|
|
||||||
/// Hell Let Loose
|
|
||||||
pub mod hll;
|
|
||||||
/// Soldier of Fortune 2
|
|
||||||
pub mod sof2;
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::GDResult;
|
|
||||||
use crate::protocols::quake;
|
use crate::protocols::quake;
|
||||||
use crate::protocols::quake::Response;
|
|
||||||
use crate::protocols::quake::one::Player;
|
use crate::protocols::quake::one::Player;
|
||||||
|
use crate::protocols::quake::Response;
|
||||||
|
use crate::GDResult;
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response<Player>> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response<Player>> {
|
||||||
quake::one::query(&SocketAddr::new(*address, port.unwrap_or(27500)), None)
|
quake::one::query(&SocketAddr::new(*address, port.unwrap_or(27500)), None)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::GDResult;
|
|
||||||
use crate::protocols::quake;
|
use crate::protocols::quake;
|
||||||
use crate::protocols::quake::Response;
|
|
||||||
use crate::protocols::quake::two::Player;
|
use crate::protocols::quake::two::Player;
|
||||||
|
use crate::protocols::quake::Response;
|
||||||
|
use crate::GDResult;
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response<Player>> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response<Player>> {
|
||||||
quake::two::query(&SocketAddr::new(*address, port.unwrap_or(27910)), None)
|
quake::two::query(&SocketAddr::new(*address, port.unwrap_or(27910)), None)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::GDResult;
|
|
||||||
use crate::protocols::quake;
|
use crate::protocols::quake;
|
||||||
use crate::protocols::quake::Response;
|
|
||||||
use crate::protocols::quake::two::Player;
|
use crate::protocols::quake::two::Player;
|
||||||
|
use crate::protocols::quake::Response;
|
||||||
|
use crate::GDResult;
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response<Player>> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response<Player>> {
|
||||||
quake::three::query(&SocketAddr::new(*address, port.unwrap_or(27960)), None)
|
quake::three::query(&SocketAddr::new(*address, port.unwrap_or(27960)), None)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::GDResult;
|
|
||||||
use crate::protocols::quake;
|
use crate::protocols::quake;
|
||||||
use crate::protocols::quake::Response;
|
|
||||||
use crate::protocols::quake::two::Player;
|
use crate::protocols::quake::two::Player;
|
||||||
|
use crate::protocols::quake::Response;
|
||||||
|
use crate::GDResult;
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response<Player>> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response<Player>> {
|
||||||
quake::three::query(&SocketAddr::new(*address, port.unwrap_or(20100)), None)
|
quake::three::query(&SocketAddr::new(*address, port.unwrap_or(20100)), None)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::protocols::gamespy;
|
use crate::protocols::gamespy;
|
||||||
use crate::protocols::gamespy::one::Response;
|
use crate::protocols::gamespy::one::Response;
|
||||||
use crate::GDResult;
|
use crate::GDResult;
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response> {
|
||||||
gamespy::one::query(&SocketAddr::new(*address, port.unwrap_or(25601)), None)
|
gamespy::one::query(&SocketAddr::new(*address, port.unwrap_or(25601)), None)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, get_optional_extracted_data, Server, ServerPlayer, SteamApp},
|
protocols::valve::{self, get_optional_extracted_data, Server, ServerPlayer, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::protocols::gamespy;
|
use crate::protocols::gamespy;
|
||||||
use crate::protocols::gamespy::one::Response;
|
use crate::protocols::gamespy::one::Response;
|
||||||
use crate::GDResult;
|
use crate::GDResult;
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response> {
|
||||||
gamespy::one::query(&SocketAddr::new(*address, port.unwrap_or(7778)), None)
|
gamespy::one::query(&SocketAddr::new(*address, port.unwrap_or(7778)), None)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::valve::{self, game, SteamApp},
|
protocols::valve::{self, game, SteamApp},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
||||||
let valve_response = valve::query(
|
let valve_response = valve::query(
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@
|
||||||
//! # Crate features:
|
//! # Crate features:
|
||||||
//! Enabled by default: None
|
//! Enabled by default: None
|
||||||
//!
|
//!
|
||||||
//! `serde` - enables json serialization/deserialization for all response types. <br>
|
//! `serde` - enables json serialization/deserialization for all response types.
|
||||||
//! `no_games` - disables the included games support. <br>
|
//! <br> `no_games` - disables the included games support. <br>
|
||||||
//! `no_services` - disables the included services support.
|
//! `no_services` - disables the included services support.
|
||||||
|
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
use crate::protocols::gamespy::common::has_password;
|
||||||
use crate::{
|
use crate::{
|
||||||
bufferer::{Bufferer, Endianess},
|
bufferer::{Bufferer, Endianess},
|
||||||
protocols::{
|
protocols::{
|
||||||
|
|
@ -8,7 +9,6 @@ use crate::{
|
||||||
GDError,
|
GDError,
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
use crate::protocols::gamespy::common::has_password;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// This file has code that has been documented by the NodeJS GameDig library
|
// 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
|
// (MIT) from https://github.com/gamedig/node-gamedig/blob/master/protocols/minecraftbedrock.js
|
||||||
|
|
||||||
use std::net::SocketAddr;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
bufferer::{Bufferer, Endianess},
|
bufferer::{Bufferer, Endianess},
|
||||||
protocols::{
|
protocols::{
|
||||||
|
|
@ -13,6 +12,7 @@ use crate::{
|
||||||
GDError::{PacketBad, TypeParse},
|
GDError::{PacketBad, TypeParse},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
pub struct Bedrock {
|
pub struct Bedrock {
|
||||||
socket: UdpSocket,
|
socket: UdpSocket,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
use std::net::SocketAddr;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
bufferer::{Bufferer, Endianess},
|
bufferer::{Bufferer, Endianess},
|
||||||
protocols::{
|
protocols::{
|
||||||
|
|
@ -9,6 +8,7 @@ use crate::{
|
||||||
GDError::{JsonParse, PacketBad},
|
GDError::{JsonParse, PacketBad},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
use std::net::SocketAddr;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
bufferer::{Bufferer, Endianess},
|
bufferer::{Bufferer, Endianess},
|
||||||
protocols::{
|
protocols::{
|
||||||
|
|
@ -10,6 +9,7 @@ use crate::{
|
||||||
GDError::{PacketBad, ProtocolFormat},
|
GDError::{PacketBad, ProtocolFormat},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
pub struct LegacyBV1_8 {
|
pub struct LegacyBV1_8 {
|
||||||
socket: TcpSocket,
|
socket: TcpSocket,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
use std::net::SocketAddr;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
bufferer::{Bufferer, Endianess},
|
bufferer::{Bufferer, Endianess},
|
||||||
protocols::{
|
protocols::{
|
||||||
|
|
@ -10,6 +9,7 @@ use crate::{
|
||||||
GDError::{PacketBad, ProtocolFormat},
|
GDError::{PacketBad, ProtocolFormat},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
pub struct LegacyV1_4 {
|
pub struct LegacyV1_4 {
|
||||||
socket: TcpSocket,
|
socket: TcpSocket,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
use std::net::SocketAddr;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
bufferer::{Bufferer, Endianess},
|
bufferer::{Bufferer, Endianess},
|
||||||
protocols::{
|
protocols::{
|
||||||
|
|
@ -10,6 +9,7 @@ use crate::{
|
||||||
GDError::{PacketBad, ProtocolFormat},
|
GDError::{PacketBad, ProtocolFormat},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
pub struct LegacyV1_6 {
|
pub struct LegacyV1_6 {
|
||||||
socket: TcpSocket,
|
socket: TcpSocket,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
use std::net::SocketAddr;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::minecraft::{
|
protocols::minecraft::{
|
||||||
protocol::{
|
protocol::{
|
||||||
|
|
@ -16,6 +15,7 @@ use crate::{
|
||||||
GDError::AutoQuery,
|
GDError::AutoQuery,
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
mod bedrock;
|
mod bedrock;
|
||||||
mod java;
|
mod java;
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@
|
||||||
pub mod gamespy;
|
pub mod gamespy;
|
||||||
/// Reference: [Server List Ping](https://wiki.vg/Server_List_Ping)
|
/// Reference: [Server List Ping](https://wiki.vg/Server_List_Ping)
|
||||||
pub mod minecraft;
|
pub mod minecraft;
|
||||||
|
/// Reference: [node-GameDig](https://github.com/gamedig/node-gamedig/blob/master/protocols/quake1.js)
|
||||||
|
pub mod quake;
|
||||||
/// General types that are used by all protocols.
|
/// General types that are used by all protocols.
|
||||||
pub mod types;
|
pub mod types;
|
||||||
/// Reference: [Server Query](https://developer.valvesoftware.com/wiki/Server_queries)
|
/// Reference: [Server Query](https://developer.valvesoftware.com/wiki/Server_queries)
|
||||||
pub mod valve;
|
pub mod valve;
|
||||||
/// Reference: [node-GameDig](https://github.com/gamedig/node-gamedig/blob/master/protocols/quake1.js)
|
|
||||||
pub mod quake;
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::net::SocketAddr;
|
|
||||||
use std::slice::Iter;
|
|
||||||
use crate::bufferer::{Bufferer, Endianess};
|
use crate::bufferer::{Bufferer, Endianess};
|
||||||
use crate::{GDError, GDResult};
|
|
||||||
use crate::protocols::quake::types::Response;
|
use crate::protocols::quake::types::Response;
|
||||||
use crate::protocols::types::TimeoutSettings;
|
use crate::protocols::types::TimeoutSettings;
|
||||||
use crate::socket::{Socket, UdpSocket};
|
use crate::socket::{Socket, UdpSocket};
|
||||||
|
use crate::{GDError, GDResult};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::net::SocketAddr;
|
||||||
|
use std::slice::Iter;
|
||||||
|
|
||||||
pub(crate) trait QuakeClient {
|
pub(crate) trait QuakeClient {
|
||||||
type Player;
|
type Player;
|
||||||
|
|
@ -15,11 +15,21 @@ pub(crate) trait QuakeClient {
|
||||||
fn parse_player_string(data: Iter<&str>) -> GDResult<Self::Player>;
|
fn parse_player_string(data: Iter<&str>) -> GDResult<Self::Player>;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_data<Client: QuakeClient>(address: &SocketAddr, timeout_settings: Option<TimeoutSettings>) -> GDResult<Bufferer> {
|
fn get_data<Client: QuakeClient>(
|
||||||
|
address: &SocketAddr,
|
||||||
|
timeout_settings: Option<TimeoutSettings>,
|
||||||
|
) -> GDResult<Bufferer> {
|
||||||
let mut socket = UdpSocket::new(address)?;
|
let mut socket = UdpSocket::new(address)?;
|
||||||
socket.apply_timeout(timeout_settings)?;
|
socket.apply_timeout(timeout_settings)?;
|
||||||
|
|
||||||
socket.send(&[&[0xFF, 0xFF, 0xFF, 0xFF], Client::get_send_header().as_bytes(), &[0x00]].concat())?;
|
socket.send(
|
||||||
|
&[
|
||||||
|
&[0xFF, 0xFF, 0xFF, 0xFF],
|
||||||
|
Client::get_send_header().as_bytes(),
|
||||||
|
&[0x00],
|
||||||
|
]
|
||||||
|
.concat(),
|
||||||
|
)?;
|
||||||
|
|
||||||
let data = socket.receive(None)?;
|
let data = socket.receive(None)?;
|
||||||
let mut bufferer = Bufferer::new_with_data(Endianess::Little, &data);
|
let mut bufferer = Bufferer::new_with_data(Endianess::Little, &data);
|
||||||
|
|
@ -78,27 +88,34 @@ fn get_players<Client: QuakeClient>(bufferer: &mut Bufferer) -> GDResult<Vec<Cli
|
||||||
Ok(players)
|
Ok(players)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn client_query<Client: QuakeClient>(address: &SocketAddr, timeout_settings: Option<TimeoutSettings>) -> GDResult<Response<Client::Player>> {
|
pub(crate) fn client_query<Client: QuakeClient>(
|
||||||
|
address: &SocketAddr,
|
||||||
|
timeout_settings: Option<TimeoutSettings>,
|
||||||
|
) -> GDResult<Response<Client::Player>> {
|
||||||
let mut bufferer = get_data::<Client>(address, timeout_settings)?;
|
let mut bufferer = get_data::<Client>(address, timeout_settings)?;
|
||||||
|
|
||||||
let mut server_vars = get_server_values(&mut bufferer)?;
|
let mut server_vars = get_server_values(&mut bufferer)?;
|
||||||
let players = get_players::<Client>(&mut bufferer)?;
|
let players = get_players::<Client>(&mut bufferer)?;
|
||||||
|
|
||||||
Ok(Response {
|
Ok(Response {
|
||||||
name: server_vars.remove("hostname")
|
name: server_vars
|
||||||
|
.remove("hostname")
|
||||||
.or(server_vars.remove("sv_hostname"))
|
.or(server_vars.remove("sv_hostname"))
|
||||||
.ok_or(GDError::PacketBad)?,
|
.ok_or(GDError::PacketBad)?,
|
||||||
map: server_vars.remove("mapname")
|
map: server_vars
|
||||||
|
.remove("mapname")
|
||||||
.or(server_vars.remove("map"))
|
.or(server_vars.remove("map"))
|
||||||
.ok_or(GDError::PacketBad)?,
|
.ok_or(GDError::PacketBad)?,
|
||||||
players_online: players.len() as u8,
|
players_online: players.len() as u8,
|
||||||
players_maximum: server_vars.remove("maxclients")
|
players_maximum: server_vars
|
||||||
|
.remove("maxclients")
|
||||||
.or(server_vars.remove("sv_maxclients"))
|
.or(server_vars.remove("sv_maxclients"))
|
||||||
.ok_or(GDError::PacketBad)?
|
.ok_or(GDError::PacketBad)?
|
||||||
.parse()
|
.parse()
|
||||||
.map_err(|_| GDError::TypeParse)?,
|
.map_err(|_| GDError::TypeParse)?,
|
||||||
players,
|
players,
|
||||||
version: server_vars.remove("version")
|
version: server_vars
|
||||||
|
.remove("version")
|
||||||
.or(server_vars.remove("*version"))
|
.or(server_vars.remove("*version"))
|
||||||
.ok_or(GDError::PacketBad)?,
|
.ok_or(GDError::PacketBad)?,
|
||||||
unused_entries: server_vars,
|
unused_entries: server_vars,
|
||||||
|
|
@ -108,6 +125,6 @@ pub(crate) fn client_query<Client: QuakeClient>(address: &SocketAddr, timeout_se
|
||||||
pub(crate) fn remove_wrapping_quotes<'a>(string: &&'a str) -> &'a str {
|
pub(crate) fn remove_wrapping_quotes<'a>(string: &&'a str) -> &'a str {
|
||||||
match string.starts_with('\"') && string.ends_with('\"') {
|
match string.starts_with('\"') && string.ends_with('\"') {
|
||||||
false => string,
|
false => string,
|
||||||
true => &string[1..string.len() - 1]
|
true => &string[1 .. string.len() - 1],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
|
|
||||||
pub mod one;
|
pub mod one;
|
||||||
pub mod two;
|
|
||||||
pub mod three;
|
pub mod three;
|
||||||
|
pub mod two;
|
||||||
|
|
||||||
/// All types used by the implementation.
|
/// All types used by the implementation.
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
use std::net::SocketAddr;
|
use crate::protocols::quake::client::{client_query, remove_wrapping_quotes, QuakeClient};
|
||||||
use std::slice::Iter;
|
|
||||||
use crate::{GDError, GDResult};
|
|
||||||
use crate::protocols::quake::Response;
|
use crate::protocols::quake::Response;
|
||||||
use crate::protocols::quake::client::{QuakeClient, client_query, remove_wrapping_quotes};
|
|
||||||
use crate::protocols::types::TimeoutSettings;
|
use crate::protocols::types::TimeoutSettings;
|
||||||
|
use crate::{GDError, GDResult};
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::net::SocketAddr;
|
||||||
|
use std::slice::Iter;
|
||||||
|
|
||||||
/// Quake 1 player data.
|
/// Quake 1 player data.
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
|
@ -19,54 +19,50 @@ pub struct Player {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub skin: String,
|
pub skin: String,
|
||||||
pub color_primary: u8,
|
pub color_primary: u8,
|
||||||
pub color_secondary: u8
|
pub color_secondary: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct QuakeOne;
|
pub(crate) struct QuakeOne;
|
||||||
impl QuakeClient for QuakeOne {
|
impl QuakeClient for QuakeOne {
|
||||||
type Player = Player;
|
type Player = Player;
|
||||||
|
|
||||||
fn get_send_header<'a>() -> &'a str {
|
fn get_send_header<'a>() -> &'a str { "status" }
|
||||||
"status"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_response_header<'a>() -> &'a str {
|
fn get_response_header<'a>() -> &'a str { "n" }
|
||||||
"n"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn parse_player_string(mut data: Iter<&str>) -> GDResult<Self::Player> {
|
fn parse_player_string(mut data: Iter<&str>) -> GDResult<Self::Player> {
|
||||||
Ok(Player {
|
Ok(Player {
|
||||||
id: match data.next() {
|
id: match data.next() {
|
||||||
None => Err(GDError::PacketBad)?,
|
None => Err(GDError::PacketBad)?,
|
||||||
Some(v) => v.parse().map_err(|_| GDError::PacketBad)?
|
Some(v) => v.parse().map_err(|_| GDError::PacketBad)?,
|
||||||
},
|
},
|
||||||
score: match data.next() {
|
score: match data.next() {
|
||||||
None => Err(GDError::PacketBad)?,
|
None => Err(GDError::PacketBad)?,
|
||||||
Some(v) => v.parse().map_err(|_| GDError::PacketBad)?
|
Some(v) => v.parse().map_err(|_| GDError::PacketBad)?,
|
||||||
},
|
},
|
||||||
time: match data.next() {
|
time: match data.next() {
|
||||||
None => Err(GDError::PacketBad)?,
|
None => Err(GDError::PacketBad)?,
|
||||||
Some(v) => v.parse().map_err(|_| GDError::PacketBad)?
|
Some(v) => v.parse().map_err(|_| GDError::PacketBad)?,
|
||||||
},
|
},
|
||||||
ping: match data.next() {
|
ping: match data.next() {
|
||||||
None => Err(GDError::PacketBad)?,
|
None => Err(GDError::PacketBad)?,
|
||||||
Some(v) => v.parse().map_err(|_| GDError::PacketBad)?
|
Some(v) => v.parse().map_err(|_| GDError::PacketBad)?,
|
||||||
},
|
},
|
||||||
name: match data.next() {
|
name: match data.next() {
|
||||||
None => Err(GDError::PacketBad)?,
|
None => Err(GDError::PacketBad)?,
|
||||||
Some(v) => remove_wrapping_quotes(v).to_string()
|
Some(v) => remove_wrapping_quotes(v).to_string(),
|
||||||
},
|
},
|
||||||
skin: match data.next() {
|
skin: match data.next() {
|
||||||
None => Err(GDError::PacketBad)?,
|
None => Err(GDError::PacketBad)?,
|
||||||
Some(v) => remove_wrapping_quotes(v).to_string()
|
Some(v) => remove_wrapping_quotes(v).to_string(),
|
||||||
},
|
},
|
||||||
color_primary: match data.next() {
|
color_primary: match data.next() {
|
||||||
None => Err(GDError::PacketBad)?,
|
None => Err(GDError::PacketBad)?,
|
||||||
Some(v) => v.parse().map_err(|_| GDError::PacketBad)?
|
Some(v) => v.parse().map_err(|_| GDError::PacketBad)?,
|
||||||
},
|
},
|
||||||
color_secondary: match data.next() {
|
color_secondary: match data.next() {
|
||||||
None => Err(GDError::PacketBad)?,
|
None => Err(GDError::PacketBad)?,
|
||||||
Some(v) => v.parse().map_err(|_| GDError::PacketBad)?
|
Some(v) => v.parse().map_err(|_| GDError::PacketBad)?,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,20 @@
|
||||||
use std::net::SocketAddr;
|
use crate::protocols::quake::client::{client_query, QuakeClient};
|
||||||
use std::slice::Iter;
|
|
||||||
use crate::GDResult;
|
|
||||||
use crate::protocols::quake::two::{Player, QuakeTwo};
|
use crate::protocols::quake::two::{Player, QuakeTwo};
|
||||||
use crate::protocols::quake::Response;
|
use crate::protocols::quake::Response;
|
||||||
use crate::protocols::quake::client::{QuakeClient, client_query};
|
|
||||||
use crate::protocols::types::TimeoutSettings;
|
use crate::protocols::types::TimeoutSettings;
|
||||||
|
use crate::GDResult;
|
||||||
|
use std::net::SocketAddr;
|
||||||
|
use std::slice::Iter;
|
||||||
|
|
||||||
struct QuakeThree;
|
struct QuakeThree;
|
||||||
impl QuakeClient for QuakeThree {
|
impl QuakeClient for QuakeThree {
|
||||||
type Player = Player;
|
type Player = Player;
|
||||||
|
|
||||||
fn get_send_header<'a>() -> &'a str {
|
fn get_send_header<'a>() -> &'a str { "getstatus" }
|
||||||
"getstatus"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_response_header<'a>() -> &'a str {
|
fn get_response_header<'a>() -> &'a str { "statusResponse\n" }
|
||||||
"statusResponse\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn parse_player_string(data: Iter<&str>) -> GDResult<Self::Player> {
|
fn parse_player_string(data: Iter<&str>) -> GDResult<Self::Player> { QuakeTwo::parse_player_string(data) }
|
||||||
QuakeTwo::parse_player_string(data)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query(address: &SocketAddr, timeout_settings: Option<TimeoutSettings>) -> GDResult<Response<Player>> {
|
pub fn query(address: &SocketAddr, timeout_settings: Option<TimeoutSettings>) -> GDResult<Response<Player>> {
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
use std::net::SocketAddr;
|
use crate::protocols::quake::client::{client_query, remove_wrapping_quotes, QuakeClient};
|
||||||
use std::slice::Iter;
|
|
||||||
use crate::{GDError, GDResult};
|
|
||||||
use crate::protocols::quake::one::QuakeOne;
|
use crate::protocols::quake::one::QuakeOne;
|
||||||
use crate::protocols::quake::Response;
|
use crate::protocols::quake::Response;
|
||||||
use crate::protocols::quake::client::{QuakeClient, client_query, remove_wrapping_quotes};
|
|
||||||
use crate::protocols::types::TimeoutSettings;
|
use crate::protocols::types::TimeoutSettings;
|
||||||
|
use crate::{GDError, GDResult};
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::net::SocketAddr;
|
||||||
|
use std::slice::Iter;
|
||||||
|
|
||||||
/// Quake 2 player data.
|
/// Quake 2 player data.
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
|
@ -14,35 +14,31 @@ use serde::{Deserialize, Serialize};
|
||||||
pub struct Player {
|
pub struct Player {
|
||||||
pub frags: i16,
|
pub frags: i16,
|
||||||
pub ping: u16,
|
pub ping: u16,
|
||||||
pub name: String
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct QuakeTwo;
|
pub(crate) struct QuakeTwo;
|
||||||
impl QuakeClient for QuakeTwo {
|
impl QuakeClient for QuakeTwo {
|
||||||
type Player = Player;
|
type Player = Player;
|
||||||
|
|
||||||
fn get_send_header<'a>() -> &'a str {
|
fn get_send_header<'a>() -> &'a str { QuakeOne::get_send_header() }
|
||||||
QuakeOne::get_send_header()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_response_header<'a>() -> &'a str {
|
fn get_response_header<'a>() -> &'a str { "print\n" }
|
||||||
"print\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn parse_player_string(mut data: Iter<&str>) -> GDResult<Self::Player> {
|
fn parse_player_string(mut data: Iter<&str>) -> GDResult<Self::Player> {
|
||||||
Ok(Player {
|
Ok(Player {
|
||||||
frags: match data.next() {
|
frags: match data.next() {
|
||||||
None => Err(GDError::PacketBad)?,
|
None => Err(GDError::PacketBad)?,
|
||||||
Some(v) => v.parse().map_err(|_| GDError::PacketBad)?
|
Some(v) => v.parse().map_err(|_| GDError::PacketBad)?,
|
||||||
},
|
},
|
||||||
ping: match data.next() {
|
ping: match data.next() {
|
||||||
None => Err(GDError::PacketBad)?,
|
None => Err(GDError::PacketBad)?,
|
||||||
Some(v) => v.parse().map_err(|_| GDError::PacketBad)?
|
Some(v) => v.parse().map_err(|_| GDError::PacketBad)?,
|
||||||
},
|
},
|
||||||
name: match data.next() {
|
name: match data.next() {
|
||||||
None => Err(GDError::PacketBad)?,
|
None => Err(GDError::PacketBad)?,
|
||||||
Some(v) => remove_wrapping_quotes(v).to_string()
|
Some(v) => remove_wrapping_quotes(v).to_string(),
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::HashMap;
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
/// General server information's.
|
/// General server information's.
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
|
|
||||||
|
|
@ -418,12 +418,7 @@ pub fn query(
|
||||||
timeout_settings: Option<TimeoutSettings>,
|
timeout_settings: Option<TimeoutSettings>,
|
||||||
) -> GDResult<Response> {
|
) -> GDResult<Response> {
|
||||||
let response_gather_settings = gather_settings.unwrap_or_default();
|
let response_gather_settings = gather_settings.unwrap_or_default();
|
||||||
get_response(
|
get_response(address, engine, response_gather_settings, timeout_settings)
|
||||||
address,
|
|
||||||
engine,
|
|
||||||
response_gather_settings,
|
|
||||||
timeout_settings,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_response(
|
fn get_response(
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,12 @@ impl ValveMasterServer {
|
||||||
|
|
||||||
let mut ips: Vec<(IpAddr, u16)> = Vec::new();
|
let mut ips: Vec<(IpAddr, u16)> = Vec::new();
|
||||||
while buf.remaining_length() > 0 {
|
while buf.remaining_length() > 0 {
|
||||||
let ip = IpAddr::V4(Ipv4Addr::new(buf.get_u8()?, buf.get_u8()?, buf.get_u8()?, buf.get_u8()?));
|
let ip = IpAddr::V4(Ipv4Addr::new(
|
||||||
|
buf.get_u8()?,
|
||||||
|
buf.get_u8()?,
|
||||||
|
buf.get_u8()?,
|
||||||
|
buf.get_u8()?,
|
||||||
|
));
|
||||||
let port = buf.get_u16()?;
|
let port = buf.get_u16()?;
|
||||||
|
|
||||||
ips.push((ip, port));
|
ips.push((ip, port));
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@ pub enum Filter {
|
||||||
HasTags(Vec<String>),
|
HasTags(Vec<String>),
|
||||||
MatchName(String),
|
MatchName(String),
|
||||||
MatchVersion(String),
|
MatchVersion(String),
|
||||||
/// Restrict to only a server if an IP hosts (on different ports) multiple servers.
|
/// Restrict to only a server if an IP hosts (on different ports) multiple
|
||||||
|
/// servers.
|
||||||
RestrictUniqueIP(bool),
|
RestrictUniqueIP(bool),
|
||||||
/// Query for servers on a specific address.
|
/// Query for servers on a specific address.
|
||||||
OnAddress(String),
|
OnAddress(String),
|
||||||
|
|
@ -133,7 +134,8 @@ impl Filter {
|
||||||
/// .insert(Filter::IsEmpty(false))
|
/// .insert(Filter::IsEmpty(false))
|
||||||
/// .insert(Filter::CanHavePassword(false));
|
/// .insert(Filter::CanHavePassword(false));
|
||||||
/// ```
|
/// ```
|
||||||
/// This will construct filters that search for servers that can't have a password, are not empty and run App ID 440.
|
/// This will construct filters that search for servers that can't have a
|
||||||
|
/// password, are not empty and run App ID 440.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct SearchFilters {
|
pub struct SearchFilters {
|
||||||
filters: HashMap<Discriminant<Filter>, Filter>,
|
filters: HashMap<Discriminant<Filter>, Filter>,
|
||||||
|
|
@ -208,8 +210,14 @@ impl SearchFilters {
|
||||||
bytes.extend(filter.to_bytes())
|
bytes.extend(filter.to_bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes.extend(SearchFilters::special_filter_to_bytes("nand", &self.nand_filters));
|
bytes.extend(SearchFilters::special_filter_to_bytes(
|
||||||
bytes.extend(SearchFilters::special_filter_to_bytes("nor", &self.nor_filters));
|
"nand",
|
||||||
|
&self.nand_filters,
|
||||||
|
));
|
||||||
|
bytes.extend(SearchFilters::special_filter_to_bytes(
|
||||||
|
"nor",
|
||||||
|
&self.nor_filters,
|
||||||
|
));
|
||||||
|
|
||||||
bytes.extend([0x00]);
|
bytes.extend([0x00]);
|
||||||
bytes
|
bytes
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@ use crate::{
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use std::net::SocketAddr;
|
||||||
use std::{
|
use std::{
|
||||||
io::{Read, Write},
|
io::{Read, Write},
|
||||||
net,
|
net,
|
||||||
};
|
};
|
||||||
use std::net::SocketAddr;
|
|
||||||
|
|
||||||
const DEFAULT_PACKET_SIZE: usize = 1024;
|
const DEFAULT_PACKET_SIZE: usize = 1024;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue