feat: evolve rate-filter to a more generic filter

This commit is contained in:
2026-07-28 20:40:12 +08:00
parent a3e3079af1
commit b206594eb8
15 changed files with 492 additions and 193 deletions

View File

@ -24,18 +24,17 @@ func ParseConfig(raw interface{}) (*Config, error) {
}
// Apply runs every ssm automation rule against finalConfig (the fully
// merged generated config, with essential/DNS defaults already applied),
// using proxies as the pool collected while merging active subscriptions.
// Each rule/patch is independent: one failing doesn't stop the rest, and
// all failures are returned as non-fatal errors for the caller to log.
// merged generated config — subscription-provided proxy-groups already
// merged in, essential/DNS defaults already applied), using proxies as the
// pool collected while merging active subscriptions. proxy-groups rules run
// first so filters rules can also scrub proxies out of the groups they
// build. Each rule/patch is independent: one failing doesn't stop the rest,
// and all failures are returned as non-fatal errors for the caller to log.
func Apply(finalConfig map[string]interface{}, cfg *Config, proxies []ProxyRef) []error {
var errs []error
buildProxyGroups(finalConfig, cfg.ProxyGroups, proxies)
if rateErrs := buildRateFilterGroups(finalConfig, cfg.RateFilters, proxies); len(rateErrs) > 0 {
errs = append(errs, rateErrs...)
}
errs = append(errs, buildProxyGroups(finalConfig, cfg.ProxyGroups, proxies)...)
errs = append(errs, applyFilters(finalConfig, cfg.Filters, proxies)...)
for _, patch := range cfg.Patches {
if err := applyPatch(finalConfig, patch); err != nil {