diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index ddc2c46a..fc58e2ab 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -246,7 +246,7 @@ dependencies = [ "memchr", "serde", "serde_derive", - "winnow 0.7.13", + "winnow 0.7.14", ] [[package]] @@ -693,9 +693,9 @@ dependencies = [ [[package]] name = "borsh" -version = "1.5.7" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad8646f98db542e39fc66e68a20b2144f6a732636df7c2354e74645faaa433ce" +checksum = "d1da5ab77c1437701eeff7c88d968729e7766172279eab0676857b3d63af7a6f" dependencies = [ "borsh-derive", "cfg_aliases", @@ -703,9 +703,9 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "1.5.7" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdd1d3c0c2f5833f22386f252fe8ed005c7f59fdcddeef025c01b4c3b9fd9ac3" +checksum = "0686c856aa6aac0c4498f936d7d6a02df690f614c03e4d906d1018062b5c5e2c" dependencies = [ "once_cell", "proc-macro-crate 3.4.0", @@ -871,9 +871,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.47" +version = "1.2.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd405d82c84ff7f35739f175f67d8b9fb7687a0e84ccdc78bd3568839827cf07" +checksum = "c481bdbf0ed3b892f6f806287d72acd515b352a4ec27a208489b8c1bc839633a" dependencies = [ "find-msvc-tools", "jobserver", @@ -1172,9 +1172,9 @@ dependencies = [ [[package]] name = "crc" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9710d3b3739c2e349eb44fe848ad0b7c8cb1e42bd87ee49371df2f7acaf3e675" +checksum = "5eb8a2a1cd12ab0d987a5d5e825195d372001a4094a0376319d5a0ad71c1ba0d" dependencies = [ "crc-catalog", ] @@ -1664,9 +1664,9 @@ dependencies = [ [[package]] name = "dlopen2" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b54f373ccf864bf587a89e880fb7610f8d73f3045f13580948ccbcaff26febff" +checksum = "8d65cde5fb0c42a3d5882d99807698b459f5928de035fa7f547c784fb7b34219" dependencies = [ "dlopen2_derive", "libc", @@ -1676,9 +1676,9 @@ dependencies = [ [[package]] name = "dlopen2_derive" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "788160fb30de9cdd857af31c6a2675904b16ece8fc2737b2c7127ba368c9d0f4" +checksum = "95f4a04e1bfbfa4835a6073177aafb95ead4de0722dbb339195fdc7e0a09599b" dependencies = [ "proc-macro2", "quote", @@ -1791,9 +1791,9 @@ dependencies = [ [[package]] name = "endi" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3d8a32ae18130a3c84dd492d4215c3d913c3b07c6b63c2eb3eb7ff1101ab7bf" +checksum = "66b7e2430c6dff6a955451e2cfc438f09cea1965a9d6f87f7e3b90decc014099" [[package]] name = "enumflags2" @@ -2661,12 +2661,11 @@ dependencies = [ [[package]] name = "http" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" dependencies = [ "bytes", - "fnv", "itoa", ] @@ -3132,9 +3131,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.82" +version = "0.3.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65" +checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8" dependencies = [ "once_cell", "wasm-bindgen", @@ -3238,9 +3237,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.177" +version = "0.2.178" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" +checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" [[package]] name = "libgit2-sys" @@ -3349,11 +3348,11 @@ dependencies = [ [[package]] name = "log" -version = "0.4.28" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" dependencies = [ - "serde", + "serde_core", "value-bag", ] @@ -3371,9 +3370,9 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" [[package]] name = "mac-notification-sys" -version = "0.6.8" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee70bb2bba058d58e252d2944582d634fc884fc9c489a966d428dedcf653e97" +checksum = "65fd3f75411f4725061682ed91f131946e912859d0044d39c4ec0aac818d7621" dependencies = [ "cc", "objc2 0.6.3", @@ -3487,9 +3486,9 @@ dependencies = [ [[package]] name = "moxcms" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fbdd3d7436f8b5e892b8b7ea114271ff0fa00bc5acae845d53b07d498616ef6" +checksum = "80986bbbcf925ebd3be54c26613d861255284584501595cf418320c078945608" dependencies = [ "num-traits", "pxfm", @@ -4829,9 +4828,9 @@ dependencies = [ [[package]] name = "pxfm" -version = "0.1.25" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3cbdf373972bf78df4d3b518d07003938e2c7d1fb5891e55f9cb6df57009d84" +checksum = "b3502d6155304a4173a5f2c34b52b7ed0dd085890326cb50fd625fdf39e86b3b" dependencies = [ "num-traits", ] @@ -5374,9 +5373,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.13.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94182ad936a0c91c324cd46c6511b9510ed16af436d7b5bab34beab0afd55f7a" +checksum = "708c0f9d5f54ba0272468c1d306a52c495b31fa155e91bc25371e6df7996908c" dependencies = [ "web-time", "zeroize", @@ -5685,9 +5684,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.16.0" +version = "3.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10574371d41b0d9b2cff89418eda27da52bcaff2cc8741db26382a77c29131f1" +checksum = "4fa237f2807440d238e0364a218270b98f767a00d3dada77b1c53ae88940e2e7" dependencies = [ "base64 0.22.1", "chrono", @@ -5704,9 +5703,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.16.0" +version = "3.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a72d8216842fdd57820dc78d840bef99248e35fb2554ff923319e60f2d686b" +checksum = "52a8e3ca0ca629121f70ab50f95249e5a6f925cc0f6ffe8256c45b728875706c" dependencies = [ "darling 0.21.3", "proc-macro2", @@ -6382,9 +6381,9 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tauri" -version = "2.9.3" +version = "2.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e492485dd390b35f7497401f67694f46161a2a00ffd800938d5dd3c898fb9d8" +checksum = "15524fc7959bfcaa051ba6d0b3fb1ef18e978de2176c7c6acb977f7fd14d35c7" dependencies = [ "anyhow", "bytes", @@ -6434,9 +6433,9 @@ dependencies = [ [[package]] name = "tauri-build" -version = "2.5.2" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87d6f8cafe6a75514ce5333f115b7b1866e8e68d9672bf4ca89fc0f35697ea9d" +checksum = "17fcb8819fd16463512a12f531d44826ce566f486d7ccd211c9c8cebdaec4e08" dependencies = [ "anyhow", "cargo_toml", @@ -6456,9 +6455,9 @@ dependencies = [ [[package]] name = "tauri-codegen" -version = "2.5.1" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7ef707148f0755110ca54377560ab891d722de4d53297595380a748026f139f" +checksum = "9fa9844cefcf99554a16e0a278156ae73b0d8680bbc0e2ad1e4287aadd8489cf" dependencies = [ "base64 0.22.1", "brotli", @@ -6483,9 +6482,9 @@ dependencies = [ [[package]] name = "tauri-macros" -version = "2.5.1" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71664fd715ee6e382c05345ad258d6d1d50f90cf1b58c0aa726638b33c2a075d" +checksum = "3764a12f886d8245e66b7ee9b43ccc47883399be2019a61d80cf0f4117446fde" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -6497,9 +6496,9 @@ dependencies = [ [[package]] name = "tauri-plugin" -version = "2.5.1" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076c78a474a7247c90cad0b6e87e593c4c620ed4efdb79cbe0214f0021f6c39d" +checksum = "0e1d0a4860b7ff570c891e1d2a586bf1ede205ff858fbc305e0b5ae5d14c1377" dependencies = [ "anyhow", "glob", @@ -6736,9 +6735,9 @@ dependencies = [ [[package]] name = "tauri-runtime" -version = "2.9.1" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9368f09358496f2229313fccb37682ad116b7f46fa76981efe116994a0628926" +checksum = "87f766fe9f3d1efc4b59b17e7a891ad5ed195fa8d23582abb02e6c9a01137892" dependencies = [ "cookie", "dpi", @@ -6761,9 +6760,9 @@ dependencies = [ [[package]] name = "tauri-runtime-wry" -version = "2.9.1" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "929f5df216f5c02a9e894554401bcdab6eec3e39ec6a4a7731c7067fc8688a93" +checksum = "7950f3bde6bcca6655bc5e76d3d6ec587ceb81032851ab4ddbe1f508bdea2729" dependencies = [ "gtk", "http", @@ -6788,9 +6787,9 @@ dependencies = [ [[package]] name = "tauri-utils" -version = "2.8.0" +version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6b8bbe426abdbf52d050e52ed693130dbd68375b9ad82a3fb17efb4c8d85673" +checksum = "76a423c51176eb3616ee9b516a9fa67fed5f0e78baaba680e44eb5dd2cc37490" dependencies = [ "anyhow", "brotli", @@ -7107,7 +7106,7 @@ dependencies = [ "toml_datetime 0.7.3", "toml_parser", "toml_writer", - "winnow 0.7.13", + "winnow 0.7.14", ] [[package]] @@ -7161,7 +7160,7 @@ dependencies = [ "indexmap 2.12.1", "toml_datetime 0.7.3", "toml_parser", - "winnow 0.7.13", + "winnow 0.7.14", ] [[package]] @@ -7170,7 +7169,7 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0cbe268d35bdb4bb5a56a2de88d0ad0eb70af5384a99d648cd4b3d04039800e" dependencies = [ - "winnow 0.7.13", + "winnow 0.7.14", ] [[package]] @@ -7271,9 +7270,9 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" +checksum = "9cf146f99d442e8e68e585f5d798ccd3cad9a7835b917e09728880a862706456" dependencies = [ "bitflags 2.10.0", "bytes", @@ -7301,9 +7300,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.41" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +checksum = "2d15d90a0b5c19378952d479dc858407149d7bb45a14de0142f6c534b16fc647" dependencies = [ "log", "pin-project-lite", @@ -7313,21 +7312,21 @@ dependencies = [ [[package]] name = "tracing-appender" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" +checksum = "786d480bce6247ab75f005b14ae1624ad978d3029d9113f0a22fa1ac773faeaf" dependencies = [ "crossbeam-channel", - "thiserror 1.0.69", + "thiserror 2.0.17", "time", "tracing-subscriber", ] [[package]] name = "tracing-attributes" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", @@ -7336,9 +7335,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.34" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" +checksum = "7a04e24fab5c89c6a36eb8558c9656f30d81de51dfa4d3b45f26b21d61fa0a6c" dependencies = [ "once_cell", "valuable", @@ -7367,9 +7366,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.20" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" +checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" dependencies = [ "matchers", "nu-ansi-term", @@ -7727,13 +7726,13 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.18.1" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2" +checksum = "e2e054861b4bd027cd373e18e8d8d8e6548085000e41290d95ce0c373a654b4a" dependencies = [ "getrandom 0.3.4", "js-sys", - "serde", + "serde_core", "wasm-bindgen", ] @@ -7874,9 +7873,9 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" [[package]] name = "wasm-bindgen" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60" +checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd" dependencies = [ "cfg-if", "once_cell", @@ -7887,9 +7886,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.55" +version = "0.4.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "551f88106c6d5e7ccc7cd9a16f312dd3b5d36ea8b4954304657d5dfba115d4a0" +checksum = "836d9622d604feee9e5de25ac10e3ea5f2d65b41eac0d9ce72eb5deae707ce7c" dependencies = [ "cfg-if", "js-sys", @@ -7900,9 +7899,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2" +checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -7910,9 +7909,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc" +checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40" dependencies = [ "bumpalo", "proc-macro2", @@ -7923,9 +7922,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76" +checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4" dependencies = [ "unicode-ident", ] @@ -8018,9 +8017,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.82" +version = "0.3.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a1f95c0d03a47f4ae1f7a64643a6bb97465d9b740f0fa8f90ea33915c99a9a1" +checksum = "9b32828d774c412041098d182a8b38b16ea816958e07cf40eec2bc080ae137ac" dependencies = [ "js-sys", "wasm-bindgen", @@ -8785,9 +8784,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.7.13" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" +checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829" dependencies = [ "memchr", ] @@ -9015,7 +9014,7 @@ dependencies = [ "uds_windows", "uuid", "windows-sys 0.61.2", - "winnow 0.7.13", + "winnow 0.7.14", "zbus_macros", "zbus_names", "zvariant", @@ -9044,24 +9043,24 @@ checksum = "7be68e64bf6ce8db94f63e72f0c7eb9a60d733f7e0499e628dfab0f84d6bcb97" dependencies = [ "serde", "static_assertions", - "winnow 0.7.13", + "winnow 0.7.14", "zvariant", ] [[package]] name = "zerocopy" -version = "0.8.28" +version = "0.8.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43fa6694ed34d6e57407afbccdeecfa268c470a7d2a5b0cf49ce9fcc345afb90" +checksum = "fd74ec98b9250adb3ca554bdde269adf631549f51d8a8f8f0a10b50f1cb298c3" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.28" +version = "0.8.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c640b22cd9817fae95be82f0d2f90b11f7605f6c319d16705c459b27ac2cbc26" +checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a" dependencies = [ "proc-macro2", "quote", @@ -9167,7 +9166,7 @@ dependencies = [ "enumflags2", "serde", "url", - "winnow 0.7.13", + "winnow 0.7.14", "zvariant_derive", "zvariant_utils", ] @@ -9195,5 +9194,5 @@ dependencies = [ "quote", "serde", "syn 2.0.111", - "winnow 0.7.13", + "winnow 0.7.14", ] diff --git a/src-tauri/src/apple.rs b/src-tauri/src/apple.rs index a3af555c..57b997d8 100644 --- a/src-tauri/src/apple.rs +++ b/src-tauri/src/apple.rs @@ -31,6 +31,7 @@ use objc2_network_extension::{ use serde::{Deserialize, Serialize}; use sqlx::SqliteExecutor; use tauri::{AppHandle, Emitter, Manager}; +use tracing::Level; use crate::{ active_connections::find_connection, @@ -41,6 +42,7 @@ use crate::{ }, error::Error, events::EventKey, + log_watcher::service_log_watcher::spawn_log_watcher_task, utils::{DEFAULT_ROUTE_IPV4, DEFAULT_ROUTE_IPV6}, ConnectionType, }; @@ -62,6 +64,8 @@ static VPN_STATE_UPDATE_COMMS: LazyLock<( (Mutex::new(tx), Mutex::new(Some(rx))) }); +const SYSTEM_SYNC_DELAY_MS: u64 = 500; + /// Thread responsible for handling VPN status update requests. /// This is an async function. /// It has access to the `AppHandle` to be able to emit events. @@ -78,6 +82,7 @@ pub async fn connection_state_update_thread(app_handle: &AppHandle) { debug!("Waiting for status update message from channel..."); debug!("Status update message received, synchronizing state..."); + tokio::time::sleep(Duration::from_millis(SYSTEM_SYNC_DELAY_MS)).await; sync_connections_with_system(app_handle).await; debug!("Processed status update message."); @@ -128,6 +133,26 @@ pub async fn sync_connections_with_system(app_handle: &AppHandle) { app_handle .emit(EventKey::ConnectionChanged.into(), ()) .unwrap(); + + debug!( + "Spawning log watcher for location {} (started from system settings)", + location.name + ); + if let Err(e) = spawn_log_watcher_task( + app_handle.clone(), + location.id, + location.name.clone(), + ConnectionType::Location, + Level::DEBUG, + None, + ) + .await + { + warn!( + "Failed to spawn log watcher for location {}: {e}", + location.name + ); + } } } Some(NEVPNStatus::Disconnected) => { @@ -197,6 +222,27 @@ pub async fn sync_connections_with_system(app_handle: &AppHandle) { app_handle .emit(EventKey::ConnectionChanged.into(), ()) .unwrap(); + + // Spawn log watcher for this tunnel (VPN was started from system settings) + debug!( + "Spawning log watcher for tunnel {} (started from system settings)", + tunnel.name + ); + if let Err(e) = spawn_log_watcher_task( + app_handle.clone(), + tunnel.id, + tunnel.name.clone(), + ConnectionType::Tunnel, + Level::DEBUG, + None, + ) + .await + { + warn!( + "Failed to spawn log watcher for tunnel {}: {e}", + tunnel.name + ); + } } } Some(NEVPNStatus::Disconnected) => { @@ -676,7 +722,7 @@ impl TunnelConfiguration { info!("VPN started"); } } else { - error!( + debug!( "Couldn't find configuration from system settings for {}", self.name ); @@ -691,7 +737,7 @@ pub(crate) fn remove_config_for_location(location: &Location) { provider_manager.removeFromPreferencesWithCompletionHandler(None); } } else { - error!( + debug!( "Couldn't find configuration in system settings for location {}", location.name ); @@ -705,7 +751,7 @@ pub(crate) fn remove_config_for_tunnel(tunnel: &Tunnel) { provider_manager.removeFromPreferencesWithCompletionHandler(None); } } else { - error!( + debug!( "Couldn't find configuration in system settings for tunnel {}", tunnel.name ); @@ -716,7 +762,7 @@ pub(crate) fn remove_config_for_tunnel(tunnel: &Tunnel) { pub(crate) fn stop_tunnel_for_location(location: &Location) -> bool { manager_for_key_and_value("locationId", location.id).map_or_else( || { - error!( + debug!( "Couldn't find configuration in system settings for location {}", location.name ); @@ -726,6 +772,7 @@ pub(crate) fn stop_tunnel_for_location(location: &Location) -> bool { unsafe { provider_manager.connection().stopVPNTunnel(); } + info!("VPN stopped"); true }, @@ -736,7 +783,7 @@ pub(crate) fn stop_tunnel_for_location(location: &Location) -> bool { pub(crate) fn stop_tunnel_for_tunnel(tunnel: &Tunnel) -> bool { manager_for_key_and_value("tunnelId", tunnel.id).map_or_else( || { - error!( + debug!( "Couldn't find configuration in system settings for location {}", tunnel.name ); @@ -746,6 +793,7 @@ pub(crate) fn stop_tunnel_for_tunnel(tunnel: &Tunnel) -> bool { unsafe { provider_manager.connection().stopVPNTunnel(); } + info!("VPN stopped"); true }, @@ -756,7 +804,7 @@ pub(crate) fn stop_tunnel_for_tunnel(tunnel: &Tunnel) -> bool { pub(crate) fn get_location_status(location: &Location) -> Option { manager_for_key_and_value("locationId", location.id).map_or_else( || { - error!( + debug!( "Couldn't find configuration in system settings for location {}", location.name ); @@ -773,7 +821,7 @@ pub(crate) fn get_location_status(location: &Location) -> Option) -> Option { manager_for_key_and_value("tunnelId", tunnel.id).map_or_else( || { - error!( + debug!( "Couldn't find configuration in system settings for tunnel {}", tunnel.name ); diff --git a/src-tauri/src/log_watcher/global_log_watcher.rs b/src-tauri/src/log_watcher/global_log_watcher.rs index 8a7a1abc..ee698dae 100644 --- a/src-tauri/src/log_watcher/global_log_watcher.rs +++ b/src-tauri/src/log_watcher/global_log_watcher.rs @@ -21,7 +21,7 @@ use tokio_util::sync::CancellationToken; use tracing::Level; #[cfg(target_os = "macos")] -use crate::log_watcher::get_vpn_extension_log_path; +use crate::log_watcher::get_vpn_extension_log_dir_path; use crate::{ appstate::AppState, error::Error, @@ -31,7 +31,7 @@ use crate::{ use crate::{log_watcher::extract_timestamp, utils::get_service_log_dir}; #[cfg(target_os = "macos")] -const VPN_EXTENSION_LOG_FILENAME: &str = "vpn-extension.log"; +pub(crate) const VPN_EXTENSION_LOG_FILENAME: &str = "vpn-extension.log"; /// Helper struct to handle log directory logic #[derive(Debug)] @@ -60,7 +60,7 @@ impl LogDirs { })?; #[cfg(target_os = "macos")] - let vpn_extension_log_dir = get_vpn_extension_log_path()?; + let vpn_extension_log_dir = get_vpn_extension_log_dir_path()?; #[cfg(not(target_os = "macos"))] debug!( diff --git a/src-tauri/src/log_watcher/mod.rs b/src-tauri/src/log_watcher/mod.rs index 0b994a33..b2c5bb8d 100644 --- a/src-tauri/src/log_watcher/mod.rs +++ b/src-tauri/src/log_watcher/mod.rs @@ -82,7 +82,7 @@ static LOG_LINE_REGEX: LazyLock = LazyLock::new(|| { /// Get the VPN extension log file path on macOS #[cfg(target_os = "macos")] -fn get_vpn_extension_log_path() -> Result { +fn get_vpn_extension_log_dir_path() -> Result { use objc2_foundation::{ns_string, NSFileManager}; let manager = NSFileManager::defaultManager(); diff --git a/src-tauri/src/log_watcher/service_log_watcher.rs b/src-tauri/src/log_watcher/service_log_watcher.rs index 1f1936ff..f7f4c931 100644 --- a/src-tauri/src/log_watcher/service_log_watcher.rs +++ b/src-tauri/src/log_watcher/service_log_watcher.rs @@ -490,7 +490,9 @@ pub async fn spawn_log_watcher_task( log_level: Level, from: Option, ) -> Result { - use crate::log_watcher::get_vpn_extension_log_path; + use crate::log_watcher::{ + get_vpn_extension_log_dir_path, global_log_watcher::VPN_EXTENSION_LOG_FILENAME, + }; debug!( "Spawning VPN extension log watcher task for location ID {location_id}, interface {interface_name}" @@ -507,7 +509,9 @@ pub async fn spawn_log_watcher_task( let event_topic = format!("log-update-{connection_type_str}-{location_id}"); debug!("Using the following event topic for the VPN extension log watcher: {event_topic}"); - let log_file = get_vpn_extension_log_path().map_err(|e| Error::InternalError(e.to_string()))?; + let log_dir = + get_vpn_extension_log_dir_path().map_err(|e| Error::InternalError(e.to_string()))?; + let log_file = log_dir.join(VPN_EXTENSION_LOG_FILENAME); debug!("VPN extension log file path: {}", log_file.display()); let topic_clone = event_topic.clone(); @@ -566,15 +570,20 @@ pub fn stop_log_watcher_task(handle: &AppHandle, interface_name: &str) -> Result .lock() .expect("Failed to lock log watchers mutex"); - if let Some(token) = log_watchers.remove(interface_name) { - debug!("Using cancellation token for service log watcher on interface {interface_name}"); - token.cancel(); - debug!("Service log watcher for interface {interface_name} stopped"); - Ok(()) - } else { - debug!( - "Service log watcher for interface {interface_name} couldn't be found, nothing to stop" - ); - Err(Error::NotFound) - } + log_watchers.remove(interface_name).map_or_else( + || { + warn!( + "Service log watcher for interface {interface_name} couldn't be found, nothing to stop" + ); + Ok(()) + }, + |token| { + debug!( + "Using cancellation token for service log watcher on interface {interface_name}" + ); + token.cancel(); + debug!("Service log watcher for interface {interface_name} stopped"); + Ok(()) + }, + ) } diff --git a/src/pages/client/pages/ClientInstancePage/components/LocationsList/components/LocationsDetailView/components/LocationLogs/LocationLogs.tsx b/src/pages/client/pages/ClientInstancePage/components/LocationsList/components/LocationsDetailView/components/LocationLogs/LocationLogs.tsx index 56cdfce1..603d77ab 100644 --- a/src/pages/client/pages/ClientInstancePage/components/LocationsList/components/LocationsDetailView/components/LocationLogs/LocationLogs.tsx +++ b/src/pages/client/pages/ClientInstancePage/components/LocationsList/components/LocationsDetailView/components/LocationLogs/LocationLogs.tsx @@ -62,7 +62,11 @@ export const LocationLogs = ({ locationId, connectionType }: Props) => { logsContainerElement.current && filterLogByLevel(locationLogLevelRef.current, item.level) ) { - const messageString = `${item.timestamp} ${item.level} ${item.fields.message}`; + const utcTimestamp = item.timestamp.endsWith('Z') + ? item.timestamp + : `${item.timestamp}Z`; + const dateTime = new Date(utcTimestamp).toLocaleString(); + const messageString = `${dateTime} ${item.level} ${item.fields.message}`; const element = createLogLineElement(messageString); const scrollAfterAppend = logsContainerElement.current.scrollHeight - diff --git a/src/pages/client/pages/ClientSettingsPage/components/GlobalLogs/GlobalLogs.tsx b/src/pages/client/pages/ClientSettingsPage/components/GlobalLogs/GlobalLogs.tsx index c6f14053..c7fc7162 100644 --- a/src/pages/client/pages/ClientSettingsPage/components/GlobalLogs/GlobalLogs.tsx +++ b/src/pages/client/pages/ClientSettingsPage/components/GlobalLogs/GlobalLogs.tsx @@ -30,20 +30,24 @@ export const GlobalLogs = () => { const { startGlobalLogWatcher, stopGlobalLogWatcher } = clientApi; const handleLogsDownload = async () => { - const path = await save({ - filters: [ - { - name: 'Logs', - extensions: ['txt', 'log'], - }, - ], - }); + try { + const path = await save({ + filters: [ + { + name: 'Logs', + extensions: ['txt', 'log'], + }, + ], + }); - if (path) { - const logs = getAllLogs(); - await writeTextFile(path, logs); - } else { - error('Failed to save logs! Path was null'); + if (path) { + const logs = getAllLogs(); + await writeTextFile(path, logs); + } else { + throw new Error('No path selected'); + } + } catch (e) { + error(`Failed to save logs: ${e}`); } }; @@ -72,7 +76,10 @@ export const GlobalLogs = () => { filterLogByLevel(globalLogLevelRef.current, item.level) && filterLogBySource(logSourceRef.current, item.source) ) { - const dateTime = new Date(item.timestamp).toLocaleString(); + const utcTimestamp = item.timestamp.endsWith('Z') + ? item.timestamp + : `${item.timestamp}Z`; + const dateTime = new Date(utcTimestamp).toLocaleString(); const messageString = `[${dateTime}][${item.level}][${item.source}] ${item.fields.message}`; const element = createLogLineElement(messageString); const scrollAfterAppend = diff --git a/swift/boringtun b/swift/boringtun index 20d92e55..7ba620b3 160000 --- a/swift/boringtun +++ b/swift/boringtun @@ -1 +1 @@ -Subproject commit 20d92e555303ae2d7c54f759c3cb4b222eec9d54 +Subproject commit 7ba620b327f8c5065c7f7069a57ed752b1eed90c