From d66d5bf5c133dfab816c982ee57822c30b8787da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Ciarcin=CC=81ski?= Date: Tue, 5 Aug 2025 16:06:44 +0200 Subject: [PATCH 1/3] Fix CLI: multi IP address, one interface name --- src-tauri/Cargo.lock | 468 ++++++++++++++------------ src-tauri/Cargo.toml | 53 +-- src-tauri/build.rs | 33 +- src-tauri/cli/Cargo.toml | 4 +- src-tauri/cli/src/bin/dg.rs | 196 ++++++----- src-tauri/proto | 2 +- src-tauri/src/periodic/purge_stats.rs | 2 +- src-tauri/src/utils.rs | 5 +- 8 files changed, 428 insertions(+), 335 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 59aba5dc..f4b68e8c 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -162,7 +162,7 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3d60bee1a1d38c2077030f4788e1b4e31058d2e79a8cfc8f2b440bd44db290" dependencies = [ - "async-fs 2.1.2", + "async-fs 2.1.3", "async-net", "enumflags2", "futures-channel", @@ -171,7 +171,7 @@ dependencies = [ "serde", "serde_repr", "url", - "zbus 5.8.0", + "zbus 5.9.0", ] [[package]] @@ -190,7 +190,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532" dependencies = [ - "event-listener 5.4.0", + "event-listener 5.4.1", "event-listener-strategy", "futures-core", "pin-project-lite", @@ -228,7 +228,7 @@ dependencies = [ "async-task", "concurrent-queue", "fastrand 2.3.0", - "futures-lite 2.6.0", + "futures-lite 2.6.1", "pin-project-lite", "slab", ] @@ -247,13 +247,13 @@ dependencies = [ [[package]] name = "async-fs" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebcd09b382f40fcd159c2d695175b2ae620ffa5f3bd6f664131efff4e8b9e04a" +checksum = "09f7e37c0ed80b2a977691c47dae8625cfb21e205827106c64f7c588766b2e50" dependencies = [ - "async-lock 3.4.0", + "async-lock 3.4.1", "blocking", - "futures-lite 2.6.0", + "futures-lite 2.6.1", ] [[package]] @@ -264,10 +264,10 @@ checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" dependencies = [ "async-channel 2.5.0", "async-executor", - "async-io 2.4.1", - "async-lock 3.4.0", + "async-io 2.5.0", + "async-lock 3.4.1", "blocking", - "futures-lite 2.6.0", + "futures-lite 2.6.1", "once_cell", ] @@ -293,21 +293,20 @@ dependencies = [ [[package]] name = "async-io" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1237c0ae75a0f3765f58910ff9cdd0a12eeb39ab2f4c7de23262f337f0aacbb3" +checksum = "19634d6336019ef220f09fd31168ce5c184b295cbf80345437cc36094ef223ca" dependencies = [ - "async-lock 3.4.0", + "async-lock 3.4.1", "cfg-if", "concurrent-queue", "futures-io", - "futures-lite 2.6.0", + "futures-lite 2.6.1", "parking", - "polling 3.8.0", + "polling 3.10.0", "rustix 1.0.8", "slab", - "tracing", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -321,11 +320,11 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.4.0" +version = "3.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" +checksum = "5fd03604047cee9b6ce9de9f70c6cd540a0520c813cbd49bae61f33ab80ed1dc" dependencies = [ - "event-listener 5.4.0", + "event-listener 5.4.1", "event-listener-strategy", "pin-project-lite", ] @@ -336,9 +335,9 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b948000fad4873c1c9339d60f2623323a0cfd3816e5181033c6a5cb68b2accf7" dependencies = [ - "async-io 2.4.1", + "async-io 2.5.0", "blocking", - "futures-lite 2.6.0", + "futures-lite 2.6.1", ] [[package]] @@ -360,21 +359,20 @@ dependencies = [ [[package]] name = "async-process" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde3f4e40e6021d7acffc90095cbd6dc54cb593903d1de5832f435eb274b85dc" +checksum = "65daa13722ad51e6ab1a1b9c01299142bc75135b337923cfa10e79bbbd669f00" dependencies = [ "async-channel 2.5.0", - "async-io 2.4.1", - "async-lock 3.4.0", + "async-io 2.5.0", + "async-lock 3.4.1", "async-signal", "async-task", "blocking", "cfg-if", - "event-listener 5.4.0", - "futures-lite 2.6.0", + "event-listener 5.4.1", + "futures-lite 2.6.1", "rustix 1.0.8", - "tracing", ] [[package]] @@ -390,12 +388,12 @@ dependencies = [ [[package]] name = "async-signal" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7605a4e50d4b06df3898d5a70bf5fde51ed9059b0434b73105193bc27acce0d" +checksum = "f567af260ef69e1d52c2b560ce0ea230763e6fbb9214a85d768760a920e3e3c1" dependencies = [ - "async-io 2.4.1", - "async-lock 3.4.0", + "async-io 2.5.0", + "async-lock 3.4.1", "atomic-waker", "cfg-if", "futures-core", @@ -403,7 +401,7 @@ dependencies = [ "rustix 1.0.8", "signal-hook-registry", "slab", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -414,13 +412,13 @@ checksum = "730294c1c08c2e0f85759590518f6333f0d5a0a766a27d519c1b244c3dfd8a24" dependencies = [ "async-channel 1.9.0", "async-global-executor", - "async-io 2.4.1", - "async-lock 3.4.0", + "async-io 2.5.0", + "async-lock 3.4.1", "crossbeam-utils", "futures-channel", "futures-core", "futures-io", - "futures-lite 2.6.0", + "futures-lite 2.6.1", "gloo-timers", "kv-log-macro", "log", @@ -432,28 +430,6 @@ dependencies = [ "wasm-bindgen-futures", ] -[[package]] -name = "async-stream" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" -dependencies = [ - "async-stream-impl", - "futures-core", - "pin-project-lite", -] - -[[package]] -name = "async-stream-impl" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", -] - [[package]] name = "async-task" version = "4.7.1" @@ -518,11 +494,10 @@ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "axum" -version = "0.7.9" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" +checksum = "021e862c184ae977658b36c4500f7feac3221ca5da43e3f25bd04ab6c79a29b5" dependencies = [ - "async-trait", "axum-core", "bytes", "futures-util", @@ -538,20 +513,19 @@ dependencies = [ "rustversion", "serde", "sync_wrapper 1.0.2", - "tower 0.5.2", + "tower", "tower-layer", "tower-service", ] [[package]] name = "axum-core" -version = "0.4.5" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" +checksum = "68464cd0412f486726fb3373129ef5d2993f90c34bc2bc1c1e9943b2f4fc7ca6" dependencies = [ - "async-trait", "bytes", - "futures-util", + "futures-core", "http 1.3.1", "http-body 1.0.1", "http-body-util", @@ -680,7 +654,7 @@ dependencies = [ "async-channel 2.5.0", "async-task", "futures-io", - "futures-lite 2.6.0", + "futures-lite 2.6.1", "piper", ] @@ -840,9 +814,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.29" +version = "1.2.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c1599538de2394445747c8cf7935946e3cc27e9625f889d979bfb2aaf569362" +checksum = "c3a42d84bb6b69d3a8b3eaacf0d88f179e1929695e1ad012b6cf64d9caaa5fd2" dependencies = [ "jobserver", "libc", @@ -914,9 +888,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.41" +version = "4.5.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be92d32e80243a54711e5d7ce823c35c41c9d929dc4ab58e1276f625841aadf9" +checksum = "ed87a9d530bb41a67537289bafcac159cb3ee28460e0a4571123d2a778a6a882" dependencies = [ "clap_builder", "clap_derive", @@ -924,9 +898,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.41" +version = "4.5.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707eab41e9622f9139419d573eca0900137718000c517d47da73045f54331c3d" +checksum = "64f4f3f3c77c94aff3c7e9aac9a2ca1974a5adf392a8bb751e827d6d127ab966" dependencies = [ "anstream", "anstyle", @@ -954,9 +928,9 @@ checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" [[package]] name = "clipboard-win" -version = "5.4.0" +version = "5.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15efe7a882b08f34e38556b14f2fb3daa98769d06c7f0c1b076dfd0d983bc892" +checksum = "bde03770d3df201d4fb868f2c9c59e66a3e4e2bd06692a0fe701e7103c7e84d4" dependencies = [ "error-code", ] @@ -1271,9 +1245,9 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.2.0" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373b7c5dbd637569a2cca66e8d66b8c446a1e7bf064ea321d265d7b3dfe7c97e" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ "cfg-if", "cpufeatures", @@ -1360,7 +1334,6 @@ dependencies = [ "hyper-util", "log", "prost", - "prost-build", "regex", "reqwest 0.12.22", "rust-ini", @@ -1381,8 +1354,9 @@ dependencies = [ "tokio-stream", "tokio-util", "tonic", - "tonic-build", - "tower 0.5.2", + "tonic-prost", + "tonic-prost-build", + "tower", "tracing", "tracing-appender", "tracing-subscriber", @@ -1414,8 +1388,9 @@ dependencies = [ [[package]] name = "defguard_wireguard_rs" -version = "0.7.4" -source = "git+https://github.com/DefGuard/wireguard-rs.git?rev=v0.7.4#37c1ed8aa3bb38f1fa7662a9e413d52828f18486" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e2d2f56ffaf56903a51b128c6f6730b8b344fab0d0be0f5db0b65dcccbb7334" dependencies = [ "base64 0.22.1", "libc", @@ -1621,9 +1596,9 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "dyn-clone" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c7a8fb8a9fbf66c1f703fe16184d10ca0ee9d23be5b4436400408ba54a95005" +checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" [[package]] name = "either" @@ -1742,9 +1717,9 @@ dependencies = [ [[package]] name = "event-listener" -version = "5.4.0" +version = "5.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3492acde4c3fc54c845eaab3eed8bd00c7a7d881f78bfc801e43a93dec1331ae" +checksum = "e13b66accf52311f30a0db42147dadea9850cb48cd070028831ae5f5d4b856ab" dependencies = [ "concurrent-queue", "parking", @@ -1757,7 +1732,7 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" dependencies = [ - "event-listener 5.4.0", + "event-listener 5.4.1", "pin-project-lite", ] @@ -1796,9 +1771,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.3.0" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64cd1e32ddd350061ae6edb1b082d7c54915b5c672c389143b9a63403a109f24" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "field-offset" @@ -1977,9 +1952,9 @@ dependencies = [ [[package]] name = "futures-lite" -version = "2.6.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5edaec856126859abb19ed65f39e90fea3a9574b9707f13539acf4abf7eb532" +checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad" dependencies = [ "fastrand 2.3.0", "futures-core", @@ -2713,9 +2688,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f66d5bd4c6f02bf0542fad85d626775bab9258cf795a4256dcaf3161114d1df" +checksum = "8d9b05277c7e8da2c93a568989bb6207bef0112e8d17df7a6eda4a3cf143bc5e" dependencies = [ "base64 0.22.1", "bytes", @@ -2729,7 +2704,7 @@ dependencies = [ "libc", "percent-encoding", "pin-project-lite", - "socket2 0.5.10", + "socket2 0.6.0", "system-configuration 0.6.1", "tokio", "tower-service", @@ -2978,9 +2953,9 @@ dependencies = [ [[package]] name = "io-uring" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b86e202f00093dcba4275d4636b93ef9dd75d025ae560d2521b45ea28ab49013" +checksum = "d93587f37623a1a17d94ef2bc9ada592f5465fe7732084ab7beefabe5c77c0c4" dependencies = [ "bitflags 2.9.1", "cfg-if", @@ -3229,9 +3204,9 @@ checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" [[package]] name = "libredox" -version = "0.1.4" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1580801010e535496706ba011c15f8532df6b42297d2e471fec38ceadd8c0638" +checksum = "391290121bad3d37fbddad76d8f5d1c1c314cfc646d143d7e07a3086ddff0ce3" dependencies = [ "bitflags 2.9.1", "libc", @@ -3287,9 +3262,9 @@ checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" [[package]] name = "litrs" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" +checksum = "f5e54036fe321fd421e10d732f155734c4e4afd610dd556d9a82833ab3ee0bed" [[package]] name = "lock_api" @@ -3384,9 +3359,9 @@ checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "matchit" -version = "0.7.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" [[package]] name = "md-5" @@ -3473,7 +3448,7 @@ dependencies = [ "openssl-probe", "openssl-sys", "schannel", - "security-framework", + "security-framework 2.11.1", "security-framework-sys", "tempfile", ] @@ -3634,12 +3609,12 @@ version = "4.11.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6442248665a5aa2514e794af3b39661a8e73033b1cc5e59899e1276117ee4400" dependencies = [ - "futures-lite 2.6.0", + "futures-lite 2.6.1", "log", "mac-notification-sys", "serde", "tauri-winrt-notification", - "zbus 5.8.0", + "zbus 5.9.0", ] [[package]] @@ -4295,7 +4270,7 @@ checksum = "3af6b589e163c5a788fab00ce0c0366f6efbb9959c2f9874b224936af7fce7e1" dependencies = [ "base64 0.22.1", "indexmap 2.10.0", - "quick-xml 0.38.0", + "quick-xml 0.38.1", "serde", "time", ] @@ -4331,17 +4306,16 @@ dependencies = [ [[package]] name = "polling" -version = "3.8.0" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b53a684391ad002dd6a596ceb6c74fd004fdce75f4be2e3f615068abbea5fd50" +checksum = "b5bd19146350fe804f7cb2669c851c03d69da628803dab0d98018142aaa5d829" dependencies = [ "cfg-if", "concurrent-queue", "hermit-abi 0.5.2", "pin-project-lite", "rustix 1.0.8", - "tracing", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -4376,9 +4350,9 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "prettyplease" -version = "0.2.35" +version = "0.2.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "061c1221631e079b26479d25bbf2275bfe5917ae8419cd7e34f13bfc2aa7539a" +checksum = "ff24dfcda44452b9816fff4cd4227e1bb73ff5a2f1bc1105aa92fb8565ce44d2" dependencies = [ "proc-macro2", "syn 2.0.104", @@ -4444,9 +4418,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.13.5" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2796faa41db3ec313a31f7624d9286acf277b52de526150b7e69f3debf891ee5" +checksum = "7231bd9b3d3d33c86b58adbac74b5ec0ad9f496b19d22801d773636feaa95f3d" dependencies = [ "bytes", "prost-derive", @@ -4454,9 +4428,9 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.13.5" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be769465445e8c1474e9c5dac2018218498557af32d9ed057325ec9a41ae81bf" +checksum = "ac6c3320f9abac597dcbc668774ef006702672474aad53c6d596b62e487b40b1" dependencies = [ "heck 0.5.0", "itertools", @@ -4467,6 +4441,8 @@ dependencies = [ "prettyplease", "prost", "prost-types", + "pulldown-cmark", + "pulldown-cmark-to-cmark", "regex", "syn 2.0.104", "tempfile", @@ -4474,9 +4450,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.13.5" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" +checksum = "9120690fafc389a67ba3803df527d0ec9cbbc9cc45e4cc20b332996dfb672425" dependencies = [ "anyhow", "itertools", @@ -4487,9 +4463,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.13.5" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52c2c1bf36ddb1a1c396b3601a3cec27c2462e45f07c386894ec3ccf5332bd16" +checksum = "b9b4db3d6da204ed77bb26ba83b6122a73aeb2e87e25fbf7ad2e84c4ccbf8f72" dependencies = [ "prost", ] @@ -4530,6 +4506,26 @@ dependencies = [ "psl-types", ] +[[package]] +name = "pulldown-cmark" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e8bbe1a966bd2f362681a44f6edce3c2310ac21e4d5067a6e7ec396297a6ea0" +dependencies = [ + "bitflags 2.9.1", + "memchr", + "unicase", +] + +[[package]] +name = "pulldown-cmark-to-cmark" +version = "21.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5b6a0769a491a08b31ea5c62494a8f144ee0987d86d670a8af4df1e1b7cde75" +dependencies = [ + "pulldown-cmark", +] + [[package]] name = "quick-xml" version = "0.37.5" @@ -4541,9 +4537,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.38.0" +version = "0.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8927b0664f5c5a98265138b7e3f90aa19a6b21353182469ace36d4ac527b7b1b" +checksum = "9845d9dccf565065824e69f9f235fafba1587031eda353c1f1561cd6a6be78f4" dependencies = [ "memchr", ] @@ -4658,9 +4654,9 @@ checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" [[package]] name = "redox_syscall" -version = "0.5.13" +version = "0.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6" +checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" dependencies = [ "bitflags 2.9.1", ] @@ -4824,7 +4820,7 @@ dependencies = [ "sync_wrapper 1.0.2", "tokio", "tokio-native-tls", - "tower 0.5.2", + "tower", "tower-http", "tower-service", "url", @@ -4949,9 +4945,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.25" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f" +checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" [[package]] name = "rustc_version" @@ -5004,17 +5000,31 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.29" +version = "0.23.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2491382039b29b9b11ff08b76ff6c97cf287671dbb74f0be44bda389fffe9bd1" +checksum = "c0ebcbd2f03de0fc1122ad9bb24b127a5a6cd51d72604a3f3c50ac459762b6cc" dependencies = [ + "log", "once_cell", + "ring", "rustls-pki-types", "rustls-webpki", "subtle", "zeroize", ] +[[package]] +name = "rustls-native-certs" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework 3.2.0", +] + [[package]] name = "rustls-pemfile" version = "1.0.4" @@ -5129,6 +5139,19 @@ dependencies = [ "security-framework-sys", ] +[[package]] +name = "security-framework" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316" +dependencies = [ + "bitflags 2.9.1", + "core-foundation 0.10.1", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + [[package]] name = "security-framework-sys" version = "2.14.0" @@ -5190,9 +5213,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.140" +version = "1.0.142" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" dependencies = [ "indexmap 2.10.0", "itoa 1.0.15", @@ -5336,9 +5359,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.5" +version = "1.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" +checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" dependencies = [ "libc", ] @@ -5412,6 +5435,16 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "socket2" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + [[package]] name = "soup2" version = "0.2.1" @@ -5484,7 +5517,7 @@ dependencies = [ "crc", "crossbeam-queue", "either", - "event-listener 5.4.0", + "event-listener 5.4.1", "futures-core", "futures-intrusive", "futures-io", @@ -5720,18 +5753,18 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "struct-patch" -version = "0.9.4" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "157c4161ecd2bdb6fac38c4c627b5b3adc62a0ad53d0ba8b984f1df9631ebef0" +checksum = "5b7b4951cb1da2288c258a7ce95d046236a16ebf196ef173a3fa8d30050f6a16" dependencies = [ "struct-patch-derive", ] [[package]] name = "struct-patch-derive" -version = "0.9.4" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "403a2a4b4fae123baa030e9a13f1d366647164fa6222a92c49730d10e8df1b93" +checksum = "f2cc6db9c0478552bafc49ec2a04f4c6de282789b66bcf2dafe057921054d659" dependencies = [ "proc-macro2", "quote", @@ -5740,23 +5773,22 @@ dependencies = [ [[package]] name = "strum" -version = "0.27.1" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f64def088c51c9510a8579e3c5d67c65349dcf755e5479ad3d010aa6454e2c32" +checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" dependencies = [ "strum_macros", ] [[package]] name = "strum_macros" -version = "0.27.1" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77a8c5abcaf0f9ce05d62342b7d298c346515365c36b673df4ebe3ced01fde8" +checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "rustversion", "syn 2.0.104", ] @@ -6083,7 +6115,7 @@ dependencies = [ [[package]] name = "tauri-plugin-log" version = "0.0.0" -source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v1#35fff903ad9f7c1ed6f9a8cead4210c36868ff0e" +source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v1#2a8f9b91a746c9f76c29f26fe1d62d905fb54f88" dependencies = [ "byte-unit", "fern", @@ -6098,7 +6130,7 @@ dependencies = [ [[package]] name = "tauri-plugin-single-instance" version = "0.0.0" -source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v1#35fff903ad9f7c1ed6f9a8cead4210c36868ff0e" +source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v1#2a8f9b91a746c9f76c29f26fe1d62d905fb54f88" dependencies = [ "log", "serde", @@ -6112,7 +6144,7 @@ dependencies = [ [[package]] name = "tauri-plugin-window-state" version = "0.1.1" -source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v1#35fff903ad9f7c1ed6f9a8cead4210c36868ff0e" +source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v1#2a8f9b91a746c9f76c29f26fe1d62d905fb54f88" dependencies = [ "bincode", "bitflags 2.9.1", @@ -6376,9 +6408,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.46.1" +version = "1.47.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cc3a2344dafbe23a245241fe8b09735b521110d30fcefbbd5feb1797ca35d17" +checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038" dependencies = [ "backtrace", "bytes", @@ -6389,9 +6421,9 @@ dependencies = [ "pin-project-lite", "signal-hook-registry", "slab", - "socket2 0.5.10", + "socket2 0.6.0", "tokio-macros", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -6438,9 +6470,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.15" +version = "0.7.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df" +checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5" dependencies = [ "bytes", "futures-core", @@ -6526,15 +6558,15 @@ checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" [[package]] name = "tonic" -version = "0.12.3" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" +checksum = "308e1db96abdccdf0a9150fb69112bf6ea72640e0bd834ef0c4a618ccc8c8ddc" dependencies = [ - "async-stream", "async-trait", "axum", "base64 0.22.1", "bytes", + "flate2", "h2 0.4.11", "http 1.3.1", "http-body 1.0.1", @@ -6544,11 +6576,13 @@ dependencies = [ "hyper-util", "percent-encoding", "pin-project", - "prost", - "socket2 0.5.10", + "rustls-native-certs", + "socket2 0.6.0", + "sync_wrapper 1.0.2", "tokio", + "tokio-rustls", "tokio-stream", - "tower 0.4.13", + "tower", "tower-layer", "tower-service", "tracing", @@ -6556,36 +6590,41 @@ dependencies = [ [[package]] name = "tonic-build" -version = "0.12.3" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9557ce109ea773b399c9b9e5dca39294110b74f1f342cb347a80d1fce8c26a11" +checksum = "18262cdd13dec66e8e3f2e3fe535e4b2cc706fab444a7d3678d75d8ac2557329" dependencies = [ "prettyplease", "proc-macro2", - "prost-build", - "prost-types", "quote", "syn 2.0.104", ] [[package]] -name = "tower" -version = "0.4.13" +name = "tonic-prost" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +checksum = "2d8b5b7a44512c59f5ad45e0c40e53263cbbf4426d74fe6b569e04f1d4206e9c" dependencies = [ - "futures-core", - "futures-util", - "indexmap 1.9.3", - "pin-project", - "pin-project-lite", - "rand 0.8.5", - "slab", - "tokio", - "tokio-util", - "tower-layer", - "tower-service", - "tracing", + "bytes", + "prost", + "tonic", +] + +[[package]] +name = "tonic-prost-build" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "114cca66d757d72422ef8cccf8be3065321860ac9fa4be73aab37a8a20a9a805" +dependencies = [ + "prettyplease", + "proc-macro2", + "prost-build", + "prost-types", + "quote", + "syn 2.0.104", + "tempfile", + "tonic-build", ] [[package]] @@ -6596,11 +6635,15 @@ checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" dependencies = [ "futures-core", "futures-util", + "indexmap 2.10.0", "pin-project-lite", + "slab", "sync_wrapper 1.0.2", "tokio", + "tokio-util", "tower-layer", "tower-service", + "tracing", ] [[package]] @@ -6616,7 +6659,7 @@ dependencies = [ "http-body 1.0.1", "iri-string", "pin-project-lite", - "tower 0.5.2", + "tower", "tower-layer", "tower-service", ] @@ -6762,6 +6805,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "unicase" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" + [[package]] name = "unicode-bidi" version = "0.3.18" @@ -7081,34 +7130,34 @@ dependencies = [ [[package]] name = "wayland-backend" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe770181423e5fc79d3e2a7f4410b7799d5aab1de4372853de3c6aa13ca24121" +checksum = "673a33c33048a5ade91a6b139580fa174e19fb0d23f396dca9fa15f2e1e49b35" dependencies = [ "cc", "downcast-rs", - "rustix 0.38.44", + "rustix 1.0.8", "smallvec", "wayland-sys", ] [[package]] name = "wayland-client" -version = "0.31.10" +version = "0.31.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978fa7c67b0847dbd6a9f350ca2569174974cd4082737054dbb7fbb79d7d9a61" +checksum = "c66a47e840dc20793f2264eb4b3e4ecb4b75d91c0dd4af04b456128e0bdd449d" dependencies = [ "bitflags 2.9.1", - "rustix 0.38.44", + "rustix 1.0.8", "wayland-backend", "wayland-scanner", ] [[package]] name = "wayland-protocols" -version = "0.32.8" +version = "0.32.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "779075454e1e9a521794fed15886323ea0feda3f8b0fc1390f5398141310422a" +checksum = "efa790ed75fbfd71283bd2521a1cfdc022aabcc28bdcff00851f9e4ae88d9901" dependencies = [ "bitflags 2.9.1", "wayland-backend", @@ -7118,9 +7167,9 @@ dependencies = [ [[package]] name = "wayland-protocols-wlr" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cb6cdc73399c0e06504c437fe3cf886f25568dd5454473d565085b36d6a8bbf" +checksum = "efd94963ed43cf9938a090ca4f7da58eb55325ec8200c3848963e98dc25b78ec" dependencies = [ "bitflags 2.9.1", "wayland-backend", @@ -7131,9 +7180,9 @@ dependencies = [ [[package]] name = "wayland-scanner" -version = "0.31.6" +version = "0.31.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "896fdafd5d28145fce7958917d69f2fd44469b1d4e861cb5961bcbeebc6d1484" +checksum = "54cb1e9dc49da91950bdfd8b848c49330536d9d1fb03d4bfec8cae50caa50ae3" dependencies = [ "proc-macro2", "quick-xml 0.37.5", @@ -7142,9 +7191,9 @@ dependencies = [ [[package]] name = "wayland-sys" -version = "0.31.6" +version = "0.31.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbcebb399c77d5aa9fa5db874806ee7b4eba4e73650948e8f93963f128896615" +checksum = "34949b42822155826b41db8e5d0c1be3a2bd296c747577a43a3e6daefc296142" dependencies = [ "pkg-config", ] @@ -7541,7 +7590,7 @@ version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" dependencies = [ - "windows-targets 0.53.2", + "windows-targets 0.53.3", ] [[package]] @@ -7592,10 +7641,11 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.53.2" +version = "0.53.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c66f69fcc9ce11da9966ddb31a40968cad001c5bedeb5c2b82ede4253ab48aef" +checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" dependencies = [ + "windows-link", "windows_aarch64_gnullvm 0.53.0", "windows_aarch64_msvc 0.53.0", "windows_i686_gnu 0.53.0", @@ -8126,23 +8176,23 @@ dependencies = [ [[package]] name = "zbus" -version = "5.8.0" +version = "5.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597f45e98bc7e6f0988276012797855613cd8269e23b5be62cc4e5d28b7e515d" +checksum = "4bb4f9a464286d42851d18a605f7193b8febaf5b0919d71c6399b7b26e5b0aad" dependencies = [ "async-broadcast 0.7.2", "async-executor", - "async-io 2.4.1", - "async-lock 3.4.0", - "async-process 2.3.1", + "async-io 2.5.0", + "async-lock 3.4.1", + "async-process 2.4.0", "async-recursion", "async-task", "async-trait", "blocking", "enumflags2", - "event-listener 5.4.0", + "event-listener 5.4.1", "futures-core", - "futures-lite 2.6.0", + "futures-lite 2.6.1", "hex", "nix 0.30.1", "ordered-stream", @@ -8152,7 +8202,7 @@ dependencies = [ "uds_windows", "windows-sys 0.59.0", "winnow 0.7.12", - "zbus_macros 5.8.0", + "zbus_macros 5.9.0", "zbus_names 4.2.0", "zvariant 5.6.0", ] @@ -8173,9 +8223,9 @@ dependencies = [ [[package]] name = "zbus_macros" -version = "5.8.0" +version = "5.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5c8e4e14dcdd9d97a98b189cd1220f30e8394ad271e8c987da84f73693862c2" +checksum = "ef9859f68ee0c4ee2e8cde84737c78e3f4c54f946f2a38645d0d4c7a95327659" dependencies = [ "proc-macro-crate 3.3.0", "proc-macro2", @@ -8283,9 +8333,9 @@ dependencies = [ [[package]] name = "zerovec" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a05eb080e015ba39cc9e23bbe5e7fb04d5fb040350f99f34e338d5fdd294428" +checksum = "bdbb9122ea75b11bf96e7492afb723e8a7fbe12c67417aa95e7e3d18144d37cd" dependencies = [ "yoke", "zerofrom", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 827101ae..cb6ce415 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -3,7 +3,7 @@ members = ["cli", "common"] default-members = [".", "cli"] [workspace.dependencies] -defguard_wireguard_rs = { git = "https://github.com/DefGuard/wireguard-rs.git", rev = "v0.7.4" } +defguard_wireguard_rs = "0.7.5" [workspace.package] authors = ["Defguard"] @@ -27,8 +27,7 @@ version.workspace = true [build-dependencies] tauri-build = { version = "1.5", features = [] } -tonic-build = { version = "0.12" } -prost-build = { version = "0.13" } +tonic-prost-build = { version = "0.14" } vergen-git2 = { version = "1.0", features = ["build"] } [dependencies] @@ -41,7 +40,7 @@ dark-light = "2.0" defguard_wireguard_rs = { workspace = true, features = ["check_dependencies"] } dirs-next = "2.0" log = { version = "0.4", features = ["serde"] } -prost = "0.13" +prost = "0.14" regex = "1.11" reqwest = { version = "0.12", features = ["cookies", "json"] } # 0.21.2 causes config parsing errors @@ -50,24 +49,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.9" +struct-patch = "0.10" strum = { version = "0.27", 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" } @@ -76,15 +75,23 @@ thiserror = "2.0" time = { version = "0.3", features = ["formatting", "macros"] } tokio = { version = "1", features = ["macros", "rt-multi-thread", "signal"] } tokio-util = "0.7" -tonic = "0.12" +tonic = { version = "0.14", default-features = false, features = [ + "codegen", + "gzip", + "router", + "tls-native-roots", + "tls-ring", + "transport", +] } +tonic-prost = "0.14" tracing = "0.1" 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(unix)'.dependencies] diff --git a/src-tauri/build.rs b/src-tauri/build.rs index 04be1045..91455f0e 100644 --- a/src-tauri/build.rs +++ b/src-tauri/build.rs @@ -5,25 +5,24 @@ fn main() -> Result<(), Box> { let git2 = Git2Builder::default().branch(true).sha(true).build()?; Emitter::default().add_instructions(&git2)?.emit()?; - // compiling protos using path on build time - let mut config = prost_build::Config::new(); - // enable optional fields - config.protoc_arg("--experimental_allow_proto3_optional"); - // make sure empty DNS is deserialized correctly as None - config.type_attribute(".DeviceConfig", "#[serde_as]"); - config.field_attribute( - ".DeviceConfig.dns", - "#[serde_as(deserialize_as = \"NoneAsEmptyString\")]", - ); - // Make all messages serde-serializable - config.type_attribute(".", "#[derive(serde::Serialize,serde::Deserialize)]"); - tonic_build::configure().compile_protos_with_config( - config, - &["proto/client/client.proto", "proto/core/proxy.proto"], - &["proto/client", "proto/core"], - )?; + tonic_prost_build::configure() + // Enable optional fields. + .protoc_arg("--experimental_allow_proto3_optional") + // Make sure empty DNS is deserialized correctly as `None`. + .type_attribute(".DeviceConfig", "#[serde_as]") + .field_attribute( + ".DeviceConfig.dns", + "#[serde_as(deserialize_as = \"NoneAsEmptyString\")]", + ) + // Make all messages serde-serializable. + .type_attribute(".", "#[derive(serde::Serialize,serde::Deserialize)]") + .compile_protos( + &["proto/client/client.proto", "proto/core/proxy.proto"], + &["proto/client", "proto/core"], + )?; tauri_build::build(); + println!("cargo:rerun-if-changed=proto"); Ok(()) } diff --git a/src-tauri/cli/Cargo.toml b/src-tauri/cli/Cargo.toml index 44ddaeca..b8c6c080 100644 --- a/src-tauri/cli/Cargo.toml +++ b/src-tauri/cli/Cargo.toml @@ -8,14 +8,14 @@ rust-version.workspace = true version.workspace = true [build-dependencies] -prost-build = "0.13" +prost-build = "0.14" [dependencies] clap = { version = "4.5", features = ["cargo", "derive", "env"] } common = { path = "../common" } defguard_wireguard_rs = { workspace = true, features = ["check_dependencies"] } dirs-next = "2.0" -prost = "0.13" +prost = "0.14" reqwest = { version = "0.12", features = ["cookies", "json"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/src-tauri/cli/src/bin/dg.rs b/src-tauri/cli/src/bin/dg.rs index 036f56ad..2946d42a 100644 --- a/src-tauri/cli/src/bin/dg.rs +++ b/src-tauri/cli/src/bin/dg.rs @@ -1,7 +1,7 @@ -use core::fmt; #[cfg(not(windows))] use std::os::unix::fs::PermissionsExt; use std::{ + fmt, fs::{create_dir, OpenOptions}, net::IpAddr, path::{Path, PathBuf}, @@ -94,7 +94,7 @@ impl CliConfig { }; #[cfg(not(windows))] { - debug!("Setting config file permissions..."); + debug!("Setting config file permissions."); match file.metadata() { Ok(meta) => { let mut perms = meta.permissions(); @@ -138,8 +138,6 @@ enum CliError { TooManyDevices(usize), #[error(transparent)] WireGuard(#[from] WireguardInterfaceError), - #[error("Invalid address")] - InvalidAddress, #[error("Couldn't open CLI configuration at path: \"{0}\".")] ConfigNotFound(String), #[error("Couldn't parse CLI configuration at \"{0}\". Error details: {1}")] @@ -148,14 +146,15 @@ enum CliError { EnterpriseDisabled, #[error("Failed to save configuration at {0}: {1}")] ConfigSave(String, String), + #[error("Failed to find free TCP port")] + FreeTCPPort, } -async fn connect(config: CliConfig, trigger: Arc) -> Result<(), CliError> { +/// Connect to Defguard Gateway. +async fn connect(config: CliConfig, ifname: String, trigger: Arc) -> Result<(), CliError> { let network_name = config.device_config.network_name.clone(); - debug!("Connecting to network {network_name}..."); - let ifname = get_interface_name(&config.device.name); + debug!("Connecting to network {network_name}."); - // let wgapi = setup_wgapi(&ifname).expect("Failed to setup WireGuard API"); #[cfg(not(target_os = "macos"))] let wgapi = WGApi::::new(ifname.to_string()).expect("Failed to setup WireGuard API"); #[cfg(target_os = "macos")] @@ -163,7 +162,7 @@ async fn connect(config: CliConfig, trigger: Arc) -> Result<(), CliError #[cfg(not(windows))] { - // create new interface + // Create new interface. debug!("Creating new interface {ifname}"); wgapi .create_interface() @@ -183,7 +182,10 @@ async fn connect(config: CliConfig, trigger: Arc) -> Result<(), CliError search_domains.push(entry); } } - debug!("DNS configuration for interface {ifname}: DNS: {dns:?}, Search domains: {search_domains:?}"); + debug!( + "DNS configuration for interface {ifname}: DNS: {dns:?}, Search domains: \ + {search_domains:?}" + ); let peer_key = Key::from_str(&config.device_config.pubkey).unwrap(); let mut peer = Peer::new(peer_key); @@ -197,7 +199,18 @@ async fn connect(config: CliConfig, trigger: Arc) -> Result<(), CliError // peer.preshared_key = Some(peer_psk); // } - let allowed_ips: Vec<&str> = + let ip_addr_parser = |addr: &str| { + let ipaddrmask = addr.parse::(); + if let Err(err) = &ipaddrmask { + error!( + "Error parsing IP address `{addr}` while setting up interface: {err}. \ + Trying to parse the remaining addresses if any." + ); + } + ipaddrmask.ok() + }; + + peer.allowed_ips = //if location.route_all_traffic { // eprintln!("Using all traffic routing for location {location}: {DEFAULT_ROUTE_IPV4} {DEFAULT_ROUTE_IPV6}"); // vec![DEFAULT_ROUTE_IPV4.into(), DEFAULT_ROUTE_IPV6.into()] @@ -206,31 +219,23 @@ async fn connect(config: CliConfig, trigger: Arc) -> Result<(), CliError .device_config .allowed_ips .split(',') - .collect(); - for allowed_ip in allowed_ips { - match IpAddrMask::from_str(allowed_ip) { - Ok(addr) => { - peer.allowed_ips.push(addr); - } - Err(err) => { - error!( - "Error parsing IP address `{allowed_ip}` while setting up interface: {err}. \ - Trying to parse the remaining addresses if any." - ); - } - } - } + .filter_map(ip_addr_parser) + .collect::>(); debug!("Parsed allowed IPs: {:?}", peer.allowed_ips); - let Ok(address) = config.device_config.assigned_ip.parse() else { - error!("Invalid assigned IP address in device configuration"); - return Err(CliError::InvalidAddress); - }; + + let addresses = config + .device_config + .assigned_ip + .split(',') + .filter_map(ip_addr_parser) + .collect::>(); + debug!("Parsed assigned IPs: {:?}", addresses); let config = InterfaceConfiguration { name: config.instance_info.name.clone(), prvkey: config.private_key.to_string(), - addresses: vec![address], - port: u32::from(find_free_tcp_port().unwrap()), + addresses, + port: u32::from(find_free_tcp_port().ok_or(CliError::FreeTCPPort)?), peers: vec![peer.clone()], mtu: None, }; @@ -253,7 +258,10 @@ async fn connect(config: CliConfig, trigger: Arc) -> Result<(), CliError "No DNS configuration provided for interface {ifname}, skipping DNS configuration" ); } else { - debug!("The following DNS servers will be set: {dns:?}, search domains: {search_domains:?}"); + debug!( + "The following DNS servers will be set: {dns:?}, search domains: \ + {search_domains:?}" + ); wgapi .configure_dns(&dns, &search_domains) .expect("Failed to configure DNS for WireGuard interface"); @@ -265,10 +273,13 @@ async fn connect(config: CliConfig, trigger: Arc) -> Result<(), CliError trigger.notified().await; debug!( - "Closing the interface {ifname} for network {network_name} because of a received signal..." + "Closing the interface {ifname} for network {network_name} because of a received signal." ); if let Err(err) = wgapi.remove_interface() { - error!("Failed to close the interface {ifname} for network {network_name}: {err}. The interface may've been already closed or it's not available."); + error!( + "Failed to close the interface {ifname} for network {network_name}: {err}. The \ + interface may've been already closed or it's not available." + ); } else { info!("Connection to the network {network_name} has been terminated."); } @@ -285,7 +296,7 @@ struct ApiError { /// Enroll device. async fn enroll(base_url: &Url, token: String) -> Result { - debug!("Starting enrollment through the proxy at {base_url}..."); + debug!("Starting enrollment through Defguard Proxy at {base_url}."); let client = Client::builder().cookie_store(true).build()?; let mut url = base_url.clone(); url.set_path("/api/v1/enrollment/start"); @@ -297,8 +308,11 @@ async fn enroll(base_url: &Url, token: String) -> Result { let response: proto::EnrollmentStartResponse = if result.status() == StatusCode::OK { let result = result.json().await?; - debug!("Enrollment start request has been successfully sent to the proxy. Received a response, proceeding with the device configuration."); - trace!("Received response: {:?}", result); + debug!( + "Enrollment start request has been successfully sent to Defguard Proxy. Received a \ + response, proceeding with the device configuration." + ); + trace!("Received response: {result:?}"); result } else { let error: ApiError = result.json().await?; @@ -307,12 +321,10 @@ async fn enroll(base_url: &Url, token: String) -> Result { }; if response.instance.is_none() { - error!( - "InstanceInfo is missing from the received enrollment start response: {:?}", - response - ); + error!("InstanceInfo is missing from the received enrollment start response: {response:?}"); return Err(CliError::MissingData); } + // eprintln!("COOKIES {:?}", cookies.cookies(base_url)); // Generate a pair of WireGuard keys. let prvkey = Key::generate(); @@ -333,7 +345,10 @@ async fn enroll(base_url: &Url, token: String) -> Result { let response: proto::DeviceConfigResponse = if result.status() == StatusCode::OK { let result = result.json().await?; - debug!("The device public key has been successfully sent to the proxy. The device should be now configured on the server's end."); + debug!( + "The device public key has been successfully sent to Defguard Proxy. The device should \ + be now configured on the server's end." + ); result } else { let error: ApiError = result.json().await?; @@ -348,11 +363,11 @@ async fn enroll(base_url: &Url, token: String) -> Result { return Err(CliError::TooManyDevices(count)); } let Some(instance_info) = response.instance else { - error!("Missing InstanceInfo in the configuration received from the proxy."); + error!("Missing InstanceInfo in the configuration received from Defguard Proxy."); return Err(CliError::MissingData); }; let Some(device) = response.device else { - error!("Missing Device in the configuration received from the proxy."); + error!("Missing Device in the configuration received from Defguard Proxy."); return Err(CliError::MissingData); }; @@ -363,7 +378,7 @@ async fn enroll(base_url: &Url, token: String) -> Result { instance_info, token: response.token, }; - debug!("Enrollment done, returning the received configuration..."); + debug!("Enrollment done, returning the received configuration."); Ok(config) } @@ -425,10 +440,13 @@ async fn fetch_config( /// Poll configuration from Defguard proxy in regular intervals. /// Exit when `DeviceConfig` differs from the current one. async fn poll_config(config: &mut CliConfig) { - debug!("Starting the configuration polling task..."); + debug!("Starting the configuration polling task."); // sanity check let Some(token) = config.clone().token else { - debug!("No polling token found in the CLI configuration. Make sure you are using the latest Defguard version. Exiting..."); + debug!( + "No polling token found in the CLI configuration. Make sure you are using the latest \ + Defguard version. Exiting." + ); return; }; let client = match Client::builder().cookie_store(true).build() { @@ -449,31 +467,33 @@ async fn poll_config(config: &mut CliConfig) { } }; url.set_path("/api/v1/poll"); - debug!("Config polling setup done, starting the polling loop..."); + debug!("Config polling setup done, starting the polling loop."); let mut interval = interval(INTERVAL_SECONDS); loop { interval.tick().await; - debug!("Polling network configuration from proxy..."); + debug!("Polling network configuration from proxy."); match fetch_config(&client, url.clone(), token.clone()).await { Ok(device_config) => { if config.device_config != device_config { - debug!("Network configuration has changed, re-configuring..."); + debug!("Network configuration has changed, re-configuring."); trace!( - "Old configuration: {:?}. New configuration: {:?}.", + "Old configuration: {:?}. New configuration: {device_config:?}.", config.device_config, - device_config ); config.device_config = device_config; debug!("New configuration has been successfully applied."); break; } - debug!("Network configuration has not changed. Continuing..."); + debug!("Network configuration has not changed. Continuing."); } Err(CliError::EnterpriseDisabled) => { - debug!("Enterprise features are disabled on this Defguard instance. Skipping..."); + debug!("Enterprise features are disabled on this Defguard instance. Skipping."); } Err(CliError::Reqwest(err)) => { - warn!("Failed to make network request to proxy ({url}): {err}. Check your network connection."); + warn!( + "Failed to make network request to proxy ({url}): {err}. Check your network \ + connection." + ); } Err(err) => { warn!("Failed to fetch configuration from proxy ({url}): {err}"); @@ -545,7 +565,10 @@ async fn main() { .subcommand_required(false) .subcommand( Command::new("enroll") - .about("Perform the enrollment and configuration. Use this first to set up the device.") + .about( + "Perform the enrollment and configuration. Use this first to set up the \ + device.", + ) .arg(token_opt) .arg(url_opt), ) @@ -570,8 +593,8 @@ async fn main() { .with(tracing_subscriber::fmt::layer()) .init(); - debug!("Starting CLI..."); - debug!("Getting configuration path..."); + debug!("Starting CLI."); + debug!("Getting configuration path."); // Obtain configuration file path. let config_path = match matches.get_one::("config") { Some(path) => path.clone(), @@ -587,7 +610,10 @@ async fn main() { path.push("config.json"); path } else { - error!("Default configuration path is not available on this platform. Please, specify it explicitly."); + error!( + "Default configuration path is not available on this platform. Please, \ + specify it explicitly." + ); return; } } @@ -595,7 +621,7 @@ async fn main() { debug!("The following configuration will be used: {config_path:?}"); if let Some(("enroll", submatches)) = matches.subcommand() { - debug!("Enrollment command has been selected, starting enrollment..."); + debug!("Enrollment command has been selected, starting enrollment."); let token = submatches .get_one::("token") .expect("No enrollment token was provided or it's invalid") @@ -607,48 +633,57 @@ async fn main() { let config = enroll(url, token) .await .expect("The enrollment process has failed"); - debug!("Successfully enrolled the device, saving the configuration..."); + debug!("Successfully enrolled the device, saving the configuration."); if let Err(err) = config.save(&config_path) { error!("{err}"); return; } - info!("Device has been successfully enrolled and the CLI configuration has been saved to {config_path:?}"); + info!( + "Device has been successfully enrolled and the CLI configuration has been saved to \ + {config_path:?}" + ); } else { - debug!("No command has been selected, trying to proceed with establishing a connection..."); + debug!("No command has been selected, trying to proceed with establishing a connection."); let mut config = match CliConfig::load(&config_path) { Ok(config) => config, - Err(err) => match err { - CliError::ConfigNotFound(path) => { - error!("No CLI confioguration file found at \"{path}\". \ - Proceed with enrollment first using \"dg enroll -t -u \" or pass a valid configuration file path using the \"--config\" option. Use \"dg --help\" to display all options."); - return; - } - _ => { - error!("Failed to load CLI configuration: {err}"); + Err(err) => { + if let CliError::ConfigNotFound(path) = err { + error!( + "No CLI confioguration file found at \"{path}\". Proceed with \ + enrollment first using \"dg enroll -t -u \" or pass a valid \ + configuration file path using the \"--config\" option. Use \"dg --help\" \ + to display all options." + ); return; } - }, + error!("Failed to load CLI configuration: {err}"); + return; + } }; info!("Using the following CLI configuration: {config_path:?}"); debug!("Successfully loaded CLI configuration"); - trace!("CLI configuration: {:?}", config); + trace!("CLI configuration: {config:?}"); let trigger = Arc::new(Notify::new()); let mut perpetuum = true; - debug!("Starting the main CLI loop..."); + + // Network interface name should not change in the loop below. + let ifname = get_interface_name(&config.device.name); + + debug!("Starting the main CLI loop."); while perpetuum { - debug!("Starting the connection task..."); + debug!("Starting the connection task."); // Must be spawned as a separate task, otherwise trigger won't reach it. - let task = tokio::spawn(connect(config.clone(), trigger.clone())); + let task = tokio::spawn(connect(config.clone(), ifname.clone(), trigger.clone())); debug!("Connection task has been spawned."); // After cancelling the connection a given task should wait for cleanup confirmation. select! { biased; () = wait_for_hangup() => { - info!("Re-configuring..."); + info!("Re-configuring."); trigger.notify_one(); match CliConfig::load(&config_path) { Ok(new_config) => { - info!("Configuration has been reloaded, resetting the connection..."); + info!("Configuration has been reloaded, resetting the connection."); config = new_config; } Err(err) => { @@ -660,12 +695,13 @@ async fn main() { }, _ = ctrl_c() => { trigger.notify_one(); - debug!("Quitting and shutting down the connection..."); + debug!("Quitting and shutting down the connection."); perpetuum = false; trigger.notified().await; }, () = poll_config(&mut config), if config.token.is_some() => { - info!("Location configuration has changed, re-configuring and resetting the connection..."); + info!("Location configuration has changed, re-configuring and resetting the \ + connection."); trigger.notify_one(); trigger.notified().await; }, diff --git a/src-tauri/proto b/src-tauri/proto index b9f24ac4..5d677ae6 160000 --- a/src-tauri/proto +++ b/src-tauri/proto @@ -1 +1 @@ -Subproject commit b9f24ac41326bffe4c7e72019ccc8a785f6bd343 +Subproject commit 5d677ae6f5abbf9f7417396dc78ece11d97687b1 diff --git a/src-tauri/src/periodic/purge_stats.rs b/src-tauri/src/periodic/purge_stats.rs index 84f0613b..ff5e27f1 100644 --- a/src-tauri/src/periodic/purge_stats.rs +++ b/src-tauri/src/periodic/purge_stats.rs @@ -52,7 +52,7 @@ pub async fn purge_stats(handle: AppHandle) { error!( "Failed to commit database transaction for stats purging: {err}. Retrying in {}h", PURGE_INTERVAL.as_secs() / 3600 - ) + ); } } } diff --git a/src-tauri/src/utils.rs b/src-tauri/src/utils.rs index c5a89032..ac50fac9 100644 --- a/src-tauri/src/utils.rs +++ b/src-tauri/src/utils.rs @@ -296,8 +296,9 @@ pub(crate) async fn stats_handler( // commit transaction if let Err(err) = transaction.commit().await { error!( - "Failed to commit database transaction for saving location/tunnel stats: {err}", - ) + "Failed to commit database transaction for saving location/tunnel stats: \ + {err}", + ); } } Ok(None) => { From f6dd2b7797d659e99ec63a93db5acb4cc5c3c870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Ciarcin=CC=81ski?= Date: Tue, 5 Aug 2025 16:12:55 +0200 Subject: [PATCH 2/3] Remove commented code --- src-tauri/cli/src/bin/dg.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src-tauri/cli/src/bin/dg.rs b/src-tauri/cli/src/bin/dg.rs index 2946d42a..b8f1e5c1 100644 --- a/src-tauri/cli/src/bin/dg.rs +++ b/src-tauri/cli/src/bin/dg.rs @@ -324,7 +324,6 @@ async fn enroll(base_url: &Url, token: String) -> Result { error!("InstanceInfo is missing from the received enrollment start response: {response:?}"); return Err(CliError::MissingData); } - // eprintln!("COOKIES {:?}", cookies.cookies(base_url)); // Generate a pair of WireGuard keys. let prvkey = Key::generate(); From feb999626bf8477e09f4c17c41881477b7aae6af Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 5 Aug 2025 20:29:26 +0200 Subject: [PATCH 3/3] Fix typo Co-authored-by: Aleksander <170264518+t-aleksander@users.noreply.github.com> --- src-tauri/cli/src/bin/dg.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-tauri/cli/src/bin/dg.rs b/src-tauri/cli/src/bin/dg.rs index b8f1e5c1..3f94f339 100644 --- a/src-tauri/cli/src/bin/dg.rs +++ b/src-tauri/cli/src/bin/dg.rs @@ -648,7 +648,7 @@ async fn main() { Err(err) => { if let CliError::ConfigNotFound(path) = err { error!( - "No CLI confioguration file found at \"{path}\". Proceed with \ + "No CLI configuration file found at \"{path}\". Proceed with \ enrollment first using \"dg enroll -t -u \" or pass a valid \ configuration file path using the \"--config\" option. Use \"dg --help\" \ to display all options."