Compare commits

..
Author SHA1 Message Date
renovate[bot] 6da2964e2a chore(deps): update dependency pnpm to v12.21.0 2026-11-16 14:09:47 +00:00
32 changed files with 472 additions and 738 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
"features": { "features": {
"ghcr.io/devcontainers/features/node:2": { "ghcr.io/devcontainers/features/node:2": {
"version": "26.13.1", "version": "26.13.1",
"pnpmVersion": "12.18.0" "pnpmVersion": "12.21.0"
}, },
"ghcr.io/devcontainers/features/rust:1": { "ghcr.io/devcontainers/features/rust:1": {
"version": "1.100.0", "version": "1.100.0",
+13 -58
View File
@@ -5,10 +5,10 @@
"version": "v9.0.0", "version": "v9.0.0",
"sha": "3a2844b7e9c422d3c10d287c895573f7108da1b3" "sha": "3a2844b7e9c422d3c10d287c895573f7108da1b3"
}, },
"github/gh-aw-actions/setup@v1.3.0": { "github/gh-aw-actions/setup@v1.2.2": {
"repo": "github/gh-aw-actions/setup", "repo": "github/gh-aw-actions/setup",
"version": "v1.3.0", "version": "v1.2.2",
"sha": "8126d6cb07dea9221848de275af8a41474d839ca" "sha": "53d0749e19424a918acd82b4d140264ce48f2f14"
} }
}, },
"containers": { "containers": {
@@ -32,16 +32,6 @@
"digest": "sha256:2c78aaba1c108e130e2d6d01e4f2cca334ea04c53e6f258913ac34173fe7e3b2", "digest": "sha256:2c78aaba1c108e130e2d6d01e4f2cca334ea04c53e6f258913ac34173fe7e3b2",
"pinned_image": "ghcr.io/github/gh-aw-firewall/agent:0.28.23@sha256:2c78aaba1c108e130e2d6d01e4f2cca334ea04c53e6f258913ac34173fe7e3b2" "pinned_image": "ghcr.io/github/gh-aw-firewall/agent:0.28.23@sha256:2c78aaba1c108e130e2d6d01e4f2cca334ea04c53e6f258913ac34173fe7e3b2"
}, },
"ghcr.io/github/gh-aw-firewall/agent:0.29.11": {
"image": "ghcr.io/github/gh-aw-firewall/agent:0.29.11",
"digest": "sha256:8774a73c351395b41d2ad0af4ddb4689007c67de3cd08bd9f43bb8a0e300690e",
"pinned_image": "ghcr.io/github/gh-aw-firewall/agent:0.29.11@sha256:8774a73c351395b41d2ad0af4ddb4689007c67de3cd08bd9f43bb8a0e300690e"
},
"ghcr.io/github/gh-aw-firewall/agent:0.29.14": {
"image": "ghcr.io/github/gh-aw-firewall/agent:0.29.14",
"digest": "sha256:7f649a02f2cc235325ab512f546854e0fad32b7abdc6c24c5475ddc0639e0aaa",
"pinned_image": "ghcr.io/github/gh-aw-firewall/agent:0.29.14@sha256:7f649a02f2cc235325ab512f546854e0fad32b7abdc6c24c5475ddc0639e0aaa"
},
"ghcr.io/github/gh-aw-firewall/api-proxy:0.28.13": { "ghcr.io/github/gh-aw-firewall/api-proxy:0.28.13": {
"image": "ghcr.io/github/gh-aw-firewall/api-proxy:0.28.13", "image": "ghcr.io/github/gh-aw-firewall/api-proxy:0.28.13",
"digest": "sha256:61f12dcff38eb008b645d87a5541763452f409d9040eb243718764944167b1a2", "digest": "sha256:61f12dcff38eb008b645d87a5541763452f409d9040eb243718764944167b1a2",
@@ -62,31 +52,6 @@
"digest": "sha256:c15c3d1208df10c5b588a3657be53742aa982ae0909d1eb1812525268794ca64", "digest": "sha256:c15c3d1208df10c5b588a3657be53742aa982ae0909d1eb1812525268794ca64",
"pinned_image": "ghcr.io/github/gh-aw-firewall/api-proxy:0.28.23@sha256:c15c3d1208df10c5b588a3657be53742aa982ae0909d1eb1812525268794ca64" "pinned_image": "ghcr.io/github/gh-aw-firewall/api-proxy:0.28.23@sha256:c15c3d1208df10c5b588a3657be53742aa982ae0909d1eb1812525268794ca64"
}, },
"ghcr.io/github/gh-aw-firewall/api-proxy:0.29.11": {
"image": "ghcr.io/github/gh-aw-firewall/api-proxy:0.29.11",
"digest": "sha256:88d2d0e315a504d93fd4fb8847fd0f6b7f4469f41a6fc6047b3dc9654c56ab2c",
"pinned_image": "ghcr.io/github/gh-aw-firewall/api-proxy:0.29.11@sha256:88d2d0e315a504d93fd4fb8847fd0f6b7f4469f41a6fc6047b3dc9654c56ab2c"
},
"ghcr.io/github/gh-aw-firewall/api-proxy:0.29.14": {
"image": "ghcr.io/github/gh-aw-firewall/api-proxy:0.29.14",
"digest": "sha256:136785634c9207d7328c701d31d53941542ef307840bda6b348274c8842557c0",
"pinned_image": "ghcr.io/github/gh-aw-firewall/api-proxy:0.29.14@sha256:136785634c9207d7328c701d31d53941542ef307840bda6b348274c8842557c0"
},
"ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.11": {
"image": "ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.11",
"digest": "sha256:97782bc0d8ff7f80f19ae2fdc5e1668517aa732a6fa077e64b8d3919238496d2",
"pinned_image": "ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.11@sha256:97782bc0d8ff7f80f19ae2fdc5e1668517aa732a6fa077e64b8d3919238496d2"
},
"ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.14": {
"image": "ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.14",
"digest": "sha256:3f9cf5c56bfea6f845ac7a213f4bbbac8c5e16ea1587599fae898da3ab6a6e12",
"pinned_image": "ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.14@sha256:3f9cf5c56bfea6f845ac7a213f4bbbac8c5e16ea1587599fae898da3ab6a6e12"
},
"ghcr.io/github/gh-aw-firewall/router:0.29.14": {
"image": "ghcr.io/github/gh-aw-firewall/router:0.29.14",
"digest": "sha256:b8822defe0cc2abebc619ee1cf49c34c67286fab117512f0d667962572564be0",
"pinned_image": "ghcr.io/github/gh-aw-firewall/router:0.29.14@sha256:b8822defe0cc2abebc619ee1cf49c34c67286fab117512f0d667962572564be0"
},
"ghcr.io/github/gh-aw-firewall/squid:0.28.13": { "ghcr.io/github/gh-aw-firewall/squid:0.28.13": {
"image": "ghcr.io/github/gh-aw-firewall/squid:0.28.13", "image": "ghcr.io/github/gh-aw-firewall/squid:0.28.13",
"digest": "sha256:58a8dc5be3fbafeef7da0532c38bd9047f86bf1b3c4cfd7d9b7d8d28e80a2b56", "digest": "sha256:58a8dc5be3fbafeef7da0532c38bd9047f86bf1b3c4cfd7d9b7d8d28e80a2b56",
@@ -107,30 +72,20 @@
"digest": "sha256:02ffc56dd40158223064ef03a78c2d9717473c93723b4e403d455ea6f0b09ae0", "digest": "sha256:02ffc56dd40158223064ef03a78c2d9717473c93723b4e403d455ea6f0b09ae0",
"pinned_image": "ghcr.io/github/gh-aw-firewall/squid:0.28.23@sha256:02ffc56dd40158223064ef03a78c2d9717473c93723b4e403d455ea6f0b09ae0" "pinned_image": "ghcr.io/github/gh-aw-firewall/squid:0.28.23@sha256:02ffc56dd40158223064ef03a78c2d9717473c93723b4e403d455ea6f0b09ae0"
}, },
"ghcr.io/github/gh-aw-firewall/squid:0.29.11": { "ghcr.io/github/gh-aw-mcpg:v0.4.25": {
"image": "ghcr.io/github/gh-aw-firewall/squid:0.29.11", "image": "ghcr.io/github/gh-aw-mcpg:v0.4.25",
"digest": "sha256:861739ecf924dd2db5e5fb652db2ad82aaafd1615623297ddabc8f41a36b2847", "digest": "sha256:9be0a86220e807a0ecc89e53d7453468f7a53fbc6b3d1efd2299025ffe01d086",
"pinned_image": "ghcr.io/github/gh-aw-firewall/squid:0.29.11@sha256:861739ecf924dd2db5e5fb652db2ad82aaafd1615623297ddabc8f41a36b2847" "pinned_image": "ghcr.io/github/gh-aw-mcpg:v0.4.25@sha256:9be0a86220e807a0ecc89e53d7453468f7a53fbc6b3d1efd2299025ffe01d086"
},
"ghcr.io/github/gh-aw-firewall/squid:0.29.14": {
"image": "ghcr.io/github/gh-aw-firewall/squid:0.29.14",
"digest": "sha256:878b9c1aaeca076004bf2157dd2be28586b68b2b3d69c3ff8fd2b5add2a3126c",
"pinned_image": "ghcr.io/github/gh-aw-firewall/squid:0.29.14@sha256:878b9c1aaeca076004bf2157dd2be28586b68b2b3d69c3ff8fd2b5add2a3126c"
},
"ghcr.io/github/gh-aw-mcpg:v0.5.10": {
"image": "ghcr.io/github/gh-aw-mcpg:v0.5.10",
"digest": "sha256:629ddcd68a48ab02e7db8af527d2756c6db563b00c1d31d8aa8fcbac96f01c59",
"pinned_image": "ghcr.io/github/gh-aw-mcpg:v0.5.10@sha256:629ddcd68a48ab02e7db8af527d2756c6db563b00c1d31d8aa8fcbac96f01c59"
}, },
"ghcr.io/github/gh-aw-node": { "ghcr.io/github/gh-aw-node": {
"image": "ghcr.io/github/gh-aw-node", "image": "ghcr.io/github/gh-aw-node",
"digest": "sha256:1fe145873f46e4dded511319d2a91dbaed5bb4d9c43d93fdc383198d1bf02b7f", "digest": "sha256:bac2192f6374d6262116399b34fc5e143d576f82719e90a18261cae7480f4d4e",
"pinned_image": "ghcr.io/github/gh-aw-node@sha256:1fe145873f46e4dded511319d2a91dbaed5bb4d9c43d93fdc383198d1bf02b7f" "pinned_image": "ghcr.io/github/gh-aw-node@sha256:bac2192f6374d6262116399b34fc5e143d576f82719e90a18261cae7480f4d4e"
}, },
"ghcr.io/github/github-mcp-server:v2.1.0": { "ghcr.io/github/github-mcp-server:v1.12.2": {
"image": "ghcr.io/github/github-mcp-server:v2.1.0", "image": "ghcr.io/github/github-mcp-server:v1.12.2",
"digest": "sha256:f6056fc10bfffcc8c81a6417a2e9ca12808647e8dd6049642a4feaadee0e0f8a", "digest": "sha256:508a0857ec762b1ab1cece29193345b501fab1dd9d1228a7b617062954cecac6",
"pinned_image": "ghcr.io/github/github-mcp-server:v2.1.0@sha256:f6056fc10bfffcc8c81a6417a2e9ca12808647e8dd6049642a4feaadee0e0f8a" "pinned_image": "ghcr.io/github/github-mcp-server:v1.12.2@sha256:508a0857ec762b1ab1cece29193345b501fab1dd9d1228a7b617062954cecac6"
} }
} }
} }
+2 -2
View File
@@ -31,9 +31,9 @@ jobs:
with: with:
persist-credentials: false persist-credentials: false
- name: Install gh-aw extension - name: Install gh-aw extension
uses: github/gh-aw-actions/setup-cli@8126d6cb07dea9221848de275af8a41474d839ca # v1.3.0 uses: github/gh-aw-actions/setup-cli@862164f9ffbcce2e24e5397da938e3b19f839dce # v1.2.3
with: with:
version: v1.3.0 version: v1.2.2
- name: Install Rust Stable - name: Install Rust Stable
uses: dtolnay/rust-toolchain@stable uses: dtolnay/rust-toolchain@stable
with: with:
File diff suppressed because one or more lines are too long
+66 -115
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,3 +1,3 @@
nodejs 26.13.1 nodejs 26.13.1
pnpm 12.18.0 pnpm 12.21.0
rust 1.100.0 rust 1.100.0
Generated
+24 -36
View File
@@ -1328,7 +1328,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"windows-sys 0.59.0", "windows-sys 0.48.0",
] ]
[[package]] [[package]]
@@ -2043,7 +2043,7 @@ dependencies = [
"libc", "libc",
"option-ext", "option-ext",
"redox_users 0.5.2", "redox_users 0.5.2",
"windows-sys 0.61.2", "windows-sys 0.60.2",
] ]
[[package]] [[package]]
@@ -2302,7 +2302,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [ dependencies = [
"libc", "libc",
"windows-sys 0.61.2", "windows-sys 0.52.0",
] ]
[[package]] [[package]]
@@ -2818,7 +2818,7 @@ dependencies = [
"gobject-sys 0.21.5", "gobject-sys 0.21.5",
"libc", "libc",
"system-deps 7.0.8", "system-deps 7.0.8",
"windows-sys 0.61.2", "windows-sys 0.52.0",
] ]
[[package]] [[package]]
@@ -3372,7 +3372,7 @@ dependencies = [
"js-sys", "js-sys",
"log", "log",
"wasm-bindgen", "wasm-bindgen",
"windows-core 0.62.2", "windows-core 0.61.2",
] ]
[[package]] [[package]]
@@ -4252,7 +4252,7 @@ dependencies = [
"png", "png",
"serde", "serde",
"thiserror 2.0.20", "thiserror 2.0.20",
"windows-sys 0.61.2", "windows-sys 0.60.2",
] ]
[[package]] [[package]]
@@ -4356,18 +4356,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "nix"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77730ed34f01f4990cb2ea67fec715ecebc6fab9a6396cf83c5529b13f581bdc"
dependencies = [
"bitflags 2.13.2",
"cfg-if",
"cfg_aliases",
"libc",
]
[[package]] [[package]]
name = "nohash-hasher" name = "nohash-hasher"
version = "0.2.0" version = "0.2.0"
@@ -4431,7 +4419,7 @@ version = "0.50.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
dependencies = [ dependencies = [
"windows-sys 0.61.2", "windows-sys 0.60.2",
] ]
[[package]] [[package]]
@@ -4894,7 +4882,7 @@ checksum = "9cf20a545b305cf1da722b236b5155c9bb35f1d5ceb28c048bd96ca842f41b5b"
dependencies = [ dependencies = [
"android_system_properties", "android_system_properties",
"log", "log",
"nix 0.31.3", "nix",
"objc2", "objc2",
"objc2-foundation", "objc2-foundation",
"objc2-ui-kit", "objc2-ui-kit",
@@ -4908,7 +4896,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967"
dependencies = [ dependencies = [
"libc", "libc",
"windows-sys 0.61.2", "windows-sys 0.45.0",
] ]
[[package]] [[package]]
@@ -5588,7 +5576,7 @@ dependencies = [
"once_cell", "once_cell",
"socket2", "socket2",
"tracing", "tracing",
"windows-sys 0.61.2", "windows-sys 0.52.0",
] ]
[[package]] [[package]]
@@ -6128,7 +6116,7 @@ dependencies = [
"errno", "errno",
"libc", "libc",
"linux-raw-sys 0.4.15", "linux-raw-sys 0.4.15",
"windows-sys 0.59.0", "windows-sys 0.52.0",
] ]
[[package]] [[package]]
@@ -6141,7 +6129,7 @@ dependencies = [
"errno", "errno",
"libc", "libc",
"linux-raw-sys 0.12.1", "linux-raw-sys 0.12.1",
"windows-sys 0.61.2", "windows-sys 0.52.0",
] ]
[[package]] [[package]]
@@ -6200,7 +6188,7 @@ dependencies = [
"security-framework", "security-framework",
"security-framework-sys", "security-framework-sys",
"webpki-root-certs", "webpki-root-certs",
"windows-sys 0.61.2", "windows-sys 0.52.0",
] ]
[[package]] [[package]]
@@ -6820,7 +6808,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4"
dependencies = [ dependencies = [
"libc", "libc",
"windows-sys 0.61.2", "windows-sys 0.60.2",
] ]
[[package]] [[package]]
@@ -7877,10 +7865,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
dependencies = [ dependencies = [
"fastrand", "fastrand",
"getrandom 0.4.3", "getrandom 0.3.4",
"once_cell", "once_cell",
"rustix 1.1.4", "rustix 1.1.4",
"windows-sys 0.61.2", "windows-sys 0.52.0",
] ]
[[package]] [[package]]
@@ -8546,7 +8534,7 @@ dependencies = [
"png", "png",
"serde", "serde",
"thiserror 2.0.20", "thiserror 2.0.20",
"windows-sys 0.61.2", "windows-sys 0.60.2",
] ]
[[package]] [[package]]
@@ -8655,7 +8643,7 @@ checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e"
dependencies = [ dependencies = [
"memoffset", "memoffset",
"tempfile", "tempfile",
"windows-sys 0.61.2", "windows-sys 0.60.2",
] ]
[[package]] [[package]]
@@ -9197,7 +9185,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [ dependencies = [
"windows-sys 0.61.2", "windows-sys 0.48.0",
] ]
[[package]] [[package]]
@@ -9218,7 +9206,7 @@ dependencies = [
"objc2-foundation", "objc2-foundation",
"objc2-quartz-core", "objc2-quartz-core",
"raw-window-handle", "raw-window-handle",
"windows-sys 0.61.2", "windows-sys 0.60.2",
"windows-version", "windows-version",
] ]
@@ -9793,7 +9781,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d6f32a0ff4a9f6f01231eb2059cc85479330739333e0e58cadf03b6af2cca10" checksum = "7d6f32a0ff4a9f6f01231eb2059cc85479330739333e0e58cadf03b6af2cca10"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"windows-sys 0.61.2", "windows-sys 0.60.2",
] ]
[[package]] [[package]]
@@ -10139,9 +10127,9 @@ dependencies = [
[[package]] [[package]]
name = "zip" name = "zip"
version = "9.6.0" version = "9.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80cc68510ea7553c30a69c732de5278e94183f68765af6c642dbccefd6ec777e" checksum = "e3476fd497ac8af5b1ec7b51acab7bef380f7e8dd8e0487595bafd839417a302"
dependencies = [ dependencies = [
"aes", "aes",
"bzip2", "bzip2",
@@ -10155,7 +10143,7 @@ dependencies = [
"libc", "libc",
"lzma-rust2", "lzma-rust2",
"memchr", "memchr",
"nix 0.32.0", "nix",
"pbkdf2", "pbkdf2",
"ppmd-rust", "ppmd-rust",
"sha1 0.11.0", "sha1 0.11.0",
+1 -1
View File
@@ -138,5 +138,5 @@
] ]
}, },
"type": "module", "type": "module",
"packageManager": "pnpm@12.18.0" "packageManager": "pnpm@12.21.0"
} }
+70 -61
View File
@@ -7,153 +7,162 @@ importers:
configDependencies: {} configDependencies: {}
packageManagerDependencies: packageManagerDependencies:
pnpm: pnpm:
specifier: 12.18.0 specifier: 12.21.0
version: 12.18.0 version: 12.21.0
packages: packages:
'@pnpm/exe.android-arm64@12.18.0': '@pnpm/exe.android-arm64@12.21.0':
resolution: {integrity: sha512-fOF6IwgvnUKEmVedGqiAsNPfN2Ry8GvaqzSQOiF3RJFbpBfPKO/6YT54s1GjToyYinRxw9preHHPe4y2N3SzhA==} resolution: {integrity: sha512-iaWidxR5B9NUBpwMznCQu1yUpKB6BjTY5BYX2lORj76VsfINdj8Z8XWSzSNrGI8qlxa28Jzdp5fiaspzOaJZlA==}
cpu: [arm64] cpu: [arm64]
os: [android] os: [android]
'@pnpm/exe.android-x64@12.18.0': '@pnpm/exe.android-x64@12.21.0':
resolution: {integrity: sha512-6OiolnaCsB3/GcJ9XNrenbUH3zFHRJ+5QynrMUUEyThbgnnCzWxa199hpQlOmxN4rAXuYQ0IYgWFNUZxyzg31Q==} resolution: {integrity: sha512-35e5v3wlwjIYxDywq+R6/z8CE4gLOEgRxt18yqz1tMRLmx2mnW+CFJI2Q8+srTNjn7gykXUC0x1k195JNikC5A==}
cpu: [x64] cpu: [x64]
os: [android] os: [android]
'@pnpm/exe.darwin-arm64@12.18.0': '@pnpm/exe.darwin-arm64@12.21.0':
resolution: {integrity: sha512-zkq+4YzVIX39ETYLyC3W7LY7MpHEU/J3nRhHl4i2yPld2Cf2+rEKRh3ejJ4AmaQ77HHJLCktY4Z3jq0fpcxFXg==} resolution: {integrity: sha512-F5OyMX/6zLSowpTZEQRojbCmPS1Pq+fyRaIinslsIe6Glh3qbyQ52u+Fe0eEzSaRuIbWZkXmAAXSWh6Q5Wrlgg==}
cpu: [arm64] cpu: [arm64]
os: [darwin] os: [darwin]
'@pnpm/exe.darwin-x64@12.18.0': '@pnpm/exe.darwin-x64@12.21.0':
resolution: {integrity: sha512-qMsL9qx92unOTa6hgkfiTJv8ceZaTx0IQg7InhYDVX2ZrTECujaVEEVypnJK5m3eGUsP1KD7Y4qIgleCwfRsYw==} resolution: {integrity: sha512-EzpvcsaE6hrrgYeEiAFYd2rSgFybYyxXhkAY7K3y6Hg3loVfcyJ81hHczpFzi8lW5RXtUlFECRPZ8ZAMRFQYYg==}
cpu: [x64] cpu: [x64]
os: [darwin] os: [darwin]
'@pnpm/exe.freebsd-x64@12.18.0': '@pnpm/exe.freebsd-x64@12.21.0':
resolution: {integrity: sha512-/9vy/4ms52cU4MjZ5NhHd6N2d9L9W0kARf5/ff2tweAHu0VeUzs/0qp/7ZHFuddm2Wa/m0AKQoPum9AVUCqKsw==} resolution: {integrity: sha512-wNjuEnmdLks4aayPu/QZWQ5tQM9Jn+odUp/vwQM8BXRYoulkTZhtZTHoD60N6mUdLWef1hgUeUh8llNGEUsimw==}
cpu: [x64] cpu: [x64]
os: [freebsd] os: [freebsd]
'@pnpm/exe.linux-arm64-musl@12.18.0': '@pnpm/exe.linux-arm64-musl@12.21.0':
resolution: {integrity: sha512-Vp+TIMPPyackVCXkOdEKH/RmAn/r07EcIyrgZYQK7VrkksqZOie0GnWIx+85mPqeFEYCRtXIZAFJ9L4ceTndDg==} resolution: {integrity: sha512-Ceit9zn4g5ZqCJtx1fV8eJE7p8aeXMrGZ+Dc01vRqZLIUNgNeI+Ur0ruyqxtsnJx6rGADyXzohumxPLHjaJ5AQ==}
cpu: [arm64] cpu: [arm64]
os: [linux] os: [linux]
libc: [musl] libc: [musl]
'@pnpm/exe.linux-arm64@12.18.0': '@pnpm/exe.linux-arm64@12.21.0':
resolution: {integrity: sha512-2dpyVBCHT+FfpuQh9i+7MXAqNWYLCvD5vYr5p6Eimxoga8USLnjbUgyj72AOrO0hjc5ri3TEFP3jiyBHjkSZpQ==} resolution: {integrity: sha512-4Oj/iF2TDCe2lcH0n4TupPR5sSdrNLclJB6xBElLMPCUOAvBhdf2rRlSaO5M4erJ6g4Fyy7YTXTpcmfFsKyxEA==}
cpu: [arm64] cpu: [arm64]
os: [linux] os: [linux]
libc: [glibc] libc: [glibc]
'@pnpm/exe.linux-ppc64@12.18.0': '@pnpm/exe.linux-ppc64@12.21.0':
resolution: {integrity: sha512-BBOOOfNJ2QwIIya3eKqOjiN4WNTszfRz7HCvw9XggcT7+ftMjNP8XJ/GfW+ltCBeUFR9d8WBVsr2m/NLjX2CZQ==} resolution: {integrity: sha512-s2o7rdSDeUTBFsNqxptpZXlTgT6cojmMVUOvTQvFNSv6Easian02ha4tR32fwwD97Au4YzIIjMCwywCF4D82Sw==}
cpu: [ppc64] cpu: [ppc64]
os: [linux] os: [linux]
libc: [glibc] libc: [glibc]
'@pnpm/exe.linux-riscv64@12.18.0': '@pnpm/exe.linux-riscv64@12.21.0':
resolution: {integrity: sha512-7kMN77xSOYJX8GPSH5RbNAc5oM61LMmcSUukDDUwllnZPXm8GRPskCNsTWy8SCw01Kr1FB+5SwGNMiTdiziLNQ==} resolution: {integrity: sha512-EYv3GzxeBTITCuM3yGHHbpRFpUvyulkXpQ6LsjKAQNL3iaba1E6h9iDmlouLb3Io4AMMsfdk0/uG6poQ41uewA==}
cpu: [riscv64] cpu: [riscv64]
os: [linux] os: [linux]
libc: [glibc] libc: [glibc]
'@pnpm/exe.linux-s390x@12.18.0': '@pnpm/exe.linux-s390x@12.21.0':
resolution: {integrity: sha512-htuSCpEcmDzhKoJqXbPkvfr176dBHU0QIF5mWcRiqxRXAB/1JoYiMYotfjWpk+ztgpB9qlx4XnWlLFAf7gzc6g==} resolution: {integrity: sha512-8VXGNGVNEfs7pL9GTZOzFxjFEnMt4WL3rLOADR5/kPQ7ROTV9GfpVI2DPO/zArXFSkvfc9Zad/WypHLbvzoaTQ==}
cpu: [s390x] cpu: [s390x]
os: [linux] os: [linux]
libc: [glibc] libc: [glibc]
'@pnpm/exe.linux-x64-musl@12.18.0': '@pnpm/exe.linux-x64-musl@12.21.0':
resolution: {integrity: sha512-Uj+vzfIQ62kDP10x36yHZIXVs5ohdNtiPYwn5FhCLlNScHPo0OAI+ShGDtLofiBXKE7umu71Jmjm7N8a8zVcDw==} resolution: {integrity: sha512-MnC5vpIXYubhDZCgCwlfJMg7Cg6HupN2IuouT9gD/tUmOfVdQYqeyYccWbthyo/Jeto8de1oQlxeRN1+1Hl2DQ==}
cpu: [x64] cpu: [x64]
os: [linux] os: [linux]
libc: [musl] libc: [musl]
'@pnpm/exe.linux-x64@12.18.0': '@pnpm/exe.linux-x64@12.21.0':
resolution: {integrity: sha512-OJ+X2wcraldCwj75pCIerWARQSRpdfj0eBTs/2ODyhfeW46ylOnjTIE/GKra6Mn6E72/gBmXS8igrUioa+F9fQ==} resolution: {integrity: sha512-8eufCjHXspKbNS/kh8q4Q0gqJoOuvC4Q5pgos6XS8By/nAMtP+jf8F1Cw9er840kfAX+PJ/ts+A9qnLE91rvXQ==}
cpu: [x64] cpu: [x64]
os: [linux] os: [linux]
libc: [glibc] libc: [glibc]
'@pnpm/exe.win32-arm64@12.18.0': '@pnpm/exe.netbsd-x64@12.21.0':
resolution: {integrity: sha512-wEY6jiACGcbhhi5yD59doHqNTndS7AaujaPmtWAu1DKkHru2hy5fJ9yUGecW72Ypaw2/I3BEprfMOopap2NQtw==} resolution: {integrity: sha512-eyh1M8hQZCkLWxuva7S/fc1SbFbgqg0/5di0dgWmyiuc2Io3dbWVihDun8X+XM8zsR5uhIDvvZpbS9aZQbCovg==}
cpu: [x64]
os: [netbsd]
'@pnpm/exe.win32-arm64@12.21.0':
resolution: {integrity: sha512-7xTxxUXo/grRLivSeIl6B21gnsz7ooe5EMPcJmQqwxc8WLJVReN8MzrlHru8bqXfVr4X3+6ZGZscntKenlCBqQ==}
cpu: [arm64] cpu: [arm64]
os: [win32] os: [win32]
'@pnpm/exe.win32-x64@12.18.0': '@pnpm/exe.win32-x64@12.21.0':
resolution: {integrity: sha512-5FJkghO7RLRkQpWxeVEygW9XsmnNuxzPfXbgwFWCHsFyFhpDn/vOdL88ToQEM0Kt5igdW5s6U0/IDH8Dvkt3pg==} resolution: {integrity: sha512-9TpkJemVApxJ1Z1w0ZFGN+AuSx4nJOqXSJUqMqDvaXTYwGOzvBiiWdFP9GN0ketiWCQS1Q0/pza2E7I3pP0OBQ==}
cpu: [x64] cpu: [x64]
os: [win32] os: [win32]
pnpm@12.18.0: pnpm@12.21.0:
resolution: {integrity: sha512-nXiC1dyCFH7PxOBiqjSDTgrQKWcQoYN6ERWuASEn02txCeMhrBWYod0KZVl2gbHpmRfhLtDXSerpEYeUM2O+sw==} resolution: {integrity: sha512-Zv2CeO4ok1zpUXktNDZ/869cQyonVkRYIwKVM4NbjaUpu+C+UTCv1W7QcT+4eJ5Hutgtk71a4v5UsVVi1idu8A==}
engines: {node: '>=18'} engines: {node: '>=18'}
hasBin: true hasBin: true
snapshots: snapshots:
'@pnpm/exe.android-arm64@12.18.0': '@pnpm/exe.android-arm64@12.21.0':
optional: true optional: true
'@pnpm/exe.android-x64@12.18.0': '@pnpm/exe.android-x64@12.21.0':
optional: true optional: true
'@pnpm/exe.darwin-arm64@12.18.0': '@pnpm/exe.darwin-arm64@12.21.0':
optional: true optional: true
'@pnpm/exe.darwin-x64@12.18.0': '@pnpm/exe.darwin-x64@12.21.0':
optional: true optional: true
'@pnpm/exe.freebsd-x64@12.18.0': '@pnpm/exe.freebsd-x64@12.21.0':
optional: true optional: true
'@pnpm/exe.linux-arm64-musl@12.18.0': '@pnpm/exe.linux-arm64-musl@12.21.0':
optional: true optional: true
'@pnpm/exe.linux-arm64@12.18.0': '@pnpm/exe.linux-arm64@12.21.0':
optional: true optional: true
'@pnpm/exe.linux-ppc64@12.18.0': '@pnpm/exe.linux-ppc64@12.21.0':
optional: true optional: true
'@pnpm/exe.linux-riscv64@12.18.0': '@pnpm/exe.linux-riscv64@12.21.0':
optional: true optional: true
'@pnpm/exe.linux-s390x@12.18.0': '@pnpm/exe.linux-s390x@12.21.0':
optional: true optional: true
'@pnpm/exe.linux-x64-musl@12.18.0': '@pnpm/exe.linux-x64-musl@12.21.0':
optional: true optional: true
'@pnpm/exe.linux-x64@12.18.0': '@pnpm/exe.linux-x64@12.21.0':
optional: true optional: true
'@pnpm/exe.win32-arm64@12.18.0': '@pnpm/exe.netbsd-x64@12.21.0':
optional: true optional: true
'@pnpm/exe.win32-x64@12.18.0': '@pnpm/exe.win32-arm64@12.21.0':
optional: true optional: true
pnpm@12.18.0: '@pnpm/exe.win32-x64@12.21.0':
optional: true
pnpm@12.21.0:
optionalDependencies: optionalDependencies:
'@pnpm/exe.android-arm64': 12.18.0 '@pnpm/exe.android-arm64': 12.21.0
'@pnpm/exe.android-x64': 12.18.0 '@pnpm/exe.android-x64': 12.21.0
'@pnpm/exe.darwin-arm64': 12.18.0 '@pnpm/exe.darwin-arm64': 12.21.0
'@pnpm/exe.darwin-x64': 12.18.0 '@pnpm/exe.darwin-x64': 12.21.0
'@pnpm/exe.freebsd-x64': 12.18.0 '@pnpm/exe.freebsd-x64': 12.21.0
'@pnpm/exe.linux-arm64': 12.18.0 '@pnpm/exe.linux-arm64': 12.21.0
'@pnpm/exe.linux-arm64-musl': 12.18.0 '@pnpm/exe.linux-arm64-musl': 12.21.0
'@pnpm/exe.linux-ppc64': 12.18.0 '@pnpm/exe.linux-ppc64': 12.21.0
'@pnpm/exe.linux-riscv64': 12.18.0 '@pnpm/exe.linux-riscv64': 12.21.0
'@pnpm/exe.linux-s390x': 12.18.0 '@pnpm/exe.linux-s390x': 12.21.0
'@pnpm/exe.linux-x64': 12.18.0 '@pnpm/exe.linux-x64': 12.21.0
'@pnpm/exe.linux-x64-musl': 12.18.0 '@pnpm/exe.linux-x64-musl': 12.21.0
'@pnpm/exe.win32-arm64': 12.18.0 '@pnpm/exe.netbsd-x64': 12.21.0
'@pnpm/exe.win32-x64': 12.18.0 '@pnpm/exe.win32-arm64': 12.21.0
'@pnpm/exe.win32-x64': 12.21.0
--- ---
lockfileVersion: '9.0' lockfileVersion: '9.0'
+1 -1
View File
@@ -77,7 +77,7 @@ tauri-plugin-dialog = "2.8.4"
tauri-plugin-fs = "2.7.1" tauri-plugin-fs = "2.7.1"
tauri-plugin-deep-link = "2.6.3" tauri-plugin-deep-link = "2.6.3"
tauri-plugin-window-state = "2.5.0" tauri-plugin-window-state = "2.5.0"
zip = "9.6.0" zip = "9.5.1"
flate2 = "1.1.11" flate2 = "1.1.11"
reqwest_dav = "0.3.3" reqwest_dav = "0.3.3"
aes-gcm = { version = "0.11.1" } aes-gcm = { version = "0.11.1" }
+2 -2
View File
@@ -210,10 +210,10 @@ pub async fn delete_profile(index: std::string::String) -> CmdResult {
Ok(()) Ok(())
} }
async fn restore_previous_profile(prev_profile: &str) -> CmdResult<()> { async fn restore_previous_profile(prev_profile: &String) -> CmdResult<()> {
logging!(info, Type::Cmd, "尝试恢复到之前的配置: {}", prev_profile); logging!(info, Type::Cmd, "尝试恢复到之前的配置: {}", prev_profile);
let restore_profiles = IProfiles { let restore_profiles = IProfiles {
current: Some(prev_profile.into()), current: Some(prev_profile.to_owned()),
items: None, items: None,
}; };
Config::profiles() Config::profiles()
+2 -2
View File
@@ -216,7 +216,7 @@ impl Config {
.or_else(|| runtime_data.config.as_ref()) .or_else(|| runtime_data.config.as_ref())
.ok_or_else(|| anyhow!("failed to generate runtime config, might need to restart application"))?; .ok_or_else(|| anyhow!("failed to generate runtime config, might need to restart application"))?;
let yaml_str = serde_yaml_ng::to_string(config)?; let yaml_str = serde_yaml_ng::to_string(config)?;
Ok(yaml_str) Ok(format!("# Generated by Clash Verge\n\n{}", yaml_str))
}) })
.await .await
.map_err(|join| anyhow!("runtime serialization task failed: {join}"))? .map_err(|join| anyhow!("runtime serialization task failed: {join}"))?
@@ -224,7 +224,7 @@ impl Config {
pub(crate) async fn write_runtime_file(yaml: &str) -> Result<PathBuf> { pub(crate) async fn write_runtime_file(yaml: &str) -> Result<PathBuf> {
let path = dirs::app_home_dir()?.join(files::RUNTIME_CONFIG); let path = dirs::app_home_dir()?.join(files::RUNTIME_CONFIG);
help::save_yaml_str(&path, yaml, Some("# Generated by Clash Verge")).await?; help::save_yaml_str(&path, yaml).await?;
Ok(path) Ok(path)
} }
+3 -2
View File
@@ -1,5 +1,4 @@
use crate::core::notify::NoticeStatus; use crate::core::notify::NoticeStatus;
use crate::utils::help;
use anyhow::Result; use anyhow::Result;
use clash_verge_draft::DraftTransaction; use clash_verge_draft::DraftTransaction;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@@ -50,7 +49,9 @@ pub(crate) fn dns_override_source(profile_uid: &str, config: &Mapping) -> Result
digest.update(profile_uid.as_bytes()); digest.update(profile_uid.as_bytes());
digest.update([0]); digest.update([0]);
digest.update(serde_json::to_vec(&canonical)?); digest.update(serde_json::to_vec(&canonical)?);
Ok(Some(help::hex_encode(&digest.finalize()).into())) Ok(Some(
digest.finalize().iter().map(|byte| format!("{byte:02x}")).collect(),
))
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
+1 -1
View File
@@ -26,7 +26,7 @@ pub(super) fn normalize_profile_home_url(raw: &str) -> Option<String> {
} }
url.host_str()?; url.host_str()?;
Some(url.as_str().into()) Some(url.to_string().into())
} }
#[derive(Debug, Clone, Deserialize, Serialize, Default, specta::Type)] #[derive(Debug, Clone, Deserialize, Serialize, Default, specta::Type)]
+8 -12
View File
@@ -605,7 +605,7 @@ async fn fetch_proxies_with_timeout() -> Result<Proxies> {
.map_err(Into::into) .map_err(Into::into)
} }
async fn select_node_with_timeout(group_name: &str, node: &str) -> Result<()> { async fn select_node_with_timeout(group_name: &String, node: &String) -> Result<()> {
tokio::time::timeout(MIHOMO_OPERATION_TIMEOUT, async { tokio::time::timeout(MIHOMO_OPERATION_TIMEOUT, async {
handle::Handle::mihomo().select_node_for_group(group_name, node).await handle::Handle::mihomo().select_node_for_group(group_name, node).await
}) })
@@ -761,7 +761,7 @@ pub(crate) async fn record_selected_node(group_name: &str, node: &str) -> Result
return Ok((profiles, false)); return Ok((profiles, false));
}; };
let selected = item.selected.get_or_insert_with(Vec::new); let mut selected = item.selected.clone().unwrap_or_default();
match selected match selected
.iter_mut() .iter_mut()
.find(|entry| entry.name.as_ref() == Some(&group_name)) .find(|entry| entry.name.as_ref() == Some(&group_name))
@@ -770,13 +770,14 @@ pub(crate) async fn record_selected_node(group_name: &str, node: &str) -> Result
if entry.now.as_ref() == Some(&node) { if entry.now.as_ref() == Some(&node) {
return Ok((profiles, false)); return Ok((profiles, false));
} }
entry.now = Some(node.clone()); entry.now = Some(node);
} }
None => selected.push(PrfSelected { None => selected.push(PrfSelected {
name: Some(group_name), name: Some(group_name),
now: Some(node), now: Some(node),
}), }),
} }
item.selected = Some(selected);
profiles.save_file().await?; profiles.save_file().await?;
Ok((profiles, true)) Ok((profiles, true))
}) })
@@ -795,17 +796,12 @@ pub(crate) async fn forget_selected_node(group_name: &str) -> Result<()> {
return Ok((profiles, false)); return Ok((profiles, false));
}; };
let Some(mut selected) = item.selected.take() else { let mut selected = item.selected.clone().unwrap_or_default();
return Ok((profiles, false));
};
if !remove_selected_node(&mut selected, group_name) { if !remove_selected_node(&mut selected, group_name) {
item.selected = Some(selected);
return Ok((profiles, false)); return Ok((profiles, false));
} }
if !selected.is_empty() { item.selected = (!selected.is_empty()).then_some(selected);
item.selected = Some(selected);
}
profiles.save_file().await?; profiles.save_file().await?;
Ok((profiles, true)) Ok((profiles, true))
}) })
@@ -813,7 +809,7 @@ pub(crate) async fn forget_selected_node(group_name: &str) -> Result<()> {
} }
async fn persist_reconciled_selected( async fn persist_reconciled_selected(
profile_uid: &str, profile_uid: &String,
original_selected: &[PrfSelected], original_selected: &[PrfSelected],
selected: Vec<PrfSelected>, selected: Vec<PrfSelected>,
generation: u64, generation: u64,
@@ -822,7 +818,7 @@ async fn persist_reconciled_selected(
return Ok(()); return Ok(());
} }
let profile_uid = String::from(profile_uid); let profile_uid = profile_uid.clone();
let original_selected = original_selected.to_vec(); let original_selected = original_selected.to_vec();
persist_selected_update(false, move |mut profiles| async move { persist_selected_update(false, move |mut profiles| async move {
if !is_activation_current(generation) || profiles.current.as_ref() != Some(&profile_uid) { if !is_activation_current(generation) || profiles.current.as_ref() != Some(&profile_uid) {
+3 -6
View File
@@ -42,12 +42,9 @@ pub async fn notify_event<'a>(event: NotificationEvent<'a>) {
} }
NotificationEvent::ClashModeChanged { mode } => { NotificationEvent::ClashModeChanged { mode } => {
let title = clash_verge_i18n::t!("notifications.clashModeChanged.title"); let title = clash_verge_i18n::t!("notifications.clashModeChanged.title");
let body = clash_verge_i18n::t!("notifications.clashModeChanged.body"); let body = clash_verge_i18n::t!("notifications.clashModeChanged.body")
let body = if body.contains("{mode}") { .replace("{mode}", mode)
body.replace("{mode}", mode).into() .into();
} else {
body
};
notify(title, body); notify(title, body);
} }
NotificationEvent::SystemProxyToggled(enabled) => { NotificationEvent::SystemProxyToggled(enabled) => {
+4 -5
View File
@@ -1,6 +1,5 @@
use super::NoticeStatus; use super::NoticeStatus;
use crate::{APP_HANDLE, singleton}; use crate::{APP_HANDLE, singleton};
#[cfg(target_os = "macos")]
use smartstring::alias::String; use smartstring::alias::String;
use std::sync::{ use std::sync::{
Arc, Arc,
@@ -56,21 +55,21 @@ impl Handle {
Self::send_event(FrontendEvent::RunStateChanged { state: state.clone() }); Self::send_event(FrontendEvent::RunStateChanged { state: state.clone() });
} }
pub fn notify_profile_changed(profile_id: &str) { pub fn notify_profile_changed(profile_id: &String) {
Self::send_event(FrontendEvent::ProfileChanged { Self::send_event(FrontendEvent::ProfileChanged {
current_profile_id: profile_id, current_profile_id: profile_id,
}); });
} }
pub fn notify_timer_updated(profile_index: &str) { pub fn notify_timer_updated(profile_index: &String) {
Self::send_event(FrontendEvent::TimerUpdated { profile_index }); Self::send_event(FrontendEvent::TimerUpdated { profile_index });
} }
pub fn notify_profile_update_started(uid: &str) { pub fn notify_profile_update_started(uid: &String) {
Self::send_event(FrontendEvent::ProfileUpdateStarted { uid }); Self::send_event(FrontendEvent::ProfileUpdateStarted { uid });
} }
pub fn notify_profile_update_completed(uid: &str) { pub fn notify_profile_update_completed(uid: &String) {
Self::send_event(FrontendEvent::ProfileUpdateCompleted { uid }); Self::send_event(FrontendEvent::ProfileUpdateCompleted { uid });
} }
+5 -5
View File
@@ -20,16 +20,16 @@ pub enum FrontendEvent<'a> {
message: Arc<str>, message: Arc<str>,
}, },
ProfileChanged { ProfileChanged {
current_profile_id: &'a str, current_profile_id: &'a String,
}, },
TimerUpdated { TimerUpdated {
profile_index: &'a str, profile_index: &'a String,
}, },
ProfileUpdateStarted { ProfileUpdateStarted {
uid: &'a str, uid: &'a String,
}, },
ProfileUpdateCompleted { ProfileUpdateCompleted {
uid: &'a str, uid: &'a String,
}, },
RunStateChanged { RunStateChanged {
state: crate::core::runstate::RunStateView, state: crate::core::runstate::RunStateView,
@@ -369,7 +369,7 @@ mod wire_tests {
/// One sample per `FrontendEvent` variant, paired with its wire name and payload. /// One sample per `FrontendEvent` variant, paired with its wire name and payload.
#[cfg(test)] #[cfg(test)]
fn sample_frontend_events(uid: &str) -> Vec<(FrontendEvent<'_>, &'static str, serde_json::Value)> { fn sample_frontend_events(uid: &String) -> Vec<(FrontendEvent<'_>, &'static str, serde_json::Value)> {
let state = crate::core::runstate::RunState { let state = crate::core::runstate::RunState {
health: Default::default(), health: Default::default(),
pending: None, pending: None,
+1 -1
View File
@@ -122,7 +122,7 @@ fn allocate_provider_destination(destination: &str, url: &str, reserved: &mut Ha
digest.update(destination.as_bytes()); digest.update(destination.as_bytes());
digest.update([0]); digest.update([0]);
digest.update(url.as_bytes()); digest.update(url.as_bytes());
let digest: String = crate::utils::help::hex_encode(&digest.finalize()); let digest: String = digest.finalize().iter().map(|byte| format!("{byte:02x}")).collect();
let path = Path::new(destination); let path = Path::new(destination);
let extension = path let extension = path
.extension() .extension()
+1 -1
View File
@@ -458,7 +458,7 @@ impl Timer {
} }
} }
fn emit_update_event(uid: &str, is_start: bool) { fn emit_update_event(uid: &String, is_start: bool) {
if is_start { if is_start {
super::handle::Handle::notify_profile_update_started(uid); super::handle::Handle::notify_profile_update_started(uid);
} else { } else {
+3
View File
@@ -342,6 +342,9 @@ impl Tray {
let verge = Config::verge().await.data_arc(); let verge = Config::verge().await.data_arc();
let app_handle = handle::Handle::app_handle(); let app_handle = handle::Handle::app_handle();
self.update_menu_internal(app_handle, false).await?; self.update_menu_internal(app_handle, false).await?;
AsyncHandler::spawn(|| async {
logging_error!(Type::Tray, Self::global().update_menu().await);
});
self.update_icon(&verge).await?; self.update_icon(&verge).await?;
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
self.update_speed_task(verge.enable_tray_speed.unwrap_or(false)); self.update_speed_task(verge.enable_tray_speed.unwrap_or(false));
+1 -1
View File
@@ -435,7 +435,7 @@ impl CoreConfigValidator {
} }
let check_path = dirs::app_home_dir()?.join(crate::constants::files::CHECK_CONFIG); let check_path = dirs::app_home_dir()?.join(crate::constants::files::CHECK_CONFIG);
help::save_yaml_str(&check_path, yaml, None).await?; help::save_yaml_str(&check_path, yaml).await?;
let outcome = Self::validate_config_internal_outcome(dirs::path_to_str(&check_path)?).await?; let outcome = Self::validate_config_internal_outcome(dirs::path_to_str(&check_path)?).await?;
if outcome.is_valid() { if outcome.is_valid() {
*LAST_VALIDATED.lock() = Some(fingerprint); *LAST_VALIDATED.lock() = Some(fingerprint);
+3 -3
View File
@@ -24,12 +24,12 @@ fn lowercase_key(key: &str) -> Value {
Value::from(key.as_str()) Value::from(key.as_str())
} }
pub fn use_lowercase(config: Mapping) -> Mapping { pub fn use_lowercase(config: &Mapping) -> Mapping {
let mut lowercased = Mapping::new(); let mut lowercased = Mapping::new();
for (key, value) in config { for (key, value) in config.iter() {
if let Some(key_str) = key.as_str() { if let Some(key_str) = key.as_str() {
lowercased.insert(lowercase_key(key_str), value); lowercased.insert(lowercase_key(key_str), value.clone());
} }
} }
lowercased lowercased
+3 -3
View File
@@ -16,7 +16,7 @@ fn deep_merge(a: &mut Value, b: Value) {
} }
} }
pub fn use_merge(merge: Mapping, mut config: Mapping) -> Mapping { pub fn use_merge(merge: &Mapping, mut config: Mapping) -> Mapping {
for (key, value) in use_lowercase(merge) { for (key, value) in use_lowercase(merge) {
match (config.get_mut(&key), value) { match (config.get_mut(&key), value) {
(Some(Value::Mapping(existing)), Value::Mapping(overlay)) if key.as_str() == Some("dns") => { (Some(Value::Mapping(existing)), Value::Mapping(overlay)) if key.as_str() == Some("dns") => {
@@ -79,7 +79,7 @@ fn test_merge() -> anyhow::Result<()> {
let merge = serde_yaml_ng::from_str::<Mapping>(merge)?; let merge = serde_yaml_ng::from_str::<Mapping>(merge)?;
let config = serde_yaml_ng::from_str::<Mapping>(config)?; let config = serde_yaml_ng::from_str::<Mapping>(config)?;
let result = use_merge(merge.clone(), config); let result = use_merge(&merge, config);
assert_eq!(result["dns"]["nameserver-policy"], merge["dns"]["nameserver-policy"]); assert_eq!(result["dns"]["nameserver-policy"], merge["dns"]["nameserver-policy"]);
assert_eq!(result["dns"]["fallback-filter"], merge["dns"]["fallback-filter"]); assert_eq!(result["dns"]["fallback-filter"], merge["dns"]["fallback-filter"]);
assert_eq!(result["hosts"], merge["hosts"]); assert_eq!(result["hosts"], merge["hosts"]);
@@ -91,7 +91,7 @@ fn test_merge() -> anyhow::Result<()> {
let cleared = serde_yaml_ng::from_str::<Mapping>( let cleared = serde_yaml_ng::from_str::<Mapping>(
"dns: {enable: false, nameserver-policy: {}, fallback-filter: {}, nameserver: []}\nhosts: {}", "dns: {enable: false, nameserver-policy: {}, fallback-filter: {}, nameserver: []}\nhosts: {}",
)?; )?;
let result = use_merge(cleared.clone(), result); let result = use_merge(&cleared, result);
assert_eq!(result["dns"], cleared["dns"]); assert_eq!(result["dns"], cleared["dns"]);
assert_eq!(result["hosts"], cleared["hosts"]); assert_eq!(result["hosts"], cleared["hosts"]);
+47 -81
View File
@@ -28,7 +28,6 @@ use parking_lot::Mutex;
use serde_yaml_ng::{Mapping, Value}; use serde_yaml_ng::{Mapping, Value};
use smartstring::alias::String; use smartstring::alias::String;
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use std::hash::{Hash as _, Hasher as _};
use tokio::fs; use tokio::fs;
type ResultLog = Vec<(String, String)>; type ResultLog = Vec<(String, String)>;
@@ -237,13 +236,13 @@ async fn process_override_items(
mut result_map: HashMap<String, ResultLog>, mut result_map: HashMap<String, ResultLog>,
merge_item: ChainItem, merge_item: ChainItem,
script_item: ChainItem, script_item: ChainItem,
profile_name: &str, profile_name: &String,
authoritative: &AuthoritativeFields, authoritative: &AuthoritativeFields,
) -> (Mapping, Vec<String>, HashMap<String, ResultLog>) { ) -> (Mapping, Vec<String>, HashMap<String, ResultLog>) {
if let ChainType::Merge(merge) = merge_item.data { if let ChainType::Merge(merge) = merge_item.data {
exists_keys.extend(use_keys(&merge)); exists_keys.extend(use_keys(&merge));
let before = authoritative.current(&config); let before = authoritative.current(&config);
config = use_merge(merge, config); config = use_merge(&merge, config);
let notes: ResultLog = authoritative let notes: ResultLog = authoritative
.overridden(&before, &authoritative.current(&config)) .overridden(&before, &authoritative.current(&config))
.into_iter() .into_iter()
@@ -256,7 +255,7 @@ async fn process_override_items(
if let ChainType::Script(script) = script_item.data { if let ChainType::Script(script) = script_item.data {
let before = authoritative.current(&config); let before = authoritative.current(&config);
let (res_config, changed_keys, mut logs) = use_script(script, config, profile_name.into()).await; let (res_config, changed_keys, mut logs) = use_script(script, config, profile_name.clone()).await;
exists_keys.extend(changed_keys); exists_keys.extend(changed_keys);
config = res_config; config = res_config;
logs.extend( logs.extend(
@@ -321,45 +320,15 @@ struct AuthoritativeFields {
tun: Mapping, tun: Mapping,
dns: Mapping, dns: Mapping,
hosts: Option<Value>, hosts: Option<Value>,
fingerprints: FieldFingerprints,
}
#[derive(Default)]
struct FieldFingerprints {
control_plane: Vec<Option<u64>>,
tun: Vec<Option<u64>>,
dns: Vec<Option<u64>>,
hosts: Option<u64>,
}
fn fingerprint(value: Option<&Value>) -> Option<u64> {
let value = value?;
let mut hasher = std::collections::hash_map::DefaultHasher::new();
value.hash(&mut hasher);
Some(hasher.finish())
} }
impl AuthoritativeFields { impl AuthoritativeFields {
fn capture(config: &Mapping, gui_tun_keys: &[Value], mut dns_settings: Mapping) -> Self { fn capture(config: &Mapping, gui_tun_keys: &[Value], mut dns_settings: Mapping) -> Self {
let control_plane = snapshot_control_plane(config);
let tun = snapshot_tun(config, gui_tun_keys);
let dns = take_mapping(&mut dns_settings, "dns");
let hosts = dns_settings.remove("hosts");
let fingerprints = FieldFingerprints {
control_plane: CONTROL_PLANE_KEYS
.iter()
.map(|&key| fingerprint(control_plane.get(Value::from(key))))
.collect(),
tun: tun.iter().map(|(_, value)| fingerprint(Some(value))).collect(),
dns: dns.iter().map(|(_, value)| fingerprint(Some(value))).collect(),
hosts: fingerprint(hosts.as_ref()),
};
Self { Self {
control_plane, control_plane: snapshot_control_plane(config),
tun, tun: snapshot_tun(config, gui_tun_keys),
dns, dns: take_mapping(&mut dns_settings, "dns"),
hosts, hosts: dns_settings.remove("hosts"),
fingerprints,
} }
} }
@@ -377,50 +346,43 @@ impl AuthoritativeFields {
config config
} }
/// What `config` holds now, for diffing one override. /// The owned values as `config` holds them now, for diffing one override.
fn current(&self, config: &Mapping) -> FieldFingerprints { fn current(&self, config: &Mapping) -> Self {
let tun = config.get("tun").and_then(Value::as_mapping); let tun_keys: Vec<Value> = self.tun.keys().cloned().collect();
let dns = config.get("dns").and_then(Value::as_mapping); let dns = config.get("dns").and_then(Value::as_mapping);
FieldFingerprints { Self {
control_plane: CONTROL_PLANE_KEYS control_plane: snapshot_control_plane(config),
.iter() tun: snapshot_tun(config, &tun_keys),
.map(|&key| fingerprint(config.get(key)))
.collect(),
tun: self
.tun
.keys()
.map(|key| fingerprint(tun.and_then(|map| map.get(key))))
.collect(),
dns: self dns: self
.dns .dns
.keys() .keys()
.map(|key| fingerprint(dns.and_then(|map| map.get(key)))) .filter_map(|key| Some((key.clone(), dns?.get(key)?.clone())))
.collect(), .collect(),
hosts: self.hosts.as_ref().and_then(|_| fingerprint(config.get("hosts"))), hosts: self.hosts.as_ref().and_then(|_| config.get("hosts")).cloned(),
} }
} }
/// Owned keys an override moved off the app value; `enforce` discards those writes. /// Owned keys an override moved off the app value; `enforce` discards those writes.
fn overridden(&self, before: &FieldFingerprints, after: &FieldFingerprints) -> Vec<String> { fn overridden(&self, before: &Self, after: &Self) -> Vec<String> {
let mut keys = Vec::new(); let mut keys = Vec::new();
for (index, &key) in CONTROL_PLANE_KEYS.iter().enumerate() { for &key in CONTROL_PLANE_KEYS {
if before.control_plane[index] != after.control_plane[index] if before.control_plane.get(key) != after.control_plane.get(key)
&& after.control_plane[index] != self.fingerprints.control_plane[index] && after.control_plane.get(key) != self.control_plane.get(key)
{ {
keys.push(key.into()); keys.push(key.into());
} }
} }
for (index, key) in self.tun.keys().enumerate() { for key in self.tun.keys() {
if before.tun[index] != after.tun[index] && after.tun[index] != self.fingerprints.tun[index] { if before.tun.get(key) != after.tun.get(key) && after.tun.get(key) != self.tun.get(key) {
keys.push(format!("tun.{}", key.as_str().unwrap_or_default()).into()); keys.push(format!("tun.{}", key.as_str().unwrap_or_default()).into());
} }
} }
for (index, key) in self.dns.keys().enumerate() { for key in self.dns.keys() {
if before.dns[index] != after.dns[index] && after.dns[index] != self.fingerprints.dns[index] { if before.dns.get(key) != after.dns.get(key) && after.dns.get(key) != self.dns.get(key) {
keys.push(format!("dns.{}", key.as_str().unwrap_or_default()).into()); keys.push(format!("dns.{}", key.as_str().unwrap_or_default()).into());
} }
} }
if self.hosts.is_some() && before.hosts != after.hosts && after.hosts != self.fingerprints.hosts { if self.hosts.is_some() && before.hosts != after.hosts && after.hosts != self.hosts {
keys.push("hosts".into()); keys.push("hosts".into());
} }
keys keys
@@ -591,15 +553,16 @@ fn merge_default_config(
) -> Mapping { ) -> Mapping {
for (key, value) in clash_config.into_iter() { for (key, value) in clash_config.into_iter() {
if key.as_str() == Some("tun") { if key.as_str() == Some("tun") {
if let Value::Mapping(patch_tun) = value { let mut tun = config.get_mut("tun").map_or_else(Mapping::new, |val| {
let mut tun = take_mapping(&mut config, "tun"); val.as_mapping().cloned().unwrap_or_else(Mapping::new)
for (key, value) in patch_tun { });
if !value.is_null() { let patch_tun = value.as_mapping().cloned().unwrap_or_else(Mapping::new);
tun.insert(key, value); for (key, value) in patch_tun.into_iter() {
} if !value.is_null() {
tun.insert(key, value);
} }
config.insert(Value::from("tun"), Value::Mapping(tun));
} }
config.insert("tun".into(), tun.into());
} else { } else {
if key.as_str() == Some("socks-port") && !socks_enabled { if key.as_str() == Some("socks-port") && !socks_enabled {
config.remove("socks-port"); config.remove("socks-port");
@@ -654,7 +617,7 @@ fn merge_default_config(
fn apply_builtin_scripts(mut config: Mapping, enable_builtin: bool) -> Mapping { fn apply_builtin_scripts(mut config: Mapping, enable_builtin: bool) -> Mapping {
if enable_builtin { if enable_builtin {
// The JS path saw a lowercased view; lowercase once, only when the builtin runs. // The JS path saw a lowercased view; lowercase once, only when the builtin runs.
config = use_lowercase(config); config = use_lowercase(&config);
logging!(debug, Type::Core, "run builtin script verge_hy_alpn"); logging!(debug, Type::Core, "run builtin script verge_hy_alpn");
config = builtin_hy_alpn(config); config = builtin_hy_alpn(config);
} }
@@ -686,8 +649,11 @@ fn cleanup_proxy_groups(mut config: Mapping) -> Mapping {
.map_or_default(|seq| { .map_or_default(|seq| {
seq.iter() seq.iter()
.filter_map(|item| match item { .filter_map(|item| match item {
Value::Mapping(map) => map.get("name").and_then(Value::as_str).map(Into::into), Value::Mapping(map) => map
Value::String(name) => Some(name.as_str().into()), .get("name")
.and_then(Value::as_str)
.map(|name| name.to_owned().into()),
Value::String(name) => Some(name.to_owned().into()),
_ => None, _ => None,
}) })
.collect::<HashSet<String>>() .collect::<HashSet<String>>()
@@ -906,7 +872,7 @@ pub async fn enhance(
result_map, result_map,
global_merge, global_merge,
global_script, global_script,
profile_name.as_str(), &profile_name,
&authoritative, &authoritative,
) )
.await; .await;
@@ -917,12 +883,12 @@ pub async fn enhance(
result_map, result_map,
merge_item, merge_item,
script_item, script_item,
profile_name.as_str(), &profile_name,
&authoritative, &authoritative,
) )
.await; .await;
notify_discarded_keys(authoritative.overridden(&authoritative.fingerprints, &authoritative.current(&config))); notify_discarded_keys(authoritative.overridden(&authoritative, &authoritative.current(&config)));
let config = authoritative.enforce(config); let config = authoritative.enforce(config);
let config = ensure_tun_default_mtu(config); let config = ensure_tun_default_mtu(config);
let config = ensure_lan_bind_address(config); let config = ensure_lan_bind_address(config);
@@ -1441,7 +1407,7 @@ mod tests {
uid: uid.into(), uid: uid.into(),
data: ChainType::Merge(merge.clone()), data: ChainType::Merge(merge.clone()),
}; };
let profile_name = "test-profile"; let profile_name = "test-profile".into();
let (config, keys, logs) = process_override_items( let (config, keys, logs) = process_override_items(
config, config,
vec![], vec![],
@@ -1451,7 +1417,7 @@ mod tests {
uid: "global-script".into(), uid: "global-script".into(),
data: ChainType::Script(script.into()), data: ChainType::Script(script.into()),
}, },
profile_name, &profile_name,
&authoritative, &authoritative,
) )
.await; .await;
@@ -1464,7 +1430,7 @@ mod tests {
uid: "profile-script".into(), uid: "profile-script".into(),
data: ChainType::Script(script.into()), data: ChainType::Script(script.into()),
}, },
profile_name, &profile_name,
&authoritative, &authoritative,
) )
.await; .await;
@@ -1540,7 +1506,7 @@ mod tests {
), ),
}; };
let profile_name = "test-profile"; let profile_name = "test-profile".into();
let authoritative = AuthoritativeFields::capture(&config, &[], Mapping::new()); let authoritative = AuthoritativeFields::capture(&config, &[], Mapping::new());
let (config, exists_keys, result_map) = process_override_items( let (config, exists_keys, result_map) = process_override_items(
config, config,
@@ -1548,7 +1514,7 @@ mod tests {
HashMap::new(), HashMap::new(),
global_merge, global_merge,
global_script, global_script,
profile_name, &profile_name,
&authoritative, &authoritative,
) )
.await; .await;
@@ -1558,7 +1524,7 @@ mod tests {
result_map, result_map,
profile_merge, profile_merge,
profile_script, profile_script,
profile_name, &profile_name,
&authoritative, &authoritative,
) )
.await; .await;
+48 -79
View File
@@ -1,7 +1,7 @@
use crate::{process::AsyncHandler, utils::tmpl}; use crate::{process::AsyncHandler, utils::tmpl};
use super::field::use_lowercase; use super::field::use_lowercase;
use anyhow::Result; use anyhow::{Error, Result};
use boa_engine::{Context, JsString, JsValue, Source, js_string, native_function::NativeFunction, property::Attribute}; use boa_engine::{Context, JsString, JsValue, Source, js_string, native_function::NativeFunction, property::Attribute};
use clash_verge_logging::{Type, logging}; use clash_verge_logging::{Type, logging};
use parking_lot::Mutex; use parking_lot::Mutex;
@@ -22,26 +22,14 @@ type EvalOutcome = (Result<Mapping, std::string::String>, Vec<(String, String)>)
pub(super) async fn use_script(script: String, config: Mapping, name: String) -> ScriptResult { pub(super) async fn use_script(script: String, config: Mapping, name: String) -> ScriptResult {
// The template is identity-plus-lowercasing; skip the Boa round-trip. // The template is identity-plus-lowercasing; skip the Boa round-trip.
if script == tmpl::ITEM_SCRIPT { if script == tmpl::ITEM_SCRIPT {
return (use_lowercase(config), vec![], vec![]); return (use_lowercase(&config), vec![], vec![]);
} }
let json = match serde_json::to_value(&config) { let json = match serde_json::to_string(&use_lowercase(&config)) {
Ok(mut json) => { Ok(json) if json.len() <= MAX_JSON_SIZE => json,
if let Some(map) = json.as_object_mut() { Ok(_) => {
let mut lowered = serde_json::Map::with_capacity(map.len()); let message = "Configuration size exceeds maximum allowed size";
for (key, value) in std::mem::take(map) { return (config, vec![], vec![("exception".into(), message.into())]);
let mut key = key;
key.make_ascii_lowercase();
lowered.insert(key, value);
}
*map = lowered;
}
if json_approx_size(&json) <= MAX_JSON_SIZE {
json
} else {
let message = "Configuration size exceeds maximum allowed size";
return (config, vec![], vec![("exception".into(), message.into())]);
}
} }
Err(err) => return (config, vec![], vec![("exception".into(), err.to_string().into())]), Err(err) => return (config, vec![], vec![("exception".into(), err.to_string().into())]),
}; };
@@ -78,7 +66,7 @@ pub(super) async fn use_script(script: String, config: Mapping, name: String) ->
} }
/// Console logs survive every failure path. /// Console logs survive every failure path.
fn eval_script(script: &str, config_json: &serde_json::Value, name: &String) -> EvalOutcome { fn eval_script(script: &str, config_json: &str, name: &String) -> EvalOutcome {
let mut context = Context::default(); let mut context = Context::default();
context context
@@ -143,11 +131,12 @@ fn eval_script(script: &str, config_json: &serde_json::Value, name: &String) ->
});"#, });"#,
)); ));
let config_value = match JsValue::from_json(config_json, &mut context) { // Bind the JSON instead of embedding it in program source; Boa's parser never chews it.
Ok(value) => value, if let Err(err) = context.register_global_property(
Err(err) => return bail(format!("failed to bind config for script: {err}")), js_string!("__verge_config__"),
}; JsValue::from(JsString::from(config_json)),
if let Err(err) = context.register_global_property(js_string!("__verge_config__"), config_value, Attribute::all()) { Attribute::all(),
) {
return bail(format!("failed to bind config for script: {err}")); return bail(format!("failed to bind config for script: {err}"));
} }
@@ -160,61 +149,31 @@ fn eval_script(script: &str, config_json: &serde_json::Value, name: &String) ->
let code = format!( let code = format!(
r"try{{ r"try{{
{script}; {script};
main(globalThis.__verge_config__,'{safe_name}') JSON.stringify(main(JSON.parse(globalThis.__verge_config__),'{safe_name}')||'')
}} catch(err) {{ }} catch(err) {{
`__error_flag__ ${{err.toString()}}` `__error_flag__ ${{err.toString()}}`
}}" }}"
); );
let result = match context.eval(Source::from_bytes(code.as_str())) { let result = match context.eval(Source::from_bytes(code.as_str())) {
Ok(result) if result.is_string() => result,
_ => return bail("main function should return object".to_owned()),
};
let result = match result.to_string(&mut context) {
Ok(result) => result, Ok(result) => result,
Err(err) => { Err(e) => return bail(format!("Failed to convert JS result to string: {e}")),
logging!(
error,
Type::Config,
"Script execution error: {err}. Script name: {name}"
);
return bail("Script execution failed".to_owned());
}
}; };
// The JS wrapper funnels exceptions into a marker string; surface its text. let result = match result.to_std_string() {
if result.is_string() { Ok(result) => result,
let text = result Err(_) => return bail("Failed to convert JS string to std string".to_owned()),
.to_string(&mut context)
.ok()
.and_then(|text| text.to_std_string().ok())
.unwrap_or_default();
if text.trim_start().starts_with("__error_flag__") {
logging!(
error,
Type::Config,
"Script execution error: {}. Script name: {name}",
text.trim_start()["__error_flag__".len()..].trim()
);
return bail("Script execution failed".to_owned());
}
}
if !result.is_object() {
return bail("main function should return object".to_owned());
}
let result = match result.to_json(&mut context) {
Ok(Some(result)) => result,
Ok(None) => return bail("main function should return object".to_owned()),
Err(err) => {
logging!(
error,
Type::Config,
"Script execution error: {err}. Script name: {name}"
);
return bail("Script execution failed".to_owned());
}
}; };
if json_approx_size(&result) > MAX_JSON_SIZE {
if result.len() > MAX_JSON_SIZE {
return bail("Script result exceeds maximum allowed size".to_owned()); return bail("Script result exceeds maximum allowed size".to_owned());
} }
match serde_json::from_value::<Mapping>(result) { match parse_json_safely(&result) {
Ok(config) => (Ok(use_lowercase(config)), outputs.lock().to_vec()), Ok(config) => (Ok(use_lowercase(&config)), outputs.lock().to_vec()),
Err(err) => { Err(err) => {
logging!( logging!(
error, error,
@@ -226,17 +185,27 @@ fn eval_script(script: &str, config_json: &serde_json::Value, name: &String) ->
} }
} }
/// Serialized-size estimate without building the serialized string; a DoS guard, not an exact byte count. fn parse_json_safely(json_str: &str) -> Result<Mapping, Error> {
fn json_approx_size(value: &serde_json::Value) -> usize { if json_str.len() > MAX_JSON_SIZE {
match value { anyhow::bail!("JSON string too large");
serde_json::Value::String(s) => s.len() + 2, }
serde_json::Value::Object(map) => map
.iter() let json_str = strip_outer_quotes(json_str);
.map(|(key, value)| key.len() + 4 + json_approx_size(value)) Ok(serde_json::from_str::<Mapping>(json_str)?)
.sum(), }
serde_json::Value::Array(items) => items.iter().map(json_approx_size).sum(),
serde_json::Value::Number(n) => n.to_string().len(), // 安全地移除外层引号
serde_json::Value::Bool(_) | serde_json::Value::Null => 4, fn strip_outer_quotes(s: &str) -> &str {
let s = s.trim();
if s.len() < 2 {
return s;
}
if (s.starts_with('"') && s.ends_with('"')) || (s.starts_with('\'') && s.ends_with('\'')) {
&s[1..s.len() - 1]
} else {
s
} }
} }
+10 -2
View File
@@ -8,10 +8,18 @@ macro_rules! revise {
} }
pub fn use_tun(mut config: Mapping, enable: bool) -> Mapping { pub fn use_tun(mut config: Mapping, enable: bool) -> Mapping {
let mut tun_val = super::take_mapping(&mut config, "tun"); let tun_key = Value::from("tun");
let tun_val = config.get(&tun_key);
let mut tun_val = tun_val.map_or_else(Mapping::new, |val| {
val.as_mapping().cloned().unwrap_or_else(Mapping::new)
});
if enable { if enable {
let mut dns_val = super::take_mapping(&mut config, "dns"); let dns_key = Value::from("dns");
let dns_val = config.get(&dns_key);
let mut dns_val = dns_val.map_or_else(Mapping::new, |val| {
val.as_mapping().cloned().unwrap_or_else(Mapping::new)
});
let ipv6_key = Value::from("ipv6"); let ipv6_key = Value::from("ipv6");
let ipv6_val = config.get(&ipv6_key).and_then(|v| v.as_bool()).unwrap_or(false); let ipv6_val = config.get(&ipv6_key).and_then(|v| v.as_bool()).unwrap_or(false);
+2 -2
View File
@@ -123,7 +123,7 @@ pub async fn list_wevdav_backup() -> Result<Vec<ListFile>> {
} }
pub async fn delete_webdav_backup(filename: String) -> Result<()> { pub async fn delete_webdav_backup(filename: String) -> Result<()> {
let name = filename.clone(); let name = filename.to_string();
backup::WebDavClient::global().delete(filename).await.map_err(|err| { backup::WebDavClient::global().delete(filename).await.map_err(|err| {
logging!( logging!(
error, error,
@@ -165,7 +165,7 @@ pub async fn restore_webdav_backup(filename: String) -> Result<()> {
let backup_storage_path = app_home_dir() let backup_storage_path = app_home_dir()
.map_err(|e| anyhow::anyhow!("Failed to get app home dir: {e}"))? .map_err(|e| anyhow::anyhow!("Failed to get app home dir: {e}"))?
.join(filename.as_str()); .join(filename.as_str());
let name = filename.clone(); let name = filename.to_string();
backup::WebDavClient::global() backup::WebDavClient::global()
.download(filename, backup_storage_path.clone()) .download(filename, backup_storage_path.clone())
.await .await
+5 -5
View File
@@ -103,7 +103,7 @@ pub async fn switch_proxy_node(group_name: &str, proxy_name: &str, unfix: bool)
Ok(()) Ok(())
} }
async fn should_update_profile(uid: &str, ignore_auto_update: bool) -> Result<Option<(String, Option<PrfOption>)>> { async fn should_update_profile(uid: &String, ignore_auto_update: bool) -> Result<Option<(String, Option<PrfOption>)>> {
let profiles = Config::profiles().await; let profiles = Config::profiles().await;
let profiles = profiles.latest_arc(); let profiles = profiles.latest_arc();
let item = profiles.get_item(uid)?; let item = profiles.get_item(uid)?;
@@ -138,8 +138,8 @@ async fn should_update_profile(uid: &str, ignore_auto_update: bool) -> Result<Op
#[tracing::instrument(skip_all, level = "info", fields(uid = %uid, strategy = tracing::field::Empty, configured_elapsed = tracing::field::Empty, clash_elapsed = tracing::field::Empty, system_elapsed = tracing::field::Empty))] #[tracing::instrument(skip_all, level = "info", fields(uid = %uid, strategy = tracing::field::Empty, configured_elapsed = tracing::field::Empty, clash_elapsed = tracing::field::Empty, system_elapsed = tracing::field::Empty))]
async fn perform_profile_update( async fn perform_profile_update(
uid: &str, uid: &String,
url: &str, url: &String,
opt: Option<&PrfOption>, opt: Option<&PrfOption>,
option: Option<&PrfOption>, option: Option<&PrfOption>,
is_mannual_trigger: bool, is_mannual_trigger: bool,
@@ -234,7 +234,7 @@ async fn perform_profile_update(
} }
#[tracing::instrument(skip_all, level = "info", fields(uid = %uid, manual = is_mannual_trigger))] #[tracing::instrument(skip_all, level = "info", fields(uid = %uid, manual = is_mannual_trigger))]
pub async fn update_profile(uid: &str, option: Option<&PrfOption>, is_mannual_trigger: bool) -> Result<()> { pub async fn update_profile(uid: &String, option: Option<&PrfOption>, is_mannual_trigger: bool) -> Result<()> {
let url_opt = should_update_profile(uid, is_mannual_trigger).await?; let url_opt = should_update_profile(uid, is_mannual_trigger).await?;
let profile_persisted = match url_opt { let profile_persisted = match url_opt {
@@ -245,7 +245,7 @@ pub async fn update_profile(uid: &str, option: Option<&PrfOption>, is_mannual_tr
None => false, None => false,
}; };
let profiles = Config::profiles().await; let profiles = Config::profiles().await;
let is_current = profiles.latest_arc().current.as_deref() == Some(uid); let is_current = profiles.latest_arc().current.as_ref() == Some(uid);
let should_refresh = is_current || (!profile_persisted && is_mannual_trigger); let should_refresh = is_current || (!profile_persisted && is_mannual_trigger);
if should_refresh { if should_refresh {
+10 -22
View File
@@ -137,11 +137,16 @@ fn is_short_id(key: &Value) -> bool {
pub async fn save_yaml<T: Serialize + Sync>(path: &Path, data: &T, prefix: Option<&str>) -> Result<()> { pub async fn save_yaml<T: Serialize + Sync>(path: &Path, data: &T, prefix: Option<&str>) -> Result<()> {
let data_str = with_encryption(|| async { serde_yaml_ng::to_string(data) }).await?; let data_str = with_encryption(|| async { serde_yaml_ng::to_string(data) }).await?;
save_yaml_str(path, &data_str, prefix).await let yaml_str = match prefix {
Some(prefix) => format!("{prefix}\n\n{data_str}"),
None => data_str,
};
save_yaml_str(path, &yaml_str).await
} }
/// Atomic replace with pre-serialized content; the payload must not need the encryption scope. /// Atomic replace with pre-serialized content; the payload must not need the encryption scope.
pub async fn save_yaml_str(path: &Path, yaml_str: &str, prefix: Option<&str>) -> Result<()> { pub async fn save_yaml_str(path: &Path, yaml_str: &str) -> Result<()> {
let (temporary, file) = loop { let (temporary, file) = loop {
let temporary = path.with_extension(format!("tmp-{}-{}", std::process::id(), nanoid!())); let temporary = path.with_extension(format!("tmp-{}-{}", std::process::id(), nanoid!()));
match std::fs::OpenOptions::new() match std::fs::OpenOptions::new()
@@ -167,16 +172,9 @@ pub async fn save_yaml_str(path: &Path, yaml_str: &str, prefix: Option<&str>) ->
let _ = std::fs::remove_file(path); let _ = std::fs::remove_file(path);
}); });
let mut file = tokio::fs::File::from_std(file); let mut file = tokio::fs::File::from_std(file);
async fn write_chunk(file: &mut tokio::fs::File, bytes: &[u8], path: &Path) -> Result<()> { file.write_all(yaml_str.as_bytes())
file.write_all(bytes) .await
.await .with_context(|| format!("failed to write temporary file for \"{}\"", path.display()))?;
.with_context(|| format!("failed to write temporary file for \"{}\"", path.display()))
}
if let Some(prefix) = prefix {
write_chunk(&mut file, prefix.as_bytes(), path).await?;
write_chunk(&mut file, b"\n\n", path).await?;
}
write_chunk(&mut file, yaml_str.as_bytes(), path).await?;
file.flush() file.flush()
.await .await
.with_context(|| format!("failed to flush temporary file for \"{}\"", path.display()))?; .with_context(|| format!("failed to flush temporary file for \"{}\"", path.display()))?;
@@ -222,16 +220,6 @@ pub fn parse_str<T: FromStr>(target: &str, key: &str) -> Option<T> {
}) })
} }
pub fn hex_encode(bytes: &[u8]) -> String {
const HEX: &[u8; 16] = b"0123456789abcdef";
let mut out = String::with_capacity(bytes.len() * 2);
for &byte in bytes {
out.push(HEX[usize::from(byte >> 4)] as char);
out.push(HEX[usize::from(byte & 0x0f)] as char);
}
out
}
/// Masks query values and token-like path segments for logging. /// Masks query values and token-like path segments for logging.
pub fn mask_url(url: &str) -> String { pub fn mask_url(url: &str) -> String {
let (path_part, query_part) = match url.find('?') { let (path_part, query_part) = match url.find('?') {
+3 -3
View File
@@ -47,7 +47,7 @@ fn extract_subscription_info(link_parsed: &Url) -> Option<(std::string::String,
let name = link_parsed let name = link_parsed
.query_pairs() .query_pairs()
.find(|(key, _)| key == "name") .find(|(key, _)| key == "name")
.map(|(_, value)| value.into()); .map(|(_, value)| value.into_owned().into());
let url = extract_subscription_url(link_parsed)?; let url = extract_subscription_url(link_parsed)?;
Some((url, name)) Some((url, name))
} }
@@ -123,7 +123,7 @@ async fn fetch_profile_item(url: &str, name: Option<&String>) -> Option<PrfItem>
} }
} }
async fn post_import_updates(uid: &str, had_current_profile: bool) { async fn post_import_updates(uid: &String, had_current_profile: bool) {
handle::Handle::refresh_verge(); handle::Handle::refresh_verge();
handle::Handle::notify_profile_changed(uid); handle::Handle::notify_profile_changed(uid);
@@ -131,7 +131,7 @@ async fn post_import_updates(uid: &str, had_current_profile: bool) {
false false
} else { } else {
let profiles = Config::profiles().await; let profiles = Config::profiles().await;
profiles.latest_arc().current.as_deref() == Some(uid) profiles.latest_arc().current.as_ref() == Some(uid)
}; };
if should_update_core { if should_update_core {