From 9b6757cac8c8c44143d9422b5d277d591d63b9f8 Mon Sep 17 00:00:00 2001 From: Aleksander <170264518+t-aleksander@users.noreply.github.com> Date: Tue, 21 Apr 2026 09:47:40 +0200 Subject: [PATCH 1/4] rename migrations --- ...> 20260416160025_[2.0.0]_store_last_migrated_version.down.sql} | 0 ... => 20260416160025_[2.0.0]_store_last_migrated_version.up.sql} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename migrations/{20260416160025_store_last_migrated_version.down.sql => 20260416160025_[2.0.0]_store_last_migrated_version.down.sql} (100%) rename migrations/{20260416160025_store_last_migrated_version.up.sql => 20260416160025_[2.0.0]_store_last_migrated_version.up.sql} (100%) diff --git a/migrations/20260416160025_store_last_migrated_version.down.sql b/migrations/20260416160025_[2.0.0]_store_last_migrated_version.down.sql similarity index 100% rename from migrations/20260416160025_store_last_migrated_version.down.sql rename to migrations/20260416160025_[2.0.0]_store_last_migrated_version.down.sql diff --git a/migrations/20260416160025_store_last_migrated_version.up.sql b/migrations/20260416160025_[2.0.0]_store_last_migrated_version.up.sql similarity index 100% rename from migrations/20260416160025_store_last_migrated_version.up.sql rename to migrations/20260416160025_[2.0.0]_store_last_migrated_version.up.sql From 598385ceed059094aa72d887e9d995151857478d Mon Sep 17 00:00:00 2001 From: Aleksander <170264518+t-aleksander@users.noreply.github.com> Date: Tue, 21 Apr 2026 10:09:25 +0200 Subject: [PATCH 2/4] fix wizard state update --- crates/defguard/src/main.rs | 4 +--- crates/defguard_common/src/db/models/wizard.rs | 17 +++++++---------- crates/defguard_core/src/letsencrypt.rs | 5 ++--- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/crates/defguard/src/main.rs b/crates/defguard/src/main.rs index aa5189646..f4bfe3153 100644 --- a/crates/defguard/src/main.rs +++ b/crates/defguard/src/main.rs @@ -182,9 +182,7 @@ async fn main() -> Result<(), anyhow::Error> { } } - wizard - .update_last_version_migrated_to(&pool, CARGO_VERSION) - .await?; + Wizard::update_last_version_migrated_to(&pool, CARGO_VERSION).await?; // Reload settings from database after setup completion to ensure any changes made during setup // are reflected in the in-memory settings. diff --git a/crates/defguard_common/src/db/models/wizard.rs b/crates/defguard_common/src/db/models/wizard.rs index 02c9d195d..fa06f6a55 100644 --- a/crates/defguard_common/src/db/models/wizard.rs +++ b/crates/defguard_common/src/db/models/wizard.rs @@ -1,7 +1,7 @@ use std::fmt; use serde::{Deserialize, Serialize}; -use sqlx::{PgExecutor, Type, query, query_as}; +use sqlx::{PgExecutor, PgPool, Type, query, query_as}; use tracing::{error, info}; use url::Url; @@ -214,15 +214,12 @@ impl Wizard { } } - pub async fn update_last_version_migrated_to<'e, E>( - &mut self, - executor: E, + pub async fn update_last_version_migrated_to( + pool: &PgPool, version: &str, - ) -> Result<(), sqlx::Error> - where - E: PgExecutor<'e>, - { - self.last_version_migrated_to = Some(version.to_string()); - self.save(executor).await + ) -> Result<(), sqlx::Error> { + let mut wizard = Self::get(pool).await?; + wizard.last_version_migrated_to = Some(version.to_string()); + wizard.save(pool).await } } diff --git a/crates/defguard_core/src/letsencrypt.rs b/crates/defguard_core/src/letsencrypt.rs index 601cc3ff5..291e84ec8 100644 --- a/crates/defguard_core/src/letsencrypt.rs +++ b/crates/defguard_core/src/letsencrypt.rs @@ -333,8 +333,8 @@ mod tests { use std::{ net::{IpAddr, Ipv4Addr, SocketAddr}, pin::Pin, - sync::Arc, - sync::Once, + str::FromStr, + sync::{Arc, Once}, time::Duration, }; @@ -351,7 +351,6 @@ mod tests { AcmeCertificate, AcmeIssueEvent, AcmeLogs, AcmeProgress, AcmeStep, proxy_server, }; use sqlx::postgres::{PgConnectOptions, PgPoolOptions}; - use std::str::FromStr; use tokio::{ net::TcpListener, sync::{Mutex, mpsc}, From 9d383f317e3f7e7b4bafe9ffb28fec8c8a77030e Mon Sep 17 00:00:00 2001 From: Aleksander <170264518+t-aleksander@users.noreply.github.com> Date: Tue, 21 Apr 2026 10:09:36 +0200 Subject: [PATCH 3/4] remove mut --- crates/defguard/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/defguard/src/main.rs b/crates/defguard/src/main.rs index f4bfe3153..78a3272c2 100644 --- a/crates/defguard/src/main.rs +++ b/crates/defguard/src/main.rs @@ -143,7 +143,7 @@ async fn main() -> Result<(), anyhow::Error> { } let has_auto_adopt_flags = config.adopt_edge.is_some() && config.adopt_gateway.is_some(); - let mut wizard = Wizard::init(&pool, has_auto_adopt_flags, &config).await?; + let wizard = Wizard::init(&pool, has_auto_adopt_flags, &config).await?; Settings::initialize_runtime_defaults(&pool).await?; SERVER_CONFIG.set(config.clone()).ok(); From 6bff99493a094eb347cae15273774ca3efdc1c67 Mon Sep 17 00:00:00 2001 From: Aleksander <170264518+t-aleksander@users.noreply.github.com> Date: Tue, 21 Apr 2026 10:22:55 +0200 Subject: [PATCH 4/4] add gateway endpoint --- crates/defguard_core/src/handlers/gateway.rs | 2 +- crates/defguard_setup/src/migration.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/defguard_core/src/handlers/gateway.rs b/crates/defguard_core/src/handlers/gateway.rs index a36d142f6..d411b0866 100644 --- a/crates/defguard_core/src/handlers/gateway.rs +++ b/crates/defguard_core/src/handlers/gateway.rs @@ -98,7 +98,7 @@ pub struct GatewayUpdateData { ("api_token" = []) ) )] -pub(crate) async fn gateway_list( +pub async fn gateway_list( _role: AdminRole, session: SessionInfo, State(appstate): State, diff --git a/crates/defguard_setup/src/migration.rs b/crates/defguard_setup/src/migration.rs index 0f8b9cf35..882397fe3 100644 --- a/crates/defguard_setup/src/migration.rs +++ b/crates/defguard_setup/src/migration.rs @@ -26,6 +26,7 @@ use defguard_core::{ webauthn_end, webauthn_finish, webauthn_init, webauthn_start, }, component_setup::{setup_gateway_tls_stream, setup_proxy_tls_stream, stream_proxy_acme}, + gateway::gateway_list, resource_display::get_locations_display, session_info::get_session_info, settings::{get_settings, get_settings_essentials, patch_settings}, @@ -133,6 +134,7 @@ pub fn build_migration_webapp( "/network/{network_id}/gateways/setup", get(setup_gateway_tls_stream), ) + .route("/gateway", get(gateway_list)) .nest( "/migration", Router::new()