diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-04-11 04:37:17 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-04-11 04:39:34 -0400 |
commit | 763789f029b3be8e32efc49e9a94f61bf139ec3e (patch) | |
tree | 9fa1d38d0005f26367ce138e86f24cc166e7b269 | |
parent | c38b48749cd33d02349cd950149d4413c8469cb4 (diff) | |
download | rbw-763789f029b3be8e32efc49e9a94f61bf139ec3e.tar.gz rbw-763789f029b3be8e32efc49e9a94f61bf139ec3e.zip |
read lock timeout from config
-rw-r--r-- | src/bin/agent.rs | 3 | ||||
-rw-r--r-- | src/bin/rbw.rs | 1 | ||||
-rw-r--r-- | src/config.rs | 6 |
3 files changed, 9 insertions, 1 deletions
diff --git a/src/bin/agent.rs b/src/bin/agent.rs index b233403..9d4f7c5 100644 --- a/src/bin/agent.rs +++ b/src/bin/agent.rs @@ -163,9 +163,10 @@ struct State { impl Agent { fn new() -> Self { + let config = rbw::config::Config::load().unwrap(); Self { timeout: tokio::time::delay_for( - tokio::time::Duration::from_secs(600), // read from config + tokio::time::Duration::from_secs(config.lock_timeout), ), state: std::sync::Arc::new(tokio::sync::RwLock::new(State { priv_key: None, diff --git a/src/bin/rbw.rs b/src/bin/rbw.rs index e23d005..9a968ff 100644 --- a/src/bin/rbw.rs +++ b/src/bin/rbw.rs @@ -95,6 +95,7 @@ fn config_set(key: &str, value: &str) { "email" => config.email = Some(value.to_string()), "base_url" => config.base_url = Some(value.to_string()), "identity_url" => config.identity_url = Some(value.to_string()), + "lock_timeout" => config.lock_timeout = value.parse().unwrap(), _ => unimplemented!(), } config.save().unwrap(); diff --git a/src/config.rs b/src/config.rs index d02bc11..0e79893 100644 --- a/src/config.rs +++ b/src/config.rs @@ -8,6 +8,12 @@ pub struct Config { pub email: Option<String>, pub base_url: Option<String>, pub identity_url: Option<String>, + #[serde(default = "default_lock_timeout")] + pub lock_timeout: u64, +} + +fn default_lock_timeout() -> u64 { + 3600 } impl Config { |