forked from mirror/serenity
Add template.post_custom_rule_set
This commit is contained in:
parent
ef68e70c06
commit
45d6d8e99b
@ -55,6 +55,7 @@
|
|||||||
"custom_geoip": {},
|
"custom_geoip": {},
|
||||||
"custom_geosite": {},
|
"custom_geosite": {},
|
||||||
"custom_rule_set": [],
|
"custom_rule_set": [],
|
||||||
|
"post_custom_rule_set": [],
|
||||||
|
|
||||||
// Experimental
|
// 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.
|
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
|
#### disable_cache_file
|
||||||
|
|
||||||
Don't generate `cache_file` related options.
|
Don't generate `cache_file` related options.
|
||||||
|
@ -50,6 +50,7 @@ type Template struct {
|
|||||||
CustomGeoIP *option.GeoIPOptions `json:"custom_geoip,omitempty"`
|
CustomGeoIP *option.GeoIPOptions `json:"custom_geoip,omitempty"`
|
||||||
CustomGeosite *option.GeositeOptions `json:"custom_geosite,omitempty"`
|
CustomGeosite *option.GeositeOptions `json:"custom_geosite,omitempty"`
|
||||||
CustomRuleSet []option.RuleSet `json:"custom_rule_set,omitempty"`
|
CustomRuleSet []option.RuleSet `json:"custom_rule_set,omitempty"`
|
||||||
|
PostCustomRuleSet []option.RuleSet `json:"post_custom_rule_set,omitempty"`
|
||||||
|
|
||||||
// Experimental
|
// Experimental
|
||||||
DisableCacheFile bool `json:"disable_cache_file,omitempty"`
|
DisableCacheFile bool `json:"disable_cache_file,omitempty"`
|
||||||
|
@ -38,52 +38,55 @@ func (t *Template) renderGeoResources(metadata M.Metadata, options *option.Optio
|
|||||||
DownloadDetour: downloadDetour,
|
DownloadDetour: downloadDetour,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if len(t.CustomRuleSet) == 0 {
|
} else {
|
||||||
var (
|
if len(t.CustomRuleSet) == 0 {
|
||||||
downloadURL string
|
var (
|
||||||
downloadDetour string
|
downloadURL string
|
||||||
branchSplit string
|
downloadDetour string
|
||||||
)
|
branchSplit string
|
||||||
if t.EnableJSDelivr {
|
)
|
||||||
downloadURL = "https://testingcf.jsdelivr.net/gh/"
|
if t.EnableJSDelivr {
|
||||||
if t.DirectTag != "" {
|
downloadURL = "https://testingcf.jsdelivr.net/gh/"
|
||||||
downloadDetour = t.DirectTag
|
if t.DirectTag != "" {
|
||||||
|
downloadDetour = t.DirectTag
|
||||||
|
} else {
|
||||||
|
downloadDetour = DefaultDirectTag
|
||||||
|
}
|
||||||
|
branchSplit = "@"
|
||||||
} else {
|
} else {
|
||||||
downloadDetour = DefaultDirectTag
|
downloadURL = "https://raw.githubusercontent.com/"
|
||||||
|
branchSplit = "/"
|
||||||
|
}
|
||||||
|
options.Route.RuleSet = []option.RuleSet{
|
||||||
|
{
|
||||||
|
Type: C.RuleSetTypeRemote,
|
||||||
|
Tag: "geoip-cn",
|
||||||
|
Format: C.RuleSetFormatBinary,
|
||||||
|
RemoteOptions: option.RemoteRuleSet{
|
||||||
|
URL: downloadURL + "SagerNet/sing-geoip" + branchSplit + "rule-set/geoip-cn.srs",
|
||||||
|
DownloadDetour: downloadDetour,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Type: C.RuleSetTypeRemote,
|
||||||
|
Tag: "geosite-geolocation-cn",
|
||||||
|
Format: C.RuleSetFormatBinary,
|
||||||
|
RemoteOptions: option.RemoteRuleSet{
|
||||||
|
URL: downloadURL + "SagerNet/sing-geosite" + branchSplit + "rule-set/geosite-geolocation-cn.srs",
|
||||||
|
DownloadDetour: downloadDetour,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Type: C.RuleSetTypeRemote,
|
||||||
|
Tag: "geosite-geolocation-!cn",
|
||||||
|
Format: C.RuleSetFormatBinary,
|
||||||
|
RemoteOptions: option.RemoteRuleSet{
|
||||||
|
URL: downloadURL + "SagerNet/sing-geosite" + branchSplit + "rule-set/geosite-geolocation-!cn.srs",
|
||||||
|
DownloadDetour: downloadDetour,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
branchSplit = "@"
|
|
||||||
} else {
|
|
||||||
downloadURL = "https://raw.githubusercontent.com/"
|
|
||||||
branchSplit = "/"
|
|
||||||
}
|
|
||||||
options.Route.RuleSet = []option.RuleSet{
|
|
||||||
{
|
|
||||||
Type: C.RuleSetTypeRemote,
|
|
||||||
Tag: "geoip-cn",
|
|
||||||
Format: C.RuleSetFormatBinary,
|
|
||||||
RemoteOptions: option.RemoteRuleSet{
|
|
||||||
URL: downloadURL + "SagerNet/sing-geoip" + branchSplit + "rule-set/geoip-cn.srs",
|
|
||||||
DownloadDetour: downloadDetour,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Type: C.RuleSetTypeRemote,
|
|
||||||
Tag: "geosite-geolocation-cn",
|
|
||||||
Format: C.RuleSetFormatBinary,
|
|
||||||
RemoteOptions: option.RemoteRuleSet{
|
|
||||||
URL: downloadURL + "SagerNet/sing-geosite" + branchSplit + "rule-set/geosite-geolocation-cn.srs",
|
|
||||||
DownloadDetour: downloadDetour,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Type: C.RuleSetTypeRemote,
|
|
||||||
Tag: "geosite-geolocation-!cn",
|
|
||||||
Format: C.RuleSetFormatBinary,
|
|
||||||
RemoteOptions: option.RemoteRuleSet{
|
|
||||||
URL: downloadURL + "SagerNet/sing-geosite" + branchSplit + "rule-set/geosite-geolocation-!cn.srs",
|
|
||||||
DownloadDetour: downloadDetour,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
options.Route.RuleSet = append(options.Route.RuleSet, t.PostCustomRuleSet...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user