make xash3d-query script path configurable

This commit is contained in:
yggverse 2026-03-05 23:00:56 +02:00
parent 44a60cff11
commit 9caeb461d3
4 changed files with 11 additions and 3 deletions

View file

@ -9,4 +9,8 @@ port = 8027
# Configure instance in the debug mode
debug = true
# Path to `xash3d-query` bin
query = "xash3d-query"
# Define at least one master to scrape game servers from
masters = ["[202:68d0:f0d5:b88d:1d1a:555e:2f6b:3148]:27010", "[300:dee4:d3c0:953b::2019]:27010"]

View file

@ -2,6 +2,7 @@ use rocket::serde::Deserialize;
use std::{
collections::HashSet,
net::{IpAddr, SocketAddr},
path::PathBuf,
};
#[derive(Debug, Deserialize)]
@ -11,5 +12,6 @@ pub struct Config {
pub host: IpAddr,
pub masters: HashSet<SocketAddr>,
pub port: u16,
pub query: PathBuf,
pub title: String,
}

View file

@ -1,8 +1,9 @@
use rocket::serde::Serialize;
use std::collections::HashSet;
use std::{collections::HashSet, path::PathBuf};
#[derive(Clone, Debug, Serialize)]
#[serde(crate = "rocket::serde")]
pub struct Global {
pub masters: HashSet<std::net::SocketAddr>,
pub query: PathBuf,
}

View file

@ -16,7 +16,7 @@ use rocket_dyn_templates::{Template, context};
fn index(meta: &State<Meta>, global: &State<Global>) -> Result<Template, Status> {
// @TODO: requires library impl
// https://github.com/FWGS/xash3d-master/issues/4
let scrape = std::process::Command::new("xash3d-query")
let scrape = std::process::Command::new(&global.query)
.arg("all")
.arg("-M")
.arg(
@ -78,6 +78,7 @@ fn rocket() -> _ {
})
.manage(Global {
masters: config.masters,
query: config.query,
})
.manage(Meta {
title: config.title,