@@ -4,6 +4,26 @@ use clap::Parser;
44use log:: LevelFilter ;
55use serde:: Deserialize ;
66
7+ fn default_http_port ( ) -> u16 {
8+ 8080
9+ }
10+
11+ fn default_grpc_port ( ) -> u16 {
12+ 50051
13+ }
14+
15+ fn default_log_level ( ) -> LevelFilter {
16+ LevelFilter :: Info
17+ }
18+
19+ fn default_cert_dir ( ) -> PathBuf {
20+ PathBuf :: from ( "/etc/defguard/certs" )
21+ }
22+
23+ fn default_https_port ( ) -> u16 {
24+ 443
25+ }
26+
727fn default_adoption_timeout ( ) -> u64 {
828 10
929}
@@ -18,19 +38,24 @@ pub struct EnvConfig {
1838 env = "DEFGUARD_PROXY_HTTP_PORT" ,
1939 default_value_t = 8080
2040 ) ]
41+ #[ serde( default = "default_http_port" ) ]
2142 pub http_port : u16 ,
2243
2344 // port the API server will listen on
2445 #[ arg( long, env = "DEFGUARD_PROXY_GRPC_PORT" , default_value_t = 50051 ) ]
46+ #[ serde( default = "default_grpc_port" ) ]
2547 pub grpc_port : u16 ,
2648
2749 #[ arg( long, env = "DEFGUARD_PROXY_LOG_LEVEL" , default_value_t = LevelFilter :: Info ) ]
50+ #[ serde( default = "default_log_level" ) ]
2851 pub log_level : LevelFilter ,
2952
3053 #[ arg( long, env = "DEFGUARD_PROXY_RATELIMIT_PERSECOND" , default_value_t = 0 ) ]
54+ #[ serde( default ) ]
3155 pub rate_limit_per_second : u64 ,
3256
3357 #[ arg( long, env = "DEFGUARD_PROXY_RATELIMIT_BURST" , default_value_t = 0 ) ]
58+ #[ serde( default ) ]
3459 pub rate_limit_burst : u32 ,
3560
3661 /// Configuration file path
@@ -39,9 +64,11 @@ pub struct EnvConfig {
3964 config_path : Option < PathBuf > ,
4065
4166 #[ arg( long, env = "DEFGUARD_HTTP_BIND_ADDRESS" ) ]
67+ #[ serde( default ) ]
4268 pub http_bind_address : Option < IpAddr > ,
4369
4470 #[ arg( long, env = "DEFGUARD_GRPC_BIND_ADDRESS" ) ]
71+ #[ serde( default ) ]
4572 pub grpc_bind_address : Option < IpAddr > ,
4673
4774 // TODO: On different platforms this may be different
@@ -50,15 +77,18 @@ pub struct EnvConfig {
5077 env = "DEFGUARD_PROXY_CERT_DIR" ,
5178 default_value = "/etc/defguard/certs"
5279 ) ]
80+ #[ serde( default = "default_cert_dir" ) ]
5381 pub cert_dir : PathBuf ,
5482
5583 /// Port for the HTTPS server. When Core sends TLS certificates over gRPC, the HTTP
5684 /// server is restarted on this port using those certificates.
5785 #[ arg( long, env = "DEFGUARD_PROXY_HTTPS_PORT" , default_value_t = 443 ) ]
86+ #[ serde( default = "default_https_port" ) ]
5887 pub https_port : u16 ,
5988
6089 /// Use Let's Encrypt staging environment for ACME issuance.
6190 #[ arg( long, env = "DEFGUARD_PROXY_ACME_STAGING" , default_value_t = false ) ]
91+ #[ serde( default ) ]
6292 pub acme_staging : bool ,
6393
6494 /// Time limit in minutes for the auto-adoption process.
0 commit comments