mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-05-06 15:27:28 +00:00
[Protocol] Add PROPRIETARY to protocol enumeration (#59)
* [Protocol] Add CUSTOM to protocol enumeration * [Protocol] Rename CUSTOM to PROPRIETARY * [Protocol] Rename struct to ProprietaryProtocol and do the same thing to generic response * [Protocol] Revert proprietary change on generic response
This commit is contained in:
parent
b368877031
commit
c55254aaf6
3 changed files with 22 additions and 11 deletions
|
|
@ -9,6 +9,7 @@ use crate::protocols::{
|
|||
};
|
||||
use crate::Game;
|
||||
|
||||
use crate::protocols::types::ProprietaryProtocol;
|
||||
use phf::{phf_map, Map};
|
||||
|
||||
macro_rules! game {
|
||||
|
|
@ -51,7 +52,7 @@ pub static GAMES: Map<&'static str, Game> = phf_map! {
|
|||
"dods" => game!("Day of Defeat: Source", 27015, Protocol::Valve(SteamApp::DODS)),
|
||||
"doi" => game!("Day of Infamy", 27015, Protocol::Valve(SteamApp::DOI)),
|
||||
"dst" => game!("Don't Starve Together", 27016, Protocol::Valve(SteamApp::DST)),
|
||||
"ffow" => game!("Frontlines: Fuel of War", 5478, Protocol::FFOW),
|
||||
"ffow" => game!("Frontlines: Fuel of War", 5478, Protocol::PROPRIETARY(ProprietaryProtocol::FFOW)),
|
||||
"gm" => game!("Garry's Mod", 27016, Protocol::Valve(SteamApp::GM)),
|
||||
"hl2dm" => game!("Half-Life 2 Deathmatch", 27015, Protocol::Valve(SteamApp::HL2DM)),
|
||||
"haloce" => game!("Halo: Combat Evolved", 2302, Protocol::Gamespy(GameSpyVersion::Two)),
|
||||
|
|
@ -77,9 +78,9 @@ pub static GAMES: Map<&'static str, Game> = phf_map! {
|
|||
"tf" => game!("The Forest", 27016, Protocol::Valve(SteamApp::TF)),
|
||||
"tf2" => game!("Team Fortress 2", 27015, Protocol::Valve(SteamApp::TF2)),
|
||||
"tfc" => game!("Team Fortress Classic", 27015, Protocol::Valve(SteamApp::TFC)),
|
||||
"ts" => game!("The Ship", 27015, Protocol::TheShip),
|
||||
"ts" => game!("The Ship", 27015, Protocol::PROPRIETARY(ProprietaryProtocol::TheShip)),
|
||||
"unturned" => game!("Unturned", 27015, Protocol::Valve(SteamApp::UNTURNED)),
|
||||
"ut" => game!("Unreal Tournament", 7778, Protocol::Gamespy(GameSpyVersion::One)),
|
||||
"vr" => game!("V Rising", 27016, Protocol::Valve(SteamApp::VR)),
|
||||
"jc2mp" => game!("Just Cause 2: Multiplayer", 7777, Protocol::JC2MP),
|
||||
"jc2mp" => game!("Just Cause 2: Multiplayer", 7777, Protocol::PROPRIETARY(ProprietaryProtocol::JC2MP)),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ pub mod vr;
|
|||
|
||||
use crate::protocols::gamespy::GameSpyVersion;
|
||||
use crate::protocols::quake::QuakeVersion;
|
||||
use crate::protocols::types::CommonResponse;
|
||||
use crate::protocols::types::{CommonResponse, ProprietaryProtocol};
|
||||
use crate::protocols::{self, Protocol};
|
||||
use crate::GDResult;
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
|
|
@ -172,8 +172,12 @@ pub fn query(game: &Game, address: &IpAddr, port: Option<u16>) -> GDResult<Box<d
|
|||
QuakeVersion::Three => protocols::quake::three::query(&socket_addr, None).map(Box::new)?,
|
||||
}
|
||||
}
|
||||
Protocol::TheShip => ts::query(address, port).map(Box::new)?,
|
||||
Protocol::FFOW => ffow::query(address, port).map(Box::new)?,
|
||||
Protocol::JC2MP => jc2mp::query(address, port).map(Box::new)?,
|
||||
Protocol::PROPRIETARY(protocol) => {
|
||||
match protocol {
|
||||
ProprietaryProtocol::TheShip => ts::query(address, port).map(Box::new)?,
|
||||
ProprietaryProtocol::FFOW => ffow::query(address, port).map(Box::new)?,
|
||||
ProprietaryProtocol::JC2MP => jc2mp::query(address, port).map(Box::new)?,
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,15 @@ use std::time::Duration;
|
|||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Enumeration of all custom protocols
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum ProprietaryProtocol {
|
||||
TheShip,
|
||||
FFOW,
|
||||
JC2MP,
|
||||
}
|
||||
|
||||
/// Enumeration of all valid protocol types
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
|
|
@ -15,10 +24,7 @@ pub enum Protocol {
|
|||
Quake(quake::QuakeVersion),
|
||||
Valve(valve::SteamApp),
|
||||
#[cfg(not(feature = "no_games"))]
|
||||
TheShip,
|
||||
#[cfg(not(feature = "no_games"))]
|
||||
FFOW,
|
||||
JC2MP,
|
||||
PROPRIETARY(ProprietaryProtocol),
|
||||
}
|
||||
|
||||
/// All response types
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue