mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-10 12:22:07 +08:00
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.
This commit is contained in:
@@ -64,10 +64,7 @@ impl ChainItem {
|
|||||||
/// 内建支持一些脚本
|
/// 内建支持一些脚本
|
||||||
pub fn builtin() -> Vec<Self> {
|
pub fn builtin() -> Vec<Self> {
|
||||||
// data intentionally empty: the enhance loop dispatches on uid to native implementations
|
// data intentionally empty: the enhance loop dispatches on uid to native implementations
|
||||||
vec![
|
vec![Self::to_script("verge_hy_alpn", "")]
|
||||||
Self::to_script("verge_hy_alpn", ""),
|
|
||||||
Self::to_script("verge_meta_guard", ""),
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_script<U: Into<String>, D: Into<String>>(uid: U, data: D) -> Self {
|
pub fn to_script<U: Into<String>, D: Into<String>>(uid: U, data: D) -> Self {
|
||||||
|
|||||||
@@ -610,7 +610,6 @@ fn apply_builtin_scripts(mut config: Mapping, enable_builtin: bool) -> Mapping {
|
|||||||
logging!(debug, Type::Core, "run builtin script {}", item.uid);
|
logging!(debug, Type::Core, "run builtin script {}", item.uid);
|
||||||
config = match item.uid.as_str() {
|
config = match item.uid.as_str() {
|
||||||
"verge_hy_alpn" => builtin_hy_alpn(config),
|
"verge_hy_alpn" => builtin_hy_alpn(config),
|
||||||
"verge_meta_guard" => builtin_meta_guard(config),
|
|
||||||
_ => config,
|
_ => config,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -633,14 +632,6 @@ fn builtin_hy_alpn(mut config: Mapping) -> Mapping {
|
|||||||
config
|
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 {
|
fn cleanup_proxy_groups(mut config: Mapping) -> Mapping {
|
||||||
// built-in proxies docs: https://wiki.metacubex.one/config/proxies/built-in
|
// built-in proxies docs: https://wiki.metacubex.one/config/proxies/built-in
|
||||||
const BUILTIN_POLICIES: &[&str] = &["DIRECT", "REJECT", "REJECT-DROP", "PASS", "PASS-RULE"];
|
const BUILTIN_POLICIES: &[&str] = &["DIRECT", "REJECT", "REJECT-DROP", "PASS", "PASS-RULE"];
|
||||||
|
|||||||
Reference in New Issue
Block a user