mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-12-04 21:30:06 +08:00
* chore(clippy): scope crate lint policy Keep panic-on-error lints at application target roots and scope signal dependencies to Linux. * docs(agents): define Rust backend architecture boundaries Document which layer owns Rust capabilities, fallible inputs, background work, and crate validation. * refactor(draft): type async publication conflicts Return typed conflicts for async Draft edits. Release the lock and edit permit before converting the error, and exercise overlapping updates. * refactor(logging): use typed logger errors Expose crate-owned logger errors and preserve the underlying error sources. * refactor(subscription): extract response decoding Keep HTTP and persistence in the app. Decode response metadata and framing in the crate, and fall back when the server filename is invalid. * refactor(profile): extract profile models and index rules Move profile models and index rules into the crate, preserving serialization and returning a typed missing-profile error. * refactor(profile): separate subscription refresh and scheduling policy Separate download and scheduling policy from the subscription use case while retaining the existing write path. * refactor(subscription): decode deep links in the subscription crate * refactor(profile): extract selected node recovery rules * docs(agents): define dependencies between capability crates * refactor(task): move retry primitives into the task crate * refactor(backup): extract backup ZIP writing * refactor(subscription): keep profile writes outside proxy fallback * refactor(runtime-bundle): extract runtime bundle planning Plan provider destinations and assets in the crate. Adapt the plan to the Service wire format at the call site. * perf(runtime-bundle): share destination strings with tristr Share destination storage within bundle planning and preserve the Service wire strings and provider readback. * refactor(profile): extract script validation and execution Share the Boa validation and execution API while preserving the save-side timeout and diagnostics. * refactor(config): extract configuration renderer Render from inputs supplied by the app, reuse the script crate, and preserve the default template fast path. * refactor(proxy): extract proxy view and its use case Project the Mihomo snapshot into the existing IPC DTO and move use-case orchestration out of the command. * refactor(config): inject the profile script executor * refactor(config): centralize Mihomo YAML output * perf(runtime-bundle): read remote providers from borrowed configuration * chore(clippy): scope crate lint policy Keep panic-on-error lints at application target roots and scope signal dependencies to Linux. * docs(agents): define Rust backend architecture boundaries Document which layer owns Rust capabilities, fallible inputs, background work, and crate validation. * refactor(draft): type async publication conflicts Return typed conflicts for async Draft edits. Release the lock and edit permit before converting the error, and exercise overlapping updates. * refactor(logging): use typed logger errors Expose crate-owned logger errors and preserve the underlying error sources. * refactor(subscription): extract response decoding Keep HTTP and persistence in the app. Decode response metadata and framing in the crate, and fall back when the server filename is invalid. * refactor(profile): extract profile models and index rules Move profile models and index rules into the crate, preserving serialization and returning a typed missing-profile error. * refactor(profile): separate subscription refresh and scheduling policy Separate download and scheduling policy from the subscription use case while retaining the existing write path. * refactor(subscription): decode deep links in the subscription crate * refactor(profile): extract selected node recovery rules * docs(agents): define dependencies between capability crates * refactor(task): move retry primitives into the task crate * refactor(backup): extract backup ZIP writing * refactor(subscription): keep profile writes outside proxy fallback * fix(profile): preserve delays for future update timestamps * fix(subscription): preserve filenames from response headers and URL paths * fix(subscription): separate deep link parameters from nested URLs * refactor(profile): look up the refresh target once * refactor(subscription): pass the proxy directly to each download * refactor(profile): build companion options in one place * refactor(profile): remove companions from the deleted profile * style(profile): keep profile fields together * refactor(profile): name index operations after what they change * refactor(profile): call the core reload directly * refactor(backup): move archive validation to the restore change * refactor(config): name the runtime rendering step * refactor(config): remove the unused runtime patch API * refactor(config): accumulate profile keys and logs during rendering * refactor(config): load cached chain items directly * refactor(script): keep console state local to evaluation * refactor(proxy): read group order and scope in one pass * refactor(config): reuse sequence storage when applying profile edits * refactor(proxy): collect provider snapshots in display order * refactor(proxy): build the view from its input * refactor(runtime-bundle): share provider section order * fix(config): fill blank IPv6 fake IP ranges in TUN mode * fix(config): keep runtime field sorting stable * perf(config): reuse profile sequence storage during rendering * fix(script): check the evaluated profile entry point * fix(script): support runtime console methods during validation * perf(script): count integer digits without formatting JSON * perf(proxy): resolve unique members without building scope caches * fix(runtime-bundle): reject mixed owners of a provider path * perf(runtime-bundle): reuse the normalized destination buffer * fix(script): reject oversized names before escaping
62 lines
2.4 KiB
Rust
62 lines
2.4 KiB
Rust
use clash_verge_proxy_view::GroupScope;
|
|
use serde_yaml_ng::Mapping;
|
|
use std::collections::BTreeMap;
|
|
use tristr::alias::String as ViewString;
|
|
|
|
pub(super) fn runtime_groups(config: Option<&Mapping>) -> (Vec<ViewString>, BTreeMap<ViewString, GroupScope>) {
|
|
let mut order = Vec::new();
|
|
let mut scopes = BTreeMap::new();
|
|
let Some(config) = config else { return (order, scopes) };
|
|
let Some(groups) = config.get("proxy-groups").and_then(|groups| groups.as_sequence()) else {
|
|
return (order, scopes);
|
|
};
|
|
let mut all_providers = None;
|
|
let flag = |group: &Mapping, key: &str| group.get(key).and_then(|value| value.as_bool()) == Some(true);
|
|
|
|
for group in groups.iter().filter_map(|group| group.as_mapping()) {
|
|
let Some(name) = group.get("name").and_then(|name| name.as_str()) else {
|
|
continue;
|
|
};
|
|
let name = ViewString::from(name);
|
|
// Mihomo sorts all providers when either flag replaces the explicit use list.
|
|
let providers = if flag(group, "include-all") || flag(group, "include-all-providers") {
|
|
all_providers
|
|
.get_or_insert_with(|| {
|
|
let mut names = config
|
|
.get("proxy-providers")
|
|
.and_then(|providers| providers.as_mapping())
|
|
.into_iter()
|
|
.flat_map(|providers| providers.keys())
|
|
.filter_map(|name| name.as_str())
|
|
.map(ViewString::from)
|
|
.collect::<Vec<_>>();
|
|
names.sort();
|
|
names
|
|
})
|
|
.clone()
|
|
} else {
|
|
group
|
|
.get("use")
|
|
.and_then(|providers| providers.as_sequence())
|
|
.into_iter()
|
|
.flatten()
|
|
.filter_map(|provider| provider.as_str())
|
|
.map(ViewString::from)
|
|
.collect()
|
|
};
|
|
let exclude_types = group
|
|
.get("exclude-type")
|
|
.and_then(|types| types.as_str())
|
|
.filter(|types| !types.is_empty())
|
|
.map_or_default(|types| types.split('|').map(ViewString::from).collect());
|
|
let scope = GroupScope {
|
|
providers,
|
|
exclude_types,
|
|
};
|
|
if scopes.insert(name.clone(), scope).is_none() && !name.is_empty() && name != "GLOBAL" {
|
|
order.push(name);
|
|
}
|
|
}
|
|
(order, scopes)
|
|
}
|