This commit is contained in:
August 2026-05-10 16:40:43 -04:00
parent 4e879c35a6
commit 8c61eac586
Signed by: shibedrill
SSH Key Fingerprint: SHA256:M0m3JW1s38BgO2t0fG146Yxd9OJ2IOqkvCAsuRHQ6Pw
3 changed files with 12 additions and 7 deletions

View File

@ -1,7 +1,7 @@
use crate::{handlers::{self, minecraft::Minecraft}, types::ServerInfo}; use crate::{handlers, types::ServerInfo};
use anyhow::anyhow; use anyhow::anyhow;
use serde::Deserialize; use serde::Deserialize;
use std::{error::Error, fmt::Display, fs::File, path::Path}; use std::{fs::File, path::Path};
const SCHEMA_VERSION: &str = "0.2.0"; const SCHEMA_VERSION: &str = "0.2.0";
@ -13,7 +13,7 @@ pub enum ConfigEntry {
impl ConfigEntry { impl ConfigEntry {
pub fn inner(&self) -> impl ServerInfo { pub fn inner(&self) -> impl ServerInfo {
match self { match self {
ConfigEntry::Minecraft(mc) => mc.clone() ConfigEntry::Minecraft(mc) => mc.clone(),
} }
} }
} }
@ -28,7 +28,10 @@ pub fn parse_configs(path: &Path) -> Result<Config, anyhow::Error> {
let file_handle = File::open(path)?; let file_handle = File::open(path)?;
let config = serde_json::from_reader::<File, Config>(file_handle)?; let config = serde_json::from_reader::<File, Config>(file_handle)?;
if !(SCHEMA_VERSION == config.version) { if !(SCHEMA_VERSION == config.version) {
return Err(anyhow!(format!("Expected schema version {}, found {}", SCHEMA_VERSION, config.version))); return Err(anyhow!(format!(
"Expected schema version {}, found {}",
SCHEMA_VERSION, config.version
)));
} }
Ok(config) Ok(config)
} }

View File

@ -4,10 +4,9 @@ mod handlers;
mod request; mod request;
mod types; mod types;
use env_logger;
use log::*;
use crate::bot_runner::BotRunner; use crate::bot_runner::BotRunner;
use futures::{self, future::try_join_all}; use futures::{self, future::try_join_all};
use log::*;
use std::path::Path; use std::path::Path;
#[tokio::main] #[tokio::main]

View File

@ -6,6 +6,9 @@ const USER_AGENT: &str = "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36
pub async fn request(url: Url) -> Result<Response, reqwest::Error> { pub async fn request(url: Url) -> Result<Response, reqwest::Error> {
let client = reqwest::Client::new(); let client = reqwest::Client::new();
let mut request = reqwest::Request::new(reqwest::Method::GET, url); let mut request = reqwest::Request::new(reqwest::Method::GET, url);
request.headers_mut().append("User-Agent", HeaderValue::from_str(USER_AGENT).expect("Could not build header")); request.headers_mut().append(
"User-Agent",
HeaderValue::from_str(USER_AGENT).expect("Could not build header"),
);
client.execute(request).await client.execute(request).await
} }