mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-03 16:25:35 +00:00
Merge branch 'master' of https://github.com/Lucky4Luuk/beammp_rust_server
This commit is contained in:
commit
46e42b88da
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -177,6 +177,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"tokio",
|
"tokio",
|
||||||
"toml",
|
"toml",
|
||||||
|
"uuid",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1643,6 +1644,12 @@ dependencies = [
|
|||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uuid"
|
||||||
|
version = "1.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
version = "0.9.4"
|
version = "0.9.4"
|
||||||
|
@ -33,3 +33,4 @@ mlua = { version = "0.9.1", features = ["lua54", "vendored", "send"] }
|
|||||||
|
|
||||||
ratatui = "0.24.0"
|
ratatui = "0.24.0"
|
||||||
crossterm = "0.27.0"
|
crossterm = "0.27.0"
|
||||||
|
uuid = "1.6.1"
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
@ -46,18 +47,10 @@ pub struct GeneralSettings {
|
|||||||
|
|
||||||
impl GeneralSettings {
|
impl GeneralSettings {
|
||||||
pub fn is_auth_key_valid(&self) -> bool {
|
pub fn is_auth_key_valid(&self) -> bool {
|
||||||
// Valid key format
|
return if let Some(auth_key) = &self.auth_key {
|
||||||
// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
Uuid::parse_str(auth_key.as_str()).is_ok()
|
||||||
// -8--------4----4----4----12---------
|
} else {
|
||||||
if self.auth_key.is_none() {return false}
|
false
|
||||||
let key = self.auth_key.clone().unwrap();
|
}
|
||||||
let key_check: Vec<&str> = key.split("-").collect();
|
|
||||||
if key_check.len() != 5 {return false}
|
|
||||||
else if key_check[0].len() != 8 {return false}
|
|
||||||
else if key_check[1].len() != 4 {return false}
|
|
||||||
else if key_check[2].len() != 4 {return false}
|
|
||||||
else if key_check[3].len() != 4 {return false}
|
|
||||||
else if key_check[4].len() != 12 {return false}
|
|
||||||
true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -21,7 +21,12 @@ struct HeartbeatInfo {
|
|||||||
|
|
||||||
pub async fn backend_heartbeat(config: std::sync::Arc<crate::config::Config>, mut hb_rx: Receiver<crate::server::ServerStatus>) {
|
pub async fn backend_heartbeat(config: std::sync::Arc<crate::config::Config>, mut hb_rx: Receiver<crate::server::ServerStatus>) {
|
||||||
if !config.general.is_auth_key_valid() {
|
if !config.general.is_auth_key_valid() {
|
||||||
debug!{"auth_key has invalid format. canceling hearbeat init"};
|
if config.general.private {
|
||||||
|
warn!("AuthKey has invalid format. This is not an error, since your server is private.");
|
||||||
|
} else {
|
||||||
|
error!("AuthKey has invalid format. The server will not appear on the server list.");
|
||||||
|
}
|
||||||
|
// FIXME: The heartbeat should be started if the config is ever changed/reloaded.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let mut info = HeartbeatInfo {
|
let mut info = HeartbeatInfo {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user