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
6 changes: 2 additions & 4 deletions crates/defguard/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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.
Expand Down
17 changes: 7 additions & 10 deletions crates/defguard_common/src/db/models/wizard.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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
}
}
2 changes: 1 addition & 1 deletion crates/defguard_core/src/handlers/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AppState>,
Expand Down
5 changes: 2 additions & 3 deletions crates/defguard_core/src/letsencrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand All @@ -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},
Expand Down
2 changes: 2 additions & 0 deletions crates/defguard_setup/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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()
Expand Down
Loading