Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions example-config.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
# This is an example config file for defguard VPN gateway
# To use it fill in actual values for your deployment below

# Required: defguard server gRPC endpoint URL
# NOTE: must replace default with actual value
grpc_url = "<defguard_grpc_url>"
# Optional: gateway name which will be displayed in defguard web UI
name = "Gateway A"
# Required: use userspace WireGuard implementation (e.g. wireguard-go)
userspace = false
# Optional: path to TLS cert file
# grpc_ca = cert.pem
# Required: how often should interface stat updates be sent to defguard server (in seconds)
stats_period = 60
# Required: name of WireGuard interface
Expand Down
27 changes: 27 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ fn default_log_level() -> String {
String::from("info")
}

fn default_grpc_port() -> u16 {
50066
}

fn default_stats_period() -> u64 {
30
}

fn default_ifname() -> String {
String::from("wg0")
}

fn default_syslog_facility() -> String {
String::from("LOG_USER")
}

fn default_adoption_timeout() -> u64 {
10
}
Expand All @@ -23,6 +39,10 @@ fn default_syslog_socket() -> PathBuf {
PathBuf::from("/var/run/log")
}

fn default_cert_dir() -> PathBuf {
PathBuf::from("/etc/defguard/certs")
}

#[derive(Debug, Parser, Clone, Deserialize)]
#[clap(about = "Defguard VPN gateway service")]
#[command(version = VERSION)]
Expand All @@ -33,18 +53,22 @@ pub struct Config {

/// Gateway gRPC server port.
#[arg(long, env = "DEFGUARD_GRPC_PORT", default_value = "50066")]
#[serde(default = "default_grpc_port")]
pub(crate) grpc_port: u16,

/// Use userspace WireGuard implementation e.g. wireguard-go
#[arg(long, short = 'u', env = "DEFGUARD_USERSPACE")]
#[serde(default)]
pub userspace: bool,

/// Defines how often (in seconds) interface statistics are sent to Defguard Core.
#[arg(long, short = 'p', env = "DEFGUARD_STATS_PERIOD", default_value = "30")]
#[serde(default = "default_stats_period")]
pub stats_period: u64,

/// Network interface name (e.g. wg0)
#[arg(long, short = 'i', env = "DEFGUARD_IFNAME", default_value = "wg0")]
#[serde(default = "default_ifname")]
pub ifname: String,

/// Write process ID (PID) to this file
Expand All @@ -53,10 +77,12 @@ pub struct Config {

/// Log to syslog
#[arg(long, short = 's')]
#[serde(default)]
pub use_syslog: bool,

/// Syslog facility
#[arg(long, default_value = "LOG_USER")]
#[serde(default = "default_syslog_facility")]
pub syslog_facility: String,

/// Syslog socket path
Expand Down Expand Up @@ -113,6 +139,7 @@ pub struct Config {
env = "DEFGUARD_GATEWAY_CERT_DIR",
default_value = "/etc/defguard/certs"
)]
#[serde(default = "default_cert_dir")]
pub cert_dir: PathBuf,

/// Time limit in minutes for the auto-adoption process.
Expand Down
Loading