Skip to content

Commit df74df0

Browse files
committed
add config
1 parent 04e28ed commit df74df0

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

src/config.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{fs::read_to_string, net::IpAddr, path::PathBuf};
1+
use std::{fs::read_to_string, net::IpAddr, path::PathBuf, time::Duration};
22

33
use clap::Parser;
44
use log::LevelFilter;
@@ -9,6 +9,10 @@ fn default_url() -> Url {
99
Url::parse("http://localhost:8080").unwrap()
1010
}
1111

12+
fn default_adoption_timeout() -> u64 {
13+
10
14+
}
15+
1216
#[derive(Parser, Debug, Deserialize, Clone)]
1317
#[command(version)]
1418
pub struct EnvConfig {
@@ -88,6 +92,24 @@ pub struct EnvConfig {
8892
/// Use Let's Encrypt staging environment for ACME issuance.
8993
#[arg(long, env = "DEFGUARD_PROXY_ACME_STAGING", default_value_t = false)]
9094
pub acme_staging: bool,
95+
96+
/// Time limit in minutes for the auto-adoption process.
97+
/// After this time Edge will reject adoption attempts until restarted.
98+
#[arg(
99+
long,
100+
short = 't',
101+
env = "DEFGUARD_ADOPTION_TIMEOUT",
102+
default_value = "10"
103+
)]
104+
#[serde(default = "default_adoption_timeout")]
105+
pub adoption_timeout: u64,
106+
}
107+
108+
impl EnvConfig {
109+
#[must_use]
110+
pub fn adoption_timeout(&self) -> Duration {
111+
Duration::from_secs(self.adoption_timeout * 60)
112+
}
91113
}
92114

93115
#[derive(thiserror::Error, Debug)]

0 commit comments

Comments
 (0)