From 851874f8cf2669dd9593eff25d6f8e8814b49e8f Mon Sep 17 00:00:00 2001 From: realaravinth Date: Fri, 27 May 2022 15:25:33 +0530 Subject: [PATCH] feat: load config to make captcha stats optional --- config/default.toml | 1 + src/settings.rs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/config/default.toml b/config/default.toml index 93b88cd0..210da8dc 100644 --- a/config/default.toml +++ b/config/default.toml @@ -28,6 +28,7 @@ salt = "asdl;kjfhjawehfpa;osdkjasdvjaksndfpoanjdfainsdfaijdsfajlkjdsaf;ajsdfwero # garbage collection period to manage mCaptcha system # leave untouched if you don't know what you are doing gc = 30 +enable_stats = true [captcha.default_difficulty_strategy] avg_traffic_difficulty = 50000 # almost instant solution diff --git a/src/settings.rs b/src/settings.rs index ee71cfdf..67c5f439 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -36,6 +36,7 @@ pub struct Server { pub struct Captcha { pub salt: String, pub gc: u64, + pub enable_stats: bool, pub default_difficulty_strategy: DefaultDifficultyStrategy, } @@ -124,6 +125,9 @@ impl Settings { const CURRENT_DIR: &str = "./config/default.toml"; const ETC: &str = "/etc/mcaptcha/config.toml"; + s.set("capatcha.enable_stats", true.to_string()) + .expect("unable to set capatcha.enable_stats default config"); + if let Ok(path) = env::var("MCAPTCHA_CONFIG") { s.merge(File::with_name(&path))?; } else if Path::new(CURRENT_DIR).exists() {