0
0
mirror of https://github.com/neon-mmd/websurfx.git synced 2024-10-18 06:22:53 -04:00

🧹 chore: make github actions happy (#203)

This commit is contained in:
neon_arch 2023-09-11 20:16:42 +03:00
parent 30ca95a217
commit b9d651c378

View File

@ -36,6 +36,7 @@ pub struct Config {
pub request_timeout: u8, pub request_timeout: u8,
pub threads: u8, pub threads: u8,
pub rate_limiter: RateLimiter, pub rate_limiter: RateLimiter,
pub safe_search: u8,
} }
impl Config { impl Config {
@ -81,6 +82,16 @@ impl Config {
let rate_limiter = globals.get::<_, HashMap<String, u8>>("rate_limiter")?; let rate_limiter = globals.get::<_, HashMap<String, u8>>("rate_limiter")?;
let parsed_safe_search: u8 = globals.get::<_, u8>("safe_search")?;
let safe_search: u8 = match parsed_safe_search {
0..=4 => parsed_safe_search,
_ => {
log::error!("Config Error: The value of `safe_search` option should be a non zero positive integer from 0 to 4.");
log::error!("Falling back to using the value `1` for the option");
1
}
};
Ok(Config { Ok(Config {
port: globals.get::<_, u16>("port")?, port: globals.get::<_, u16>("port")?,
binding_ip: globals.get::<_, String>("binding_ip")?, binding_ip: globals.get::<_, String>("binding_ip")?,
@ -105,7 +116,8 @@ impl Config {
rate_limiter: RateLimiter { rate_limiter: RateLimiter {
number_of_requests: rate_limiter["number_of_requests"], number_of_requests: rate_limiter["number_of_requests"],
time_limit: rate_limiter["time_limit"], time_limit: rate_limiter["time_limit"],
} },
safe_search,
}) })
} }
} }