Add template.post_custom_rule_set

This commit is contained in:
世界 2024-05-04 22:59:14 +08:00
parent ef68e70c06
commit 45d6d8e99b
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
3 changed files with 55 additions and 44 deletions

View File

@ -55,6 +55,7 @@
"custom_geoip": {},
"custom_geosite": {},
"custom_rule_set": [],
"post_custom_rule_set": [],
// Experimental
@ -242,6 +243,12 @@ List of [RuleSet](https://sing-box.sagernet.org/configuration/rule-set/).
Default rule sets will not be generated if not empty.
#### post_custom_rule_set
List of [RuleSet](https://sing-box.sagernet.org/configuration/rule-set/).
Will be applied after default rule sets.
#### disable_cache_file
Don't generate `cache_file` related options.

View File

@ -50,6 +50,7 @@ type Template struct {
CustomGeoIP *option.GeoIPOptions `json:"custom_geoip,omitempty"`
CustomGeosite *option.GeositeOptions `json:"custom_geosite,omitempty"`
CustomRuleSet []option.RuleSet `json:"custom_rule_set,omitempty"`
PostCustomRuleSet []option.RuleSet `json:"post_custom_rule_set,omitempty"`
// Experimental
DisableCacheFile bool `json:"disable_cache_file,omitempty"`

View File

@ -38,7 +38,8 @@ func (t *Template) renderGeoResources(metadata M.Metadata, options *option.Optio
DownloadDetour: downloadDetour,
}
}
} else if len(t.CustomRuleSet) == 0 {
} else {
if len(t.CustomRuleSet) == 0 {
var (
downloadURL string
downloadDetour string
@ -86,4 +87,6 @@ func (t *Template) renderGeoResources(metadata M.Metadata, options *option.Optio
},
}
}
options.Route.RuleSet = append(options.Route.RuleSet, t.PostCustomRuleSet...)
}
}