diff --git a/config/default.toml b/config/default.toml index fef9b3f3..93b88cd0 100644 --- a/config/default.toml +++ b/config/default.toml @@ -21,7 +21,7 @@ domain = "localhost" proxy_has_tls = false #url_prefix = "" -[pow] +[captcha] # Please set a unique value, your mCaptcha instance's security depends on this being # unique salt = "asdl;kjfhjawehfpa;osdkjasdvjaksndfpoanjdfainsdfaijdsfajlkjdsaf;ajsdfweroire" @@ -29,6 +29,12 @@ salt = "asdl;kjfhjawehfpa;osdkjasdvjaksndfpoanjdfainsdfaijdsfajlkjdsaf;ajsdfwero # leave untouched if you don't know what you are doing gc = 30 +[captcha.default_difficulty_strategy] +avg_traffic_difficulty = 50000 # almost instant solution +peak_sustainable_traffic_difficulty = 3000000 # roughly 1.5s +broke_my_site_traffic_difficulty = 5000000 # greater than 3.5s +duration = 30 # cooldown period in seconds + [database] # This section deals with the database location and how to access it # Please note that at the moment, we have support for only postgresqa. diff --git a/src/data.rs b/src/data.rs index 24f62582..d098c863 100644 --- a/src/data.rs +++ b/src/data.rs @@ -103,7 +103,7 @@ impl SystemGroup { fn new_system(m: Addr, c: Addr) -> System { let pow = PoWConfigBuilder::default() - .salt(SETTINGS.pow.salt.clone()) + .salt(SETTINGS.captcha.salt.clone()) .build() .unwrap(); @@ -128,7 +128,7 @@ impl SystemGroup { SystemGroup::Redis(captcha) } None => { - let master = EmbeddedMaster::new(SETTINGS.pow.gc).start(); + let master = EmbeddedMaster::new(SETTINGS.captcha.gc).start(); let cache = HashCache::default().start(); let captcha = Self::new_system(master, cache); diff --git a/src/settings.rs b/src/settings.rs index eb8b1675..67346cc4 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -36,6 +36,15 @@ pub struct Server { pub struct Captcha { pub salt: String, pub gc: u64, + pub default_difficulty_strategy: DefaultDifficultyStrategy, +} + +#[derive(Debug, Clone, Deserialize)] +pub struct DefaultDifficultyStrategy { + pub avg_traffic_difficulty: u32, + pub broke_my_site_traffic_difficulty: u32, + pub peak_sustainable_traffic_difficulty: u32, + pub duration: u32, } #[derive(Debug, Clone, Deserialize)] @@ -102,7 +111,7 @@ pub struct Settings { pub database: Database, pub redis: Option, pub server: Server, - pub pow: Captcha, + pub captcha: Captcha, pub source_code: String, pub smtp: Option, pub allow_registration: bool,