From 60db73c82d7d7e3f3ffd7b3755acbff0dbfdacce Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Wed, 28 Oct 2026 06:31:06 +0800 Subject: [PATCH] refactor(enhance): drop unreachable mode script guard merge_default_config overwrites the profile's mode with the verge-owned clash config, whose mode is always present (template seeds rule and patch semantics never clear it) and restricted to rule/global/direct; change_clash_mode is rejected by the core before persisting anything else. mode:script can therefore only arrive through a hand-crafted patch_clash call, and for that path an explicit invalid-mode validation error is more honest than silently rewriting to rule. mihomo rejects mode:script outright (invalid mode), and user merge/script chains run after the builtins, so the guard never covered them anyway. --- src-tauri/src/enhance/chain.rs | 5 +---- src-tauri/src/enhance/mod.rs | 9 --------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src-tauri/src/enhance/chain.rs b/src-tauri/src/enhance/chain.rs index 27750d4d7..ce85e0e1f 100644 --- a/src-tauri/src/enhance/chain.rs +++ b/src-tauri/src/enhance/chain.rs @@ -64,10 +64,7 @@ impl ChainItem { /// 内建支持一些脚本 pub fn builtin() -> Vec { // data intentionally empty: the enhance loop dispatches on uid to native implementations - vec![ - Self::to_script("verge_hy_alpn", ""), - Self::to_script("verge_meta_guard", ""), - ] + vec![Self::to_script("verge_hy_alpn", "")] } pub fn to_script, D: Into>(uid: U, data: D) -> Self { diff --git a/src-tauri/src/enhance/mod.rs b/src-tauri/src/enhance/mod.rs index 38385d752..d153e747c 100644 --- a/src-tauri/src/enhance/mod.rs +++ b/src-tauri/src/enhance/mod.rs @@ -610,7 +610,6 @@ fn apply_builtin_scripts(mut config: Mapping, enable_builtin: bool) -> Mapping { logging!(debug, Type::Core, "run builtin script {}", item.uid); config = match item.uid.as_str() { "verge_hy_alpn" => builtin_hy_alpn(config), - "verge_meta_guard" => builtin_meta_guard(config), _ => config, }; } @@ -633,14 +632,6 @@ fn builtin_hy_alpn(mut config: Mapping) -> Mapping { config } -fn builtin_meta_guard(mut config: Mapping) -> Mapping { - if config.get("mode").and_then(Value::as_str) == Some("script") { - config.insert(Value::from("mode"), Value::from("rule")); - } - - config -} - fn cleanup_proxy_groups(mut config: Mapping) -> Mapping { // built-in proxies docs: https://wiki.metacubex.one/config/proxies/built-in const BUILTIN_POLICIES: &[&str] = &["DIRECT", "REJECT", "REJECT-DROP", "PASS", "PASS-RULE"];