forked from mirror/serenity
documentation: Add new rule-set
This commit is contained in:
parent
1396bde701
commit
1ad506c382
80
docs/configuration/shared/rule-set.md
Normal file
80
docs/configuration/shared/rule-set.md
Normal file
@ -0,0 +1,80 @@
|
||||
# RuleSet
|
||||
|
||||
RuleSet generate configuration.
|
||||
|
||||
### Structure
|
||||
|
||||
=== "Default"
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "", // optional
|
||||
|
||||
... // Default Fields
|
||||
}
|
||||
```
|
||||
|
||||
=== "GitHub"
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "github",
|
||||
"repository": "",
|
||||
"path": "",
|
||||
"rule-set": []
|
||||
}
|
||||
```
|
||||
|
||||
=== "Example"
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "github",
|
||||
"repository": "SagerNet/sing-geosite",
|
||||
"path": "rule-set",
|
||||
"prefix": "geosite-",
|
||||
"rule-set": [
|
||||
"apple",
|
||||
"microsoft",
|
||||
"openai"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
=== "Example (Clash.Meta repository)"
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "github",
|
||||
"repository": "MetaCubeX/meta-rules-dat",
|
||||
"path": "sing/geo/geosite",
|
||||
"prefix": "geosite-",
|
||||
"rule-set": [
|
||||
"apple",
|
||||
"microsoft",
|
||||
"openai"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Default Fields
|
||||
|
||||
See [RuleSet](https://sing-box.sagernet.org/configuration/rule-set/).
|
||||
|
||||
### GitHub Fields
|
||||
|
||||
#### repository
|
||||
|
||||
GitHub repository, `SagerNet/sing-<geoip/geosite>` or `MetaCubeX/meta-rules-dat`.
|
||||
|
||||
#### path
|
||||
|
||||
Branch and directory path, `rule-set` or `sing/geo/<geoip/geosite>`.
|
||||
|
||||
#### prefix
|
||||
|
||||
File prefix, `geoip-` or `geosite-`.
|
||||
|
||||
#### rule-set
|
||||
|
||||
RuleSet name list.
|
@ -3,6 +3,7 @@
|
||||
```json
|
||||
{
|
||||
"name": "",
|
||||
"extend": "",
|
||||
|
||||
// Global
|
||||
|
||||
@ -83,6 +84,10 @@
|
||||
|
||||
Profile name.
|
||||
|
||||
#### extend
|
||||
|
||||
Extend from another profile.
|
||||
|
||||
#### log
|
||||
|
||||
Log configuration, see [Log](https://sing-box.sagernet.org/configuration/log/).
|
||||
@ -249,13 +254,13 @@ Custom [GeoSite](https://sing-box.sagernet.org/configuration/route/geosite/) tem
|
||||
|
||||
#### custom_rule_set
|
||||
|
||||
List of [RuleSet](https://sing-box.sagernet.org/configuration/rule-set/).
|
||||
List of [RuleSet](/configuration/shared/rule-set/).
|
||||
|
||||
Default rule sets will not be generated if not empty.
|
||||
|
||||
#### post_rule_set
|
||||
|
||||
List of [RuleSet](https://sing-box.sagernet.org/configuration/rule-set/).
|
||||
List of [RuleSet](/configuration/shared/rule-set/).
|
||||
|
||||
Will be applied after default rule sets.
|
||||
|
||||
|
@ -50,6 +50,8 @@ nav:
|
||||
- Template: configuration/template.md
|
||||
- Profile: configuration/profile.md
|
||||
- User: configuration/user.md
|
||||
- Shared:
|
||||
- RuleSet: configuration/shared/rule-set.md
|
||||
markdown_extensions:
|
||||
- pymdownx.inlinehilite
|
||||
- pymdownx.snippets
|
||||
|
@ -113,9 +113,7 @@ func (r *RuleSet) UnmarshalJSON(bytes []byte) error {
|
||||
}
|
||||
|
||||
type GitHubRuleSetOptions struct {
|
||||
Owner string `json:"owner,omitempty"`
|
||||
Repo string `json:"repo,omitempty"`
|
||||
Branch string `json:"branch,omitempty"`
|
||||
Repository string `json:"repository,omitempty"`
|
||||
Path string `json:"path,omitempty"`
|
||||
Prefix string `json:"prefix,omitempty"`
|
||||
RuleSet option.Listable[string] `json:"rule_set,omitempty"`
|
||||
|
@ -117,6 +117,7 @@ func (t *Template) renderRuleSet(ruleSets []option.RuleSet) []boxOption.RuleSet
|
||||
downloadURL = "https://raw.githubusercontent.com/"
|
||||
branchSplit = "/"
|
||||
}
|
||||
|
||||
for _, code := range ruleSet.GitHubOptions.RuleSet {
|
||||
result = append(result, boxOption.RuleSet{
|
||||
Type: C.RuleSetTypeRemote,
|
||||
@ -124,10 +125,8 @@ func (t *Template) renderRuleSet(ruleSets []option.RuleSet) []boxOption.RuleSet
|
||||
Format: C.RuleSetFormatBinary,
|
||||
RemoteOptions: boxOption.RemoteRuleSet{
|
||||
URL: downloadURL +
|
||||
ruleSet.GitHubOptions.Owner + "/" +
|
||||
ruleSet.GitHubOptions.Repo +
|
||||
ruleSet.GitHubOptions.Repository +
|
||||
branchSplit +
|
||||
ruleSet.GitHubOptions.Branch + "/" +
|
||||
ruleSet.GitHubOptions.Path +
|
||||
code + ".srs",
|
||||
DownloadDetour: downloadDetour,
|
||||
|
Loading…
Reference in New Issue
Block a user