documentation: Add new rule-set

This commit is contained in:
世界 2024-05-15 21:47:52 +08:00
parent 1396bde701
commit 1ad506c382
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
5 changed files with 95 additions and 11 deletions

View 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.

View File

@ -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.

View File

@ -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

View File

@ -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"`

View File

@ -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,