vapored: Use GetCMListForConnect
This commit is contained in:
parent
ba92101e06
commit
4207832545
|
@ -28,30 +28,46 @@ use crate::message::{CMProtoBufMessage, CMRawProtoBufMessage};
|
||||||
const CHANNEL_CAPACITY: usize = 16;
|
const CHANNEL_CAPACITY: usize = 16;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct GetCMListResult<'a> {
|
struct CMServerEntry<'a> {
|
||||||
// No need to check servers, we're only implementing websockets
|
endpoint: &'a str,
|
||||||
serverlist_websockets: BTreeMap<u32, &'a str>,
|
legacy_endpoint: &'a str,
|
||||||
result: u32,
|
#[serde(rename = "type")]
|
||||||
|
server_type: &'a str,
|
||||||
|
dc: &'a str,
|
||||||
|
realm: &'a str,
|
||||||
|
load: u32,
|
||||||
|
wtd_load: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
struct GetCMListForConnectResponse<'a> {
|
||||||
|
serverlist: BTreeMap<u32, CMServerEntry<'a>>,
|
||||||
|
success: u32,
|
||||||
message: &'a str,
|
message: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn bootstrap_find_servers() -> eyre::Result<Vec<String>> {
|
pub async fn bootstrap_find_servers() -> eyre::Result<Vec<String>> {
|
||||||
// TODO: Use GetCMListForConnect, seems to be new API
|
let response = reqwest::get(
|
||||||
let result_text = reqwest::get("https://api.steampowered.com/ISteamDirectory/GetCMList/v1/?cellid=0&maxcount=10&format=vdf").await?.text().await?;
|
"https://api.steampowered.com/ISteamDirectory/GetCMListForConnect/v1/?cellid=0&format=vdf",
|
||||||
let result: GetCMListResult = keyvalues_serde::from_str(&result_text)?;
|
)
|
||||||
|
.await?
|
||||||
|
.text()
|
||||||
|
.await?;
|
||||||
|
let result: GetCMListForConnectResponse = keyvalues_serde::from_str(&response)?;
|
||||||
|
|
||||||
if result.result != 1 {
|
if result.success != 1 {
|
||||||
eyre::bail!(
|
eyre::bail!(
|
||||||
"GetCMList returned bad result {} wtih message {}",
|
"GetCMList returned bad result {} wtih message {}",
|
||||||
result.result,
|
result.success,
|
||||||
result.message
|
result.message
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(result
|
Ok(result
|
||||||
.serverlist_websockets
|
.serverlist
|
||||||
.values()
|
.values()
|
||||||
.map(|host| format!("wss://{}/cmsocket/", host))
|
.filter(|entry| entry.server_type == "websockets")
|
||||||
|
.map(|entry| format!("wss://{}/cmsocket/", entry.endpoint))
|
||||||
.collect())
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue