[desktop] Minor tauri fixes and improvments

This commit is contained in:
Vladimir Stoilov 2024-08-02 12:39:57 +03:00
parent cfd877757d
commit 500256759e
No known key found for this signature in database
GPG key ID: 2F190B67A43A81AF
9 changed files with 267 additions and 141 deletions

View file

@ -506,8 +506,8 @@ tauri-build:
RUN echo output: $(ls -R "target/${target}/release")
# Binaries
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/app" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/portmaster-app"
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/app.exe" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/portmaster-app.exe"
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/portmaster" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/portmaster-app"
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/portmaster.exe" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/portmaster-app.exe"
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/WebView2Loader.dll" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/WebView2Loader.dll"
# Installers
@ -575,7 +575,7 @@ tauri-build-windows-bundle:
RUN echo "Version Suffix: $VERSION_SUFFIX"
RUN echo output: $(ls -R "target/${target}/release")
RUN mv "target/${target}/release/app.exe" "target/${target}/release/portmaster-app_${VERSION_SUFFIX}.exe"
RUN mv "target/${target}/release/portmaster.exe" "target/${target}/release/portmaster-app_${VERSION_SUFFIX}.exe"
RUN zip "target/${target}/release/portmaster-app_${VERSION_SUFFIX}.zip" "target/${target}/release/portmaster-app_${VERSION_SUFFIX}.exe" -j portmaster-app${VERSION_SUFFIX}.exe "target/${target}/release/WebView2Loader.dll" -j WebView2Loader.dll
SAVE ARTIFACT --if-exists "target/${target}/release/portmaster-app_${VERSION_SUFFIX}.zip" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/"

View file

@ -74,7 +74,7 @@ dependencies = [
"once_cell",
"serde",
"version_check",
"zerocopy",
"zerocopy 0.7.35",
]
[[package]]
@ -3768,7 +3768,7 @@ dependencies = [
name = "indexmap"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c"
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
dependencies = [
"equivalent",
"hashbrown 0.14.5",
@ -4176,7 +4176,7 @@ dependencies = [
"anyhow",
"base64 0.22.1",
"bytecount",
"clap 4.5.16",
"clap 4.5.9",
"fancy-regex",
"fraction",
"getrandom 0.2.15",
@ -4645,8 +4645,8 @@ dependencies = [
]
[[package]]
name = "mio"
version = "1.0.2"
name = "muda"
version = "0.13.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec"
dependencies = [
@ -4980,14 +4980,35 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179"
dependencies = [
"num_enum_derive",
"num_enum_derive 0.5.11",
]
[[package]]
name = "num_enum"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845"
dependencies = [
"num_enum_derive 0.7.2",
]
[[package]]
name = "num_enum_derive"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799"
dependencies = [
"proc-macro-crate 1.3.1",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "num_enum_derive"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b"
dependencies = [
"proc-macro-crate 3.1.0",
"proc-macro2",
@ -5145,9 +5166,9 @@ dependencies = [
[[package]]
name = "object"
version = "0.36.3"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9"
checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce"
dependencies = [
"memchr",
]
@ -5663,8 +5684,7 @@ dependencies = [
"nom",
"num-bigint-dig",
"num-traits",
"num_enum",
"ocb3",
"num_enum 0.7.2",
"p256",
"p384",
"p521",
@ -5900,7 +5920,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42cf17e9a1800f5f396bc67d193dc9411b59012a5876445ef450d449881e1016"
dependencies = [
"base64 0.22.1",
"indexmap 2.4.0",
"indexmap 2.2.6",
"quick-xml 0.32.0",
"serde",
"time",
@ -5962,6 +5982,58 @@ dependencies = [
"universal-hash",
]
[[package]]
name = "portmaster"
version = "0.1.0"
dependencies = [
"assert_matches",
"cached",
"clap_lex",
"ctor",
"dark-light",
"dataurl",
"dirs 1.0.5",
"futures-util",
"gdk-pixbuf",
"gdk-pixbuf-sys",
"gio-sys",
"glib",
"glib-sys",
"gtk",
"gtk-sys",
"http 1.1.0",
"lazy_static",
"log",
"notify-rust",
"open",
"reqwest 0.12.5",
"rfd",
"rust-ini 0.20.0",
"serde",
"serde_json",
"sha",
"tauri",
"tauri-build",
"tauri-cli",
"tauri-plugin-clipboard-manager",
"tauri-plugin-dialog",
"tauri-plugin-log",
"tauri-plugin-notification",
"tauri-plugin-os",
"tauri-plugin-shell",
"tauri-plugin-single-instance",
"tauri-plugin-window-state",
"tauri-winrt-notification 0.3.1",
"thiserror",
"tokio",
"tokio-websockets",
"url",
"uuid",
"which",
"windows 0.54.0",
"windows-service",
]
[[package]]
name = "powerfmt"
version = "0.2.0"
@ -5970,12 +6042,9 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
[[package]]
name = "ppv-lite86"
version = "0.2.20"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04"
dependencies = [
"zerocopy",
]
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "precomputed-hash"
@ -7022,11 +7091,11 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.125"
version = "1.0.120"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed"
checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5"
dependencies = [
"indexmap 2.4.0",
"indexmap 2.2.6",
"itoa 1.0.11",
"memchr",
"ryu",
@ -7085,7 +7154,7 @@ dependencies = [
"chrono",
"hex",
"indexmap 1.9.3",
"indexmap 2.4.0",
"indexmap 2.2.6",
"serde",
"serde_derive",
"serde_json",
@ -7805,9 +7874,9 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
[[package]]
name = "tauri"
version = "2.0.0-rc.8"
version = "2.0.0-beta.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8345ccc676ef16e26b61fc0f5340b4e770678b1e1f53f08c69ebdac5e56b422"
checksum = "3eab508aad4ae86e23865e294b20a7bb89bd7afea523897b7478329b841d4295"
dependencies = [
"anyhow",
"bytes",
@ -7877,9 +7946,9 @@ dependencies = [
[[package]]
name = "tauri-bundler"
version = "2.0.1-rc.6"
version = "2.0.1-beta.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00a0e120d67416e774923fc07a7b531ba6898ed08f0d6e07fe79d7e3da7e0c04"
checksum = "05cc597af0bcb88c1966ccba76a6dcde5b6530c97a4fc2d798f7d3fddf182944"
dependencies = [
"anyhow",
"ar",
@ -7921,15 +7990,15 @@ dependencies = [
[[package]]
name = "tauri-cli"
version = "2.0.0-rc.8"
version = "2.0.0-beta.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddc42d318b25224c40f88550308f8cc8746a38534d450ce9c553f8c93f335499"
checksum = "24129a8dc9c3c910fca89ba0fb87ad9028868abf9dadb2514cd569fef9ad53af"
dependencies = [
"anyhow",
"axum",
"base64 0.22.1",
"cargo-mobile2",
"clap 4.5.16",
"clap 4.5.9",
"clap_complete",
"colored",
"common-path",
@ -8076,8 +8145,8 @@ dependencies = [
"schemars",
"serde",
"serde_json",
"tauri-utils 2.0.0-rc.7",
"toml 0.8.19",
"tauri-utils 2.0.0-beta.19",
"toml 0.8.15",
"walkdir",
]
@ -8099,9 +8168,9 @@ dependencies = [
[[package]]
name = "tauri-plugin-dialog"
version = "2.0.0-rc.1"
version = "2.0.0-beta.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcf99017391fdc40b6c8ae0dae8d970cc8151a8177d48b8805f320f52cac0e3c"
checksum = "8860dd73c96969eb14813f9f04d8665f2853342670456fb6619d637137ef0d09"
dependencies = [
"dunce",
"log",
@ -8117,9 +8186,9 @@ dependencies = [
[[package]]
name = "tauri-plugin-fs"
version = "2.0.0-rc.0"
version = "2.0.0-beta.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5df6b25b1f2b7b61565e66c4dbee9eb39e5635d2a763206e380e07cc3f601a67"
checksum = "461853268fe115ca19ee21e5986d505944f0b826048fe1bd726d74753fdf1df6"
dependencies = [
"anyhow",
"glob",
@ -8136,9 +8205,9 @@ dependencies = [
[[package]]
name = "tauri-plugin-log"
version = "2.0.0-rc.0"
version = "2.0.0-beta.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "380d27f23c39cde6a73024e65d8ec9b5b0af861e968dbe16b3aad86cd2c578e5"
checksum = "80f80d78a6e8102acf05a1e735f006991a2abfc71566d4e484f820b7495cd52c"
dependencies = [
"android_logger",
"byte-unit",
@ -8158,9 +8227,9 @@ dependencies = [
[[package]]
name = "tauri-plugin-notification"
version = "2.0.0-rc.1"
version = "2.0.0-beta.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35677cdcdb4dc3f3ef6891f31b8ea314045064752912d66e676a4f1577b57ffa"
checksum = "a5a09eb4d9e0919ce954da68d3707ddb161e5e37447da26609d0d0f5aebbc69a"
dependencies = [
"log",
"notify-rust",
@ -8177,9 +8246,9 @@ dependencies = [
[[package]]
name = "tauri-plugin-os"
version = "2.0.0-rc.0"
version = "2.0.0-beta.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b54cfeb26356822d3be3db4282041b03552f573a694b6b28aded7d95c62a039"
checksum = "79a0466f11f45fd3f640a17b5ba5e34c62912c9b391141c818155125ae9f0917"
dependencies = [
"gethostname",
"log",
@ -8195,9 +8264,9 @@ dependencies = [
[[package]]
name = "tauri-plugin-shell"
version = "2.0.0-rc.1"
version = "2.0.0-beta.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2133e5c6fe2ae0263ff5920feed477d3b1413f89033f537966831b0cb6f61f8e"
checksum = "8a9fa8c4e3d9ec343f6c3eb081672045566128a6c48ff6f6eeea85251ff38d3f"
dependencies = [
"encoding_rs",
"log",
@ -8216,9 +8285,9 @@ dependencies = [
[[package]]
name = "tauri-plugin-single-instance"
version = "2.0.0-rc.0"
version = "2.0.0-beta.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de552151b4c9ba9ff72c7244dccaadd47f88d1f0d5caa2603c5c1c12b7636edc"
checksum = "b21866e185e2f9c5d40afb851441e3292a4f94f4a26af6ae0dff6e7e5ba03f42"
dependencies = [
"log",
"serde",
@ -8231,9 +8300,9 @@ dependencies = [
[[package]]
name = "tauri-plugin-window-state"
version = "2.0.0-rc.1"
version = "2.0.0-beta.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb6839228cbd225b95681c766cc51113e9dad62c4b3f6ebb102234413ba85ee2"
checksum = "b6f7cea222b8eeb3598c7b3e19e9c7e6b1c2d60207b87225e0c3bb1c24c8fdec"
dependencies = [
"bitflags 2.6.0",
"log",
@ -8246,9 +8315,9 @@ dependencies = [
[[package]]
name = "tauri-runtime"
version = "2.0.0-rc.7"
version = "2.0.0-beta.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75c72b844f387bfc3341c355f3e16b8cbf4161848fa4e348670effb222cd3ba5"
checksum = "fe978df03966febbebc608931dc2cf26ef94df70855a18b05f07134cf474de09"
dependencies = [
"dpi",
"gtk",
@ -8265,9 +8334,9 @@ dependencies = [
[[package]]
name = "tauri-runtime-wry"
version = "2.0.0-rc.7"
version = "2.0.0-beta.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73accf936a7cd01d1382de7850726fdf6c1f6ab3b01ccb7a0950cb852e332596"
checksum = "11e4d568f61095f507b3fc4254dfbfff3b20de2a1d66167ffca3f6d90b14db8f"
dependencies = [
"cocoa 0.26.0",
"gtk",
@ -8576,14 +8645,15 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
version = "1.39.3"
version = "1.38.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5"
checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df"
dependencies = [
"backtrace",
"bytes",
"libc",
"mio 1.0.2",
"mio",
"num_cpus",
"pin-project-lite",
"signal-hook-registry",
"socket2 0.5.7",
@ -8711,7 +8781,7 @@ version = "0.8.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e"
dependencies = [
"indexmap 2.4.0",
"indexmap 2.2.6",
"serde",
"serde_spanned",
"toml_datetime",
@ -8733,7 +8803,7 @@ version = "0.19.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
dependencies = [
"indexmap 2.4.0",
"indexmap 2.2.6",
"serde",
"serde_spanned",
"toml_datetime",
@ -8746,7 +8816,7 @@ version = "0.20.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81"
dependencies = [
"indexmap 2.4.0",
"indexmap 2.2.6",
"toml_datetime",
"winnow 0.5.40",
]
@ -8757,7 +8827,7 @@ version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1"
dependencies = [
"indexmap 2.4.0",
"indexmap 2.2.6",
"toml_datetime",
"winnow 0.5.40",
]
@ -8768,7 +8838,7 @@ version = "0.22.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d"
dependencies = [
"indexmap 2.4.0",
"indexmap 2.2.6",
"serde",
"serde_spanned",
"toml_datetime",
@ -9523,9 +9593,9 @@ checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
[[package]]
name = "which"
version = "6.0.3"
version = "6.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4ee928febd44d98f2f459a4a79bd4d928591333a494a10a868418ac1b39cf1f"
checksum = "8211e4f58a2b2805adfbefbc07bab82958fc91e3836339b1ab7ae32465dce0d7"
dependencies = [
"either",
"home",
@ -10306,13 +10376,22 @@ dependencies = [
"zvariant 4.2.0",
]
[[package]]
name = "zerocopy"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6"
dependencies = [
"byteorder",
"zerocopy-derive 0.6.6",
]
[[package]]
name = "zerocopy"
version = "0.7.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
dependencies = [
"byteorder",
"zerocopy-derive",
]

View file

@ -1,11 +1,11 @@
[package]
name = "app"
name = "portmaster"
version = "0.1.0"
description = "Portmaster UI"
authors = ["Safing"]
license = ""
repository = ""
default-run = "app"
default-run = "portmaster"
edition = "2021"
rust-version = "1.60"

File diff suppressed because one or more lines are too long

View file

@ -3072,4 +3072,3 @@
]
}
}
}

View file

@ -3072,4 +3072,3 @@
]
}
}
}

View file

@ -0,0 +1,107 @@
use log::LevelFilter;
#[cfg(not(debug_assertions))]
const DEFAULT_LOG_LEVEL: log::LevelFilter = log::LevelFilter::Warn;
#[cfg(debug_assertions)]
const DEFAULT_LOG_LEVEL: log::LevelFilter = log::LevelFilter::Debug;
#[derive(Debug)]
pub struct CliArguments {
// Path to the installation directory
pub data: Option<String>,
// Log level to use: off, error, warn, info, debug, trace
pub log_level: log::LevelFilter,
// Start in the background without opening a window
pub background: bool,
// Enable experimental notifications via Tauri. Replaces the notifier app.
pub with_prompts: bool,
// Enable experimental prompt support via Tauri. Replaces the notifier app.
pub with_notifications: bool,
}
impl CliArguments {
fn parse_log(&mut self, level: String) {
self.log_level = match level.as_ref() {
"off" => LevelFilter::Off,
"error" => LevelFilter::Error,
"warn" => LevelFilter::Warn,
"info" => LevelFilter::Info,
"debug" => LevelFilter::Debug,
"trace" => LevelFilter::Trace,
_ => DEFAULT_LOG_LEVEL,
}
}
}
pub fn parse(raw: impl IntoIterator<Item = impl Into<std::ffi::OsString>>) -> CliArguments {
let mut cli = CliArguments {
data: None,
log_level: DEFAULT_LOG_LEVEL,
background: false,
with_prompts: false,
with_notifications: false,
};
let raw = clap_lex::RawArgs::new(raw);
let mut cursor = raw.cursor();
raw.next(&mut cursor); // Skip the bin
while let Some(arg) = raw.next(&mut cursor) {
if let Some((long, value)) = arg.to_long() {
match long {
Ok("data") => {
if let Some(value) = value {
cli.data = Some(value.to_string_lossy().into_owned());
}
}
Ok("log") => {
if let Some(value) = value {
cli.parse_log(value.to_string_lossy().into_owned());
}
}
Ok("background") => {
cli.background = true;
}
Ok("with_prompts") => {
cli.with_prompts = true;
}
Ok("with_notifications") => {
cli.with_notifications = true;
}
_ => {
// Ignore unexpected flags
}
}
} else if let Some(mut shorts) = arg.to_short() {
while let Some(short) = shorts.next() {
match short {
Ok('l') => {
if let Some(value) = shorts.next_value_os() {
let mut str = value.to_string_lossy().into_owned();
_ = str.remove(0); // remove first "=" from value (in -l=warn value will be "=warn")
cli.parse_log(str);
}
}
Ok('d') => {
if let Some(value) = shorts.next_value_os() {
let mut str = value.to_string_lossy().into_owned();
_ = str.remove(0); // remove first "=" from value (in -d=/data value will be "=/data")
cli.data = Some(str);
}
}
Ok('b') => cli.background = true,
_ => {
// Ignore unexpected flags
}
}
}
}
}
cli
}

View file

@ -3,7 +3,6 @@
use std::{env, path::Path, time::Duration};
use clap::{Arg, Command};
use tauri::{AppHandle, Emitter, Listener, Manager, RunEvent, WindowEvent};
// Library crates
@ -15,11 +14,12 @@ mod xdg;
// App modules
mod config;
mod cli;
mod portmaster;
mod traymenu;
mod window;
use log::{debug, error, info, LevelFilter};
use log::{debug, error, info};
use portmaster::PortmasterExt;
use tauri_plugin_log::RotationStrategy;
use traymenu::setup_tray_menu;
@ -30,12 +30,6 @@ extern crate lazy_static;
const FALLBACK_TO_OLD_UI_EXIT_CODE: i32 = 77;
#[cfg(not(debug_assertions))]
const LOG_LEVEL: LevelFilter = LevelFilter::Warn;
#[cfg(debug_assertions)]
const LOG_LEVEL: LevelFilter = LevelFilter::Debug;
#[derive(Clone, serde::Serialize)]
struct Payload {
args: Vec<String>,
@ -49,23 +43,6 @@ struct WsHandler {
is_first_connect: bool,
}
struct CliArguments {
// Path to the installation directory
data: Option<String>,
// Log level to use: off, error, warn, info, debug, trace
log: String,
// Start in the background without opening a window
background: bool,
// Enable experimental notifications via Tauri. Replaces the notifier app.
with_prompts: bool,
// Enable experimental prompt support via Tauri. Replaces the notifier app.
with_notifications: bool,
}
impl portmaster::Handler for WsHandler {
fn name(&self) -> String {
"main-handler".to_string()
@ -147,44 +124,7 @@ fn main() {
std::process::exit(show_webview_not_installed_dialog());
}
let matches = Command::new("Portmaster")
.ignore_errors(true)
.arg(
Arg::new("data")
.short('d')
.long("data")
.required(false)
.help("Path to the installation directory."),
)
.arg(
Arg::new("log")
.short('l')
.long("log")
.required(false)
.help("Log level to use: off, error, warn, info, debug, trace."),
)
.arg(
Arg::new("background")
.short('b')
.long("background")
.required(false)
.help("Start in the background without opening a window."),
)
.arg(
Arg::new("with_prompts")
.long("with_prompts")
.required(false)
.action(clap::ArgAction::SetTrue)
.help("Enable experimental notifications via Tauri. Replaces the notifier app."),
)
.arg(
Arg::new("with_notifications")
.long("with_notifications")
.required(false)
.action(clap::ArgAction::SetTrue)
.help("Enable experimental prompt support via Tauri. Replaces the notifier app."),
)
.get_matches();
let cli_args = cli::parse(std::env::args());
let mut cli = CliArguments {
data: None,
@ -245,7 +185,7 @@ fn main() {
// Initialize Logging plugin.
.plugin(
tauri_plugin_log::Builder::default()
.level(log_level)
.level(cli_args.log_level)
.rotation_strategy(RotationStrategy::KeepAll)
.clear_targets()
.target(log_target)
@ -287,16 +227,18 @@ fn main() {
});
// Handle cli flags:
app.portmaster().set_show_after_bootstrap(!cli.background);
app.portmaster()
.with_notification_support(cli.with_notifications);
app.portmaster().with_connection_prompts(cli.with_prompts);
.set_show_after_bootstrap(!cli_args.background);
app.portmaster()
.with_notification_support(cli_args.with_notifications);
app.portmaster()
.with_connection_prompts(cli_args.with_prompts);
// prepare a custom portmaster plugin handler that will show the splash-screen
// (if not in --background) and launch the tray-icon handler.
let handler = WsHandler {
handle: app.handle().clone(),
background: cli.background,
background: cli_args.background,
is_first_connect: true,
};

View file

@ -30,12 +30,12 @@ ProtectKernelTunables=yes
ProtectKernelLogs=yes
ProtectControlGroups=yes
PrivateDevices=yes
AmbientCapabilities=cap_chown cap_kill cap_net_admin cap_net_bind_service cap_net_broadcast cap_net_raw cap_sys_module cap_sys_ptrace cap_dac_override cap_fowner cap_fsetid
CapabilityBoundingSet=cap_chown cap_kill cap_net_admin cap_net_bind_service cap_net_broadcast cap_net_raw cap_sys_module cap_sys_ptrace cap_dac_override cap_fowner cap_fsetid
AmbientCapabilities=cap_chown cap_kill cap_net_admin cap_net_bind_service cap_net_broadcast cap_net_raw cap_sys_module cap_sys_ptrace cap_dac_override cap_fowner cap_fsetid cap_sys_resource cap_bpf cap_perfmon
CapabilityBoundingSet=cap_chown cap_kill cap_net_admin cap_net_bind_service cap_net_broadcast cap_net_raw cap_sys_module cap_sys_ptrace cap_dac_override cap_fowner cap_fsetid cap_sys_resource cap_bpf cap_perfmon
StateDirectory=portmaster
# TODO(ppacher): add --disable-software-updates once it's merged and the release process changed.
ExecStart=/usr/bin/portmaster-start --data /opt/safing/portmaster core -- $PORTMASTER_ARGS
ExecStopPost=-/usr/bin/portmaster-start recover-iptables
ExecStart=/usr/bin/portmaster-core --data /opt/safing/portmaster -- $PORTMASTER_ARGS
ExecStopPost=-/usr/bin/portmaster-core recover-iptables
[Install]
WantedBy=multi-user.target