diff --git a/CHANGELOG.md b/CHANGELOG.md index e9188b5..07d57cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,11 @@ Who knows what the future holds... # 0.0.4 - ??/??/???? Queries now support DNS resolve. -[Alien Swarm](https://store.steampowered.com/app/630/Alien_Swarm/) implementation. +[Alien Swarm](https://store.steampowered.com/app/630/Alien_Swarm/) implementation (not tested). [Alien Swarm: Reactive Drop](https://store.steampowered.com/app/563560/Alien_Swarm_Reactive_Drop/) implementation. [Insurgency](https://store.steampowered.com/app/222880/Insurgency/) implementation. [Insurgency: Sandstorm](https://store.steampowered.com/app/581320/Insurgency_Sandstorm/) implementation. +[Insurgency: Modern Infantry Combat](https://store.steampowered.com/app/17700/INSURGENCY_Modern_Infantry_Combat/) implementation (not tested). # 0.0.3 - 22/10/2022 Valve protocol now properly supports multi-packet responses (compressed ones not tested). diff --git a/GAMES.md b/GAMES.md index 925aa2d..a332f47 100644 --- a/GAMES.md +++ b/GAMES.md @@ -1,19 +1,20 @@ # Supported games: -| ID | Name | Protocol | Notes | -|--------|-------------------------------------|----------------|------------------------------------------------------------------------------| -| TF2 | Team Fortress 2 | Valve Protocol | | -| TS | The Ship | Valve Protocol | | -| CSGO | Counter-Strike: Global Offensive | Valve Protocol | The server wouldn't respond the to Rules query since the 21 Feb 2014 update. | -| CSS | Counter-Strike: Source | Valve Protocol | If protocol is 7, queries with multi-packet responses will crash. | -| DODS | Day of Defeat: Source | Valve Protocol | | -| L4D | Left 4 Dead | Valve Protocol | | -| L4D2 | Left 4 Dead 2 | Valve Protocol | | -| HL2DM | Half-Life 2 Deathmatch | Valve Protocol | | -| ALIENS | Alien Swarm | Valve Protocol | Not tested. | -| ASRD | Alien Swarm: Reactive Drop | Valve Protocol | | -| INS | Insurgency | Valve Protocol | | -| INSS | Insurgency: Sandstorm | Valve Protocol | Here you need to use the query port, not the server port. | +| ID | Name | Protocol | Notes | +|--------|------------------------------------|----------------|------------------------------------------------------------------------------| +| TF2 | Team Fortress 2 | Valve Protocol | | +| TS | The Ship | Valve Protocol | | +| CSGO | Counter-Strike: Global Offensive | Valve Protocol | The server wouldn't respond the to Rules query since the 21 Feb 2014 update. | +| CSS | Counter-Strike: Source | Valve Protocol | If protocol is 7, queries with multi-packet responses will crash. | +| DODS | Day of Defeat: Source | Valve Protocol | | +| L4D | Left 4 Dead | Valve Protocol | | +| L4D2 | Left 4 Dead 2 | Valve Protocol | | +| HL2DM | Half-Life 2 Deathmatch | Valve Protocol | | +| ALIENS | Alien Swarm | Valve Protocol | Not tested. | +| ASRD | Alien Swarm: Reactive Drop | Valve Protocol | | +| INS | Insurgency | Valve Protocol | | +| INSS | Insurgency: Sandstorm | Valve Protocol | Here you need to use the query port, not the server port. | +| INSMIC | Insurgency: Modern Infantry Combat | Valve Protocol | Not tested. | ## Planned to add support: All Valve titles. diff --git a/PROTOCOLS.md b/PROTOCOLS.md index a729dab..c83528f 100644 --- a/PROTOCOLS.md +++ b/PROTOCOLS.md @@ -1,8 +1,8 @@ # Supported protocols: -| Name | Documentation reference | Used by | Notes | -|----------------|---------------------------------------------------------------------------|--------------------------------------------------------------|----------------------------------------| -| Valve Protocol | [Server Queries](https://developer.valvesoftware.com/wiki/Server_queries) | TF2, CSGO, TS, CSS, DODS, GM, HL2DM, L4D, L4D2, ALIENS, ASRD | Multi-packet decompression not tested. | +| Name | Documentation reference | Used by | Notes | +|----------------|---------------------------------------------------------------------------|---------------------------------------------------------------------------------|----------------------------------------| +| Valve Protocol | [Server Queries](https://developer.valvesoftware.com/wiki/Server_queries) | TF2, CSGO, TS, CSS, DODS, GM, HL2DM, L4D, L4D2, ALIENS, ASRD, INS, INSS, INSMIC | Multi-packet decompression not tested. | ## Planned to add support: Minecraft protocol diff --git a/examples/master_querant.rs b/examples/master_querant.rs index 7be4b89..61012f2 100644 --- a/examples/master_querant.rs +++ b/examples/master_querant.rs @@ -1,6 +1,6 @@ use std::env; -use gamedig::{aliens, asrd, csgo, css, dods, gm, hl2dm, ins, inss, l4d, l4d2, tf2, ts}; +use gamedig::{aliens, asrd, csgo, css, dods, gm, hl2dm, ins, insmic, inss, l4d, l4d2, tf2, ts}; fn main() { let args: Vec = env::args().collect(); @@ -31,6 +31,7 @@ fn main() { "gm" => println!("{:?}", gm::query(ip, port)), "hl2dm" => println!("{:?}", hl2dm::query(ip, port)), "tf2" => println!("{:?}", tf2::query(ip, port)), + "insmic" => println!("{:?}", insmic::query(ip, port)), "ins" => println!("{:?}", ins::query(ip, port)), "inss" => println!("{:?}", inss::query(ip, port)), "l4d" => println!("{:?}", l4d::query(ip, port)), diff --git a/src/games/insmic.rs b/src/games/insmic.rs new file mode 100644 index 0000000..6e35caf --- /dev/null +++ b/src/games/insmic.rs @@ -0,0 +1,80 @@ +use crate::{GDResult, valve}; +use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer}; + +#[derive(Debug)] +pub struct Player { + pub name: String, + pub score: u32, + pub duration: f32 +} + +impl Player { + fn from_valve_response(player: &ServerPlayer) -> Self { + Self { + name: player.name.clone(), + score: player.score, + duration: player.duration + } + } +} + +#[derive(Debug)] +pub struct Response { + pub protocol: u8, + pub name: String, + pub map: String, + pub game: String, + pub players: u8, + pub players_details: Vec, + pub max_players: u8, + pub bots: u8, + pub server_type: Server, + pub has_password: bool, + pub vac_secured: bool, + pub version: String, + pub port: Option, + pub steam_id: Option, + pub tv_port: Option, + pub tv_name: Option, + pub keywords: Option, + pub rules: Vec +} + +impl Response { + pub fn new_from_valve_response(response: valve::Response) -> Self { + let (port, steam_id, tv_port, tv_name, keywords) = match response.info.extra_data { + None => (None, None, None, None, None), + Some(ed) => (ed.port, ed.steam_id, ed.tv_port, ed.tv_name, ed.keywords) + }; + + Self { + protocol: response.info.protocol, + name: response.info.name, + map: response.info.map, + game: response.info.game, + players: response.info.players, + players_details: response.players.unwrap().iter().map(|p| Player::from_valve_response(p)).collect(), + max_players: response.info.max_players, + bots: response.info.bots, + server_type: response.info.server_type, + has_password: response.info.has_password, + vac_secured: response.info.vac_secured, + version: response.info.version, + port, + steam_id, + tv_port, + tv_name, + keywords, + rules: response.rules.unwrap() + } + } +} + +pub fn query(address: &str, port: Option) -> GDResult { + let valve_response = ValveProtocol::query(App::INSMIC, address, match port { + None => 27015, + Some(port) => port + }, None)?; + + Ok(Response::new_from_valve_response(valve_response)) +} diff --git a/src/games/mod.rs b/src/games/mod.rs index 4dd9dcc..f9f48c9 100644 --- a/src/games/mod.rs +++ b/src/games/mod.rs @@ -27,3 +27,5 @@ pub mod asrd; pub mod ins; /// Insurgency: Sandstorm pub mod inss; +/// Insurgency: Modern Infantry Combat +pub mod insmic; diff --git a/src/protocols/valve.rs b/src/protocols/valve.rs index 053bed6..30cfc72 100644 --- a/src/protocols/valve.rs +++ b/src/protocols/valve.rs @@ -146,6 +146,8 @@ pub enum App { TS = 2400, /// Garry's Mod GM = 4000, + /// Insurgency: Modern Infantry Combat + INSMIC = 17700, /// Insurgency INS = 222880, /// Insurgency: Sandstorm