From 2b9507e99496078bfb74736e3e940f9ee17a7588 Mon Sep 17 00:00:00 2001 From: Jacek Chmielewski Date: Wed, 25 Mar 2026 08:01:49 +0100 Subject: [PATCH 1/2] ensure settings are initialized before running wizards --- crates/defguard/src/main.rs | 6 +----- crates/defguard_common/src/db/models/settings.rs | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/crates/defguard/src/main.rs b/crates/defguard/src/main.rs index 8ae32950b..17350f030 100644 --- a/crates/defguard/src/main.rs +++ b/crates/defguard/src/main.rs @@ -117,6 +117,7 @@ async fn main() -> Result<(), anyhow::Error> { let wizard = Wizard::init(&pool, has_auto_adopt_flags).await?; let mut ini_server_config = true; + Settings::initialize_runtime_defaults(&pool).await?; if !wizard.completed { match wizard.active_wizard { ActiveWizard::None => {} @@ -136,9 +137,6 @@ async fn main() -> Result<(), anyhow::Error> { ActiveWizard::Migration => { let mut settings = Settings::get_current_settings(); settings.update_from_config(&pool, &config).await?; - - Settings::initialize_runtime_defaults(&pool).await?; - config.initialize_post_settings(); SERVER_CONFIG .set(config.clone()) @@ -159,8 +157,6 @@ async fn main() -> Result<(), anyhow::Error> { } } - Settings::initialize_runtime_defaults(&pool).await?; - if ini_server_config { config.initialize_post_settings(); diff --git a/crates/defguard_common/src/db/models/settings.rs b/crates/defguard_common/src/db/models/settings.rs index 8a7175d83..484973043 100644 --- a/crates/defguard_common/src/db/models/settings.rs +++ b/crates/defguard_common/src/db/models/settings.rs @@ -51,7 +51,7 @@ pub async fn update_current_settings<'e, E: sqlx::PgExecutor<'e>>( pub enum SettingsValidationError { #[error("Cannot enable gateway disconnect notifications. SMTP is not configured")] CannotEnableGatewayNotifications, - #[error("Invalid defguard_url `{0}`")] + #[error("Invalid defguard_url `{0}`, url has to be a domain, not IP")] InvalidDefguardUrl(String), } From 617e3396af570f9ac5973d00267d38f2fe3474f6 Mon Sep 17 00:00:00 2001 From: Jacek Chmielewski Date: Wed, 25 Mar 2026 08:06:31 +0100 Subject: [PATCH 2/2] cargo fmt --- crates/defguard/src/main.rs | 2 +- .../src/tests/gateway_manager/handler/support.rs | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/defguard/src/main.rs b/crates/defguard/src/main.rs index 17350f030..246f1c0ea 100644 --- a/crates/defguard/src/main.rs +++ b/crates/defguard/src/main.rs @@ -117,7 +117,7 @@ async fn main() -> Result<(), anyhow::Error> { let wizard = Wizard::init(&pool, has_auto_adopt_flags).await?; let mut ini_server_config = true; - Settings::initialize_runtime_defaults(&pool).await?; + Settings::initialize_runtime_defaults(&pool).await?; if !wizard.completed { match wizard.active_wizard { ActiveWizard::None => {} diff --git a/crates/defguard_gateway_manager/src/tests/gateway_manager/handler/support.rs b/crates/defguard_gateway_manager/src/tests/gateway_manager/handler/support.rs index dab5e580d..5a2b56a1a 100644 --- a/crates/defguard_gateway_manager/src/tests/gateway_manager/handler/support.rs +++ b/crates/defguard_gateway_manager/src/tests/gateway_manager/handler/support.rs @@ -10,13 +10,15 @@ use defguard_common::db::{ }, }; use defguard_core::grpc::GatewayEvent; -use defguard_proto::enterprise::firewall::{ - FirewallConfig, FirewallPolicy, FirewallRule, IpAddress, IpVersion, Port, Protocol, - SnatBinding, ip_address::Address, port::Port as PortInner, -}; -use defguard_proto::gateway::{ - CoreResponse, Update, UpdateType, core_response, - update::{self}, +use defguard_proto::{ + enterprise::firewall::{ + FirewallConfig, FirewallPolicy, FirewallRule, IpAddress, IpVersion, Port, Protocol, + SnatBinding, ip_address::Address, port::Port as PortInner, + }, + gateway::{ + CoreResponse, Update, UpdateType, core_response, + update::{self}, + }, }; use sqlx::postgres::PgConnectOptions;