Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Windows build #372

Merged
merged 1 commit into from
Jan 8, 2025
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 2 additions & 8 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 18 additions & 18 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,24 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_with = "3.11"
sqlx = { version = "0.8", features = [
"chrono",
"sqlite",
"runtime-tokio",
"uuid",
"macros",
"chrono",
"sqlite",
"runtime-tokio",
"uuid",
"macros",
] }
struct-patch = "0.8"
strum = { version = "0.26", features = ["derive"] }
tauri = { version = "1.8", features = [
"notification-all",
"dialog-all",
"clipboard-all",
"http-all",
"window-all",
"system-tray",
"native-tls-vendored",
"icon-png",
"fs-all",
"notification-all",
"dialog-all",
"clipboard-all",
"http-all",
"window-all",
"system-tray",
"native-tls-vendored",
"icon-png",
"fs-all",
] }
tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
Expand All @@ -82,15 +82,15 @@ tracing-appender = "0.2"
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
webbrowser = "1.0"
x25519-dalek = { version = "2", features = [
"getrandom",
"serde",
"static_secrets",
"getrandom",
"serde",
"static_secrets",
] }

[target.'cfg(target_os = "windows")'.dependencies]
windows-service = "0.7"
winapi = { version = "0.3", features = ["winsvc", "winerror"] }
widestring = "0.4"
widestring = "1.1"

[target.'cfg(target_os = "macos")'.dependencies]
nix = { version = "0.29", features = ["net"] }
Expand Down
6 changes: 2 additions & 4 deletions src-tauri/src/bin/defguard-service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
//! This binary is meant to run as a daemon with root privileges
//! and communicate with the desktop client over HTTP.

use clap::Parser;
use defguard_client::service::{config::Config, run_server};

#[cfg(not(windows))]
#[tokio::main]
async fn main() -> anyhow::Result<()> {
use defguard_client::service::utils::logging_setup;
use clap::Parser;
use defguard_client::service::{config::Config, run_server, utils::logging_setup};

// parse config
let config: Config = Config::parse();
Expand Down
15 changes: 15 additions & 0 deletions src-tauri/src/database/models/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ impl fmt::Display for Location<NoId> {
}

impl Location<Id> {
#[cfg(windows)]
pub(crate) async fn all<'e, E>(executor: E) -> Result<Vec<Self>, SqlxError>
where
E: SqliteExecutor<'e>,
{
query_as!(
Self,
"SELECT id, instance_id, name, address, pubkey, endpoint, allowed_ips, dns, network_id,\
route_all_traffic, mfa_enabled, keepalive_interval \
FROM location;"
)
.fetch_all(executor)
.await
}

pub(crate) async fn save<'e, E>(&mut self, executor: E) -> Result<(), SqlxError>
where
E: SqliteExecutor<'e>,
Expand Down
8 changes: 6 additions & 2 deletions src-tauri/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,9 @@ pub async fn sync_connections(app_handle: &AppHandle) -> Result<(), Error> {
continue;
}

appstate.add_connection(location.id, &interface_name, ConnectionType::Location);
appstate
.add_connection(location.id, &interface_name, ConnectionType::Location)
.await;

debug!("Sending event informing the frontend that a new connection has been created.");
app_handle.emit_all(
Expand Down Expand Up @@ -1084,7 +1086,9 @@ pub async fn sync_connections(app_handle: &AppHandle) -> Result<(), Error> {
continue;
}

appstate.add_connection(tunnel.id, &interface_name, ConnectionType::Tunnel);
appstate
.add_connection(tunnel.id, &interface_name, ConnectionType::Tunnel)
.await;

debug!("Sending event informing the frontend that a new connection has been created.");
app_handle.emit_all(
Expand Down