mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +00:00
Removed examples, added a master_querant change gather_settings to none (representing all)
This commit is contained in:
parent
83bbd5d428
commit
88a4c82158
28 changed files with 83 additions and 176 deletions
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{GDResult, valve};
|
||||
use crate::valve::{ValveProtocol, App, GatheringSettings, Server, ServerRule, ServerPlayer};
|
||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Player {
|
||||
|
|
@ -74,10 +74,7 @@ pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
|||
let valve_response = ValveProtocol::query(App::ALIENS, address, match port {
|
||||
None => 27015,
|
||||
Some(port) => port
|
||||
}, GatheringSettings {
|
||||
players: true,
|
||||
rules: true
|
||||
})?;
|
||||
}, None)?;
|
||||
|
||||
Ok(Response::new_from_valve_response(valve_response))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{GDResult, valve};
|
||||
use crate::valve::{ValveProtocol, App, GatheringSettings, Server, ServerRule, ServerPlayer};
|
||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Player {
|
||||
|
|
@ -74,10 +74,7 @@ pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
|||
let valve_response = ValveProtocol::query(App::ASRD, address, match port {
|
||||
None => 27015,
|
||||
Some(port) => port
|
||||
}, GatheringSettings {
|
||||
players: true,
|
||||
rules: true
|
||||
})?;
|
||||
}, None)?;
|
||||
|
||||
Ok(Response::new_from_valve_response(valve_response))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,10 +72,10 @@ pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
|||
let valve_response = ValveProtocol::query(App::CSGO, address, match port {
|
||||
None => 27015,
|
||||
Some(port) => port
|
||||
}, GatheringSettings {
|
||||
}, Some(GatheringSettings {
|
||||
players: true,
|
||||
rules: false // cause csgo doesnt reply with rules anymore
|
||||
})?;
|
||||
}))?;
|
||||
|
||||
Ok(Response::new_from_valve_response(valve_response))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{GDResult, valve};
|
||||
use crate::valve::{ValveProtocol, App, GatheringSettings, Server, ServerRule, ServerPlayer};
|
||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Player {
|
||||
|
|
@ -74,10 +74,7 @@ pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
|||
let valve_response = ValveProtocol::query(App::CSS, address, match port {
|
||||
None => 27015,
|
||||
Some(port) => port
|
||||
}, GatheringSettings {
|
||||
players: true,
|
||||
rules: true
|
||||
})?;
|
||||
}, None)?;
|
||||
|
||||
Ok(Response::new_from_valve_response(valve_response))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{GDResult, valve};
|
||||
use crate::valve::{ValveProtocol, App, GatheringSettings, Server, ServerRule, ServerPlayer};
|
||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Player {
|
||||
|
|
@ -74,10 +74,7 @@ pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
|||
let valve_response = ValveProtocol::query(App::DODS, address, match port {
|
||||
None => 27015,
|
||||
Some(port) => port
|
||||
}, GatheringSettings {
|
||||
players: true,
|
||||
rules: true
|
||||
})?;
|
||||
}, None)?;
|
||||
|
||||
Ok(Response::new_from_valve_response(valve_response))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{GDResult, valve};
|
||||
use crate::valve::{ValveProtocol, App, GatheringSettings, Server, ServerRule, ServerPlayer};
|
||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Player {
|
||||
|
|
@ -74,10 +74,7 @@ pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
|||
let valve_response = ValveProtocol::query(App::GM, address, match port {
|
||||
None => 27015,
|
||||
Some(port) => port
|
||||
}, GatheringSettings {
|
||||
players: true,
|
||||
rules: true
|
||||
})?;
|
||||
}, None)?;
|
||||
|
||||
Ok(Response::new_from_valve_response(valve_response))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{GDResult, valve};
|
||||
use crate::valve::{ValveProtocol, App, GatheringSettings, Server, ServerRule, ServerPlayer};
|
||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Player {
|
||||
|
|
@ -74,10 +74,7 @@ pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
|||
let valve_response = ValveProtocol::query(App::HL2DM, address, match port {
|
||||
None => 27015,
|
||||
Some(port) => port
|
||||
}, GatheringSettings {
|
||||
players: true,
|
||||
rules: true
|
||||
})?;
|
||||
}, None)?;
|
||||
|
||||
Ok(Response::new_from_valve_response(valve_response))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{GDResult, valve};
|
||||
use crate::valve::{ValveProtocol, App, GatheringSettings, Server, ServerRule, ServerPlayer};
|
||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Player {
|
||||
|
|
@ -74,10 +74,7 @@ pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
|||
let valve_response = ValveProtocol::query(App::INS, address, match port {
|
||||
None => 27015,
|
||||
Some(port) => port
|
||||
}, GatheringSettings {
|
||||
players: true,
|
||||
rules: true
|
||||
})?;
|
||||
}, None)?;
|
||||
|
||||
Ok(Response::new_from_valve_response(valve_response))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{GDResult, valve};
|
||||
use crate::valve::{ValveProtocol, App, GatheringSettings, Server, ServerRule, ServerPlayer};
|
||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Player {
|
||||
|
|
@ -74,10 +74,7 @@ pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
|||
let valve_response = ValveProtocol::query(App::INSS, address, match port {
|
||||
None => 27131,
|
||||
Some(port) => port
|
||||
}, GatheringSettings {
|
||||
players: true,
|
||||
rules: true
|
||||
})?;
|
||||
}, None)?;
|
||||
|
||||
Ok(Response::new_from_valve_response(valve_response))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{GDResult, valve};
|
||||
use crate::valve::{ValveProtocol, App, GatheringSettings, Server, ServerRule, ServerPlayer};
|
||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Player {
|
||||
|
|
@ -74,10 +74,7 @@ pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
|||
let valve_response = ValveProtocol::query(App::L4D, address, match port {
|
||||
None => 27015,
|
||||
Some(port) => port
|
||||
}, GatheringSettings {
|
||||
players: true,
|
||||
rules: true
|
||||
})?;
|
||||
}, None)?;
|
||||
|
||||
Ok(Response::new_from_valve_response(valve_response))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{GDResult, valve};
|
||||
use crate::valve::{ValveProtocol, App, GatheringSettings, Server, ServerRule, ServerPlayer};
|
||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Player {
|
||||
|
|
@ -74,10 +74,7 @@ pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
|||
let valve_response = ValveProtocol::query(App::L4D2, address, match port {
|
||||
None => 27015,
|
||||
Some(port) => port
|
||||
}, GatheringSettings {
|
||||
players: true,
|
||||
rules: true
|
||||
})?;
|
||||
}, None)?;
|
||||
|
||||
Ok(Response::new_from_valve_response(valve_response))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{GDResult, valve};
|
||||
use crate::valve::{ValveProtocol, App, GatheringSettings, Server, ServerRule, ServerPlayer};
|
||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Player {
|
||||
|
|
@ -74,10 +74,7 @@ pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
|||
let valve_response = ValveProtocol::query(App::TF2, address, match port {
|
||||
None => 27015,
|
||||
Some(port) => port
|
||||
}, GatheringSettings {
|
||||
players: true,
|
||||
rules: true
|
||||
})?;
|
||||
}, None)?;
|
||||
|
||||
Ok(Response::new_from_valve_response(valve_response))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{GDResult, valve};
|
||||
use crate::valve::{ValveProtocol, App, GatheringSettings, ServerPlayer, Server, ServerRule};
|
||||
use crate::valve::{ValveProtocol, App, ServerPlayer, Server, ServerRule};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Player {
|
||||
|
|
@ -86,10 +86,7 @@ pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
|||
let valve_response = ValveProtocol::query(App::TS, address, match port {
|
||||
None => 27015,
|
||||
Some(port) => port
|
||||
}, GatheringSettings {
|
||||
players: true,
|
||||
rules: true
|
||||
})?;
|
||||
}, None)?;
|
||||
|
||||
Ok(Response::new_from_valve_response(valve_response))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -499,7 +499,8 @@ impl ValveProtocol {
|
|||
Ok(Some(rules))
|
||||
}
|
||||
|
||||
pub(crate) fn query(app: App, address: &str, port: u16, gather: GatheringSettings) -> Result<Response, GDError> {
|
||||
/// Query any app.
|
||||
pub fn query(app: App, address: &str, port: u16, gather_settings: Option<GatheringSettings>) -> Result<Response, GDError> {
|
||||
let client = ValveProtocol::new(address, port)?;
|
||||
|
||||
let info = client.get_server_info(&app)?;
|
||||
|
|
@ -509,13 +510,21 @@ impl ValveProtocol {
|
|||
return Err(GDError::BadGame(format!("Expected {}, found {} instead!", query_app_id, info.appid)));
|
||||
}
|
||||
|
||||
let (gather_players, gather_rules) = match gather_settings.is_some() {
|
||||
false => (true, true),
|
||||
true => {
|
||||
let settings = gather_settings.unwrap();
|
||||
(settings.players, settings.rules)
|
||||
}
|
||||
};
|
||||
|
||||
Ok(Response {
|
||||
info,
|
||||
players: match gather.players {
|
||||
players: match gather_players {
|
||||
false => None,
|
||||
true => Some(client.get_server_players(&app)?)
|
||||
},
|
||||
rules: match gather.rules {
|
||||
rules: match gather_rules {
|
||||
false => None,
|
||||
true => client.get_server_rules(&app)?
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue