feat: merge default proxy groups of all subscription

This commit is contained in:
2026-07-20 15:00:11 +08:00
parent 2b73f83a2a
commit 7ff3daa9d3
4 changed files with 172 additions and 2 deletions

View File

@ -25,12 +25,22 @@ func PrefixProxyNames(subscriptionName string, data map[string]interface{}) []Pr
refs := renameProxies(subscriptionName, data, rename)
renameProxyGroups(subscriptionName, data, rename)
rewriteGroupProxyReferences(data, rename)
rewriteRuleTargets(data, rename)
RewriteReferences(data, rename)
return refs
}
// RewriteReferences rewrites every reference to a renamed proxy or
// proxy-group — inside other groups' "proxies" lists and inside
// data["rules"]' rule targets — to the new name. Exposed separately from
// PrefixProxyNames so callers that rename groups after the fact (e.g.
// collapsing several subscriptions' default selector group into one) can
// reuse the same rewrite logic without re-running the proxy/group renaming.
func RewriteReferences(data map[string]interface{}, rename map[string]string) {
rewriteGroupProxyReferences(data, rename)
rewriteRuleTargets(data, rename)
}
func renameProxies(subscriptionName string, data map[string]interface{}, rename map[string]string) []ProxyRef {
proxiesRaw, ok := data["proxies"].([]interface{})
if !ok {