diff options
-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 { |