feat: load config to make captcha stats optional
This commit is contained in:
parent
4cd4605266
commit
851874f8cf
2 changed files with 5 additions and 0 deletions
|
@ -28,6 +28,7 @@ salt = "asdl;kjfhjawehfpa;osdkjasdvjaksndfpoanjdfainsdfaijdsfajlkjdsaf;ajsdfwero
|
||||||
# garbage collection period to manage mCaptcha system
|
# garbage collection period to manage mCaptcha system
|
||||||
# leave untouched if you don't know what you are doing
|
# leave untouched if you don't know what you are doing
|
||||||
gc = 30
|
gc = 30
|
||||||
|
enable_stats = true
|
||||||
|
|
||||||
[captcha.default_difficulty_strategy]
|
[captcha.default_difficulty_strategy]
|
||||||
avg_traffic_difficulty = 50000 # almost instant solution
|
avg_traffic_difficulty = 50000 # almost instant solution
|
||||||
|
|
|
@ -36,6 +36,7 @@ pub struct Server {
|
||||||
pub struct Captcha {
|
pub struct Captcha {
|
||||||
pub salt: String,
|
pub salt: String,
|
||||||
pub gc: u64,
|
pub gc: u64,
|
||||||
|
pub enable_stats: bool,
|
||||||
pub default_difficulty_strategy: DefaultDifficultyStrategy,
|
pub default_difficulty_strategy: DefaultDifficultyStrategy,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +125,9 @@ impl Settings {
|
||||||
const CURRENT_DIR: &str = "./config/default.toml";
|
const CURRENT_DIR: &str = "./config/default.toml";
|
||||||
const ETC: &str = "/etc/mcaptcha/config.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") {
|
if let Ok(path) = env::var("MCAPTCHA_CONFIG") {
|
||||||
s.merge(File::with_name(&path))?;
|
s.merge(File::with_name(&path))?;
|
||||||
} else if Path::new(CURRENT_DIR).exists() {
|
} else if Path::new(CURRENT_DIR).exists() {
|
||||||
|
|
Loading…
Reference in a new issue