feat(grpc): add support for maintenance checks
All checks were successful
Build and Test / sonic-transformed (push) Successful in 7m20s
Build and Test / mario-tennis (push) Successful in 7m30s
Build and Test / minecraft-wiiu (push) Successful in 7m35s
Build and Test / terraria (push) Successful in 7m58s
Build and Test / wii-sports-club (push) Successful in 8m0s
Build and Test / puyopuyo (push) Successful in 8m2s
Build and Test / splatoon-testfire (push) Successful in 8m55s
Build and Test / splatoon (push) Successful in 8m55s
Build and Test / wii-u-chat (push) Successful in 9m12s
Build and Test / super-mario-maker (push) Successful in 9m14s
Build and Test / friends (push) Successful in 9m16s
Build and Test / fast-racing-neo (push) Successful in 9m26s
All checks were successful
Build and Test / sonic-transformed (push) Successful in 7m20s
Build and Test / mario-tennis (push) Successful in 7m30s
Build and Test / minecraft-wiiu (push) Successful in 7m35s
Build and Test / terraria (push) Successful in 7m58s
Build and Test / wii-sports-club (push) Successful in 8m0s
Build and Test / puyopuyo (push) Successful in 8m2s
Build and Test / splatoon-testfire (push) Successful in 8m55s
Build and Test / splatoon (push) Successful in 8m55s
Build and Test / wii-u-chat (push) Successful in 9m12s
Build and Test / super-mario-maker (push) Successful in 9m14s
Build and Test / friends (push) Successful in 9m16s
Build and Test / fast-racing-neo (push) Successful in 9m26s
This commit is contained in:
parent
d4ede0ca83
commit
667f434189
8 changed files with 150 additions and 2 deletions
|
|
@ -18,7 +18,7 @@ use rnex_rmc::{
|
|||
use rnex_server::PassthroughInitModule;
|
||||
use tracing::{info, warn};
|
||||
|
||||
use crate::AuthManager;
|
||||
use crate::{AuthManager, is_maintenance};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[rmc_struct(AuthProtocol)]
|
||||
|
|
@ -188,6 +188,10 @@ impl Auth for AuthHandler {
|
|||
&self,
|
||||
name: String,
|
||||
) -> Result<(QResult, PID, Vec<u8>, ConnectionDataOld, String), ErrorCode> {
|
||||
if is_maintenance() {
|
||||
return Err(ErrorCode::RendezVous_GameServerMaintenance);
|
||||
}
|
||||
|
||||
let (pid, ticket) = self.generate_ticket_from_name(&name).await?;
|
||||
|
||||
let result = QResult::success(ErrorCode::Core_Unknown);
|
||||
|
|
@ -231,6 +235,10 @@ impl Auth for AuthHandler {
|
|||
name: String,
|
||||
_extra_data: Any,
|
||||
) -> Result<(QResult, PID, Vec<u8>, ConnectionData, String, String), ErrorCode> {
|
||||
if is_maintenance() {
|
||||
return Err(ErrorCode::RendezVous_GameServerMaintenance);
|
||||
}
|
||||
|
||||
let (pid, key, ticket) = self.generate_ticket_from_name_string_user_key(&name).await?;
|
||||
|
||||
let result = QResult::success(Core_Unknown);
|
||||
|
|
@ -296,6 +304,10 @@ impl Auth for AuthHandler {
|
|||
name: String,
|
||||
_extra_data: Any,
|
||||
) -> Result<(QResult, PID, Vec<u8>, ConnectionData, String), ErrorCode> {
|
||||
if is_maintenance() {
|
||||
return Err(ErrorCode::RendezVous_GameServerMaintenance);
|
||||
}
|
||||
|
||||
let (pid, ticket) = self.generate_ticket_from_name(&name).await?;
|
||||
|
||||
let result = QResult::success(ErrorCode::Core_Unknown);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,26 @@ use rnex_server::{ConnectionInitData, RnexManager, RnexModule, WeakPassthroughIn
|
|||
use tracing::info;
|
||||
|
||||
use crate::auth_handler::AuthHandler;
|
||||
use std::sync::{
|
||||
Arc, OnceLock,
|
||||
atomic::{AtomicBool, Ordering},
|
||||
};
|
||||
|
||||
static MAINTENANCE: OnceLock<Arc<AtomicBool>> = OnceLock::new();
|
||||
|
||||
pub fn maintenance_flag() -> Arc<AtomicBool> {
|
||||
MAINTENANCE
|
||||
.get_or_init(|| Arc::new(AtomicBool::new(false)))
|
||||
.clone()
|
||||
}
|
||||
|
||||
pub fn set_maintenance(on: bool) {
|
||||
maintenance_flag().store(on, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
pub fn is_maintenance() -> bool {
|
||||
maintenance_flag().load(Ordering::Relaxed)
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AuthManager {
|
||||
|
|
|
|||
Loading…
Reference in a new issue