From 0d90665698d9231d60a993489960c2b204da184d Mon Sep 17 00:00:00 2001 From: DJMrTV Date: Wed, 5 Feb 2025 16:18:51 +0100 Subject: [PATCH] feat(secure): add access level to bypass maintenance to the .env config --- src/protocols/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/protocols/mod.rs b/src/protocols/mod.rs index 82dcb66..12397aa 100644 --- a/src/protocols/mod.rs +++ b/src/protocols/mod.rs @@ -22,6 +22,12 @@ static IS_MAINTENANCE: Lazy = Lazy::new(|| { .map(|v| v.parse().expect("IS_MAINTENANCE should be a boolean value")) .unwrap_or(false) }); +static BYPASS_LEVEL: Lazy = Lazy::new(|| { + env::var("MAINTENANCE_BYPASS_MINIMUM_ACCESS_LEVEL") + .ok() + .map(|v| v.parse().expect("IS_MAINTENANCE should be a boolean value")) + .unwrap_or(3) +}); pub fn block_if_maintenance<'a>(rmcmessage: &'a RMCMessage, conn: &'a mut ConnectionData) -> Pin> + Send + 'a)>> { @@ -30,7 +36,7 @@ pub fn block_if_maintenance<'a>(rmcmessage: &'a RMCMessage, conn: &'a mut Connec if let Some(secure_conn) = active_conn.active_secure_connection_data.as_ref() { if let Ok(mut client) = grpc::account::Client::new().await { if let Ok(client_data) = client.get_user_data(secure_conn.pid).await{ - if client_data.access_level >= 2{ + if client_data.access_level >= *BYPASS_LEVEL{ return None; } }