From 0918b210ea75134d09b15029f463b71ac6a6e082 Mon Sep 17 00:00:00 2001 From: Edward Shen Date: Fri, 23 Apr 2021 00:34:23 -0400 Subject: [PATCH] don't fill logs with compromised response --- src/ping.rs | 22 +++++++++++++++------- src/state.rs | 14 ++++++-------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/ping.rs b/src/ping.rs index 4101011..5ee1968 100644 --- a/src/ping.rs +++ b/src/ping.rs @@ -11,9 +11,10 @@ use serde::{Deserialize, Serialize}; use sodiumoxide::crypto::box_::PrecomputedKey; use url::Url; -use crate::config::VALIDATE_TOKENS; -use crate::state::RwLockServerState; -use crate::{client_api_version, config::CliArgs}; +use crate::config::CliArgs; +use crate::state::PREVIOUSLY_PAUSED; +use crate::{client_api_version, state::PREVIOUSLY_COMPROMISED}; +use crate::{config::VALIDATE_TOKENS, state::RwLockServerState}; pub const CONTROL_CENTER_PING_URL: &str = "https://api.mangadex.network/ping"; @@ -180,12 +181,19 @@ pub async fn update_server_state(secret: &str, cli: &CliArgs, data: &mut Arc Result { @@ -53,10 +52,12 @@ impl ServerState { }) .unwrap(); + PREVIOUSLY_COMPROMISED.store(resp.paused, Ordering::Release); if resp.compromised { error!("Got compromised response from control center!"); } + PREVIOUSLY_PAUSED.store(resp.paused, Ordering::Release); if resp.paused { warn!("Control center has paused this node!"); } @@ -86,9 +87,6 @@ impl ServerState { tls_config: resp.tls.unwrap(), url: resp.url, url_overridden: config.override_upstream.is_some(), - log_state: LogState { - was_paused_before: resp.paused, - }, }) } Err(e) => {