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
|
```json
|
||||||
{
|
{
|
||||||
"name": "",
|
"name": "",
|
||||||
|
"extend": "",
|
||||||
|
|
||||||
// Global
|
// Global
|
||||||
|
|
||||||
@ -83,6 +84,10 @@
|
|||||||
|
|
||||||
Profile name.
|
Profile name.
|
||||||
|
|
||||||
|
#### extend
|
||||||
|
|
||||||
|
Extend from another profile.
|
||||||
|
|
||||||
#### log
|
#### log
|
||||||
|
|
||||||
Log configuration, see [Log](https://sing-box.sagernet.org/configuration/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
|
#### 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.
|
Default rule sets will not be generated if not empty.
|
||||||
|
|
||||||
#### post_rule_set
|
#### 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.
|
Will be applied after default rule sets.
|
||||||
|
|
||||||
|
@ -50,6 +50,8 @@ nav:
|
|||||||
- Template: configuration/template.md
|
- Template: configuration/template.md
|
||||||
- Profile: configuration/profile.md
|
- Profile: configuration/profile.md
|
||||||
- User: configuration/user.md
|
- User: configuration/user.md
|
||||||
|
- Shared:
|
||||||
|
- RuleSet: configuration/shared/rule-set.md
|
||||||
markdown_extensions:
|
markdown_extensions:
|
||||||
- pymdownx.inlinehilite
|
- pymdownx.inlinehilite
|
||||||
- pymdownx.snippets
|
- pymdownx.snippets
|
||||||
|
@ -113,12 +113,10 @@ func (r *RuleSet) UnmarshalJSON(bytes []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GitHubRuleSetOptions struct {
|
type GitHubRuleSetOptions struct {
|
||||||
Owner string `json:"owner,omitempty"`
|
Repository string `json:"repository,omitempty"`
|
||||||
Repo string `json:"repo,omitempty"`
|
Path string `json:"path,omitempty"`
|
||||||
Branch string `json:"branch,omitempty"`
|
Prefix string `json:"prefix,omitempty"`
|
||||||
Path string `json:"path,omitempty"`
|
RuleSet option.Listable[string] `json:"rule_set,omitempty"`
|
||||||
Prefix string `json:"prefix,omitempty"`
|
|
||||||
RuleSet option.Listable[string] `json:"rule_set,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t Template) DisableIPv6() bool {
|
func (t Template) DisableIPv6() bool {
|
||||||
|
@ -117,6 +117,7 @@ func (t *Template) renderRuleSet(ruleSets []option.RuleSet) []boxOption.RuleSet
|
|||||||
downloadURL = "https://raw.githubusercontent.com/"
|
downloadURL = "https://raw.githubusercontent.com/"
|
||||||
branchSplit = "/"
|
branchSplit = "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, code := range ruleSet.GitHubOptions.RuleSet {
|
for _, code := range ruleSet.GitHubOptions.RuleSet {
|
||||||
result = append(result, boxOption.RuleSet{
|
result = append(result, boxOption.RuleSet{
|
||||||
Type: C.RuleSetTypeRemote,
|
Type: C.RuleSetTypeRemote,
|
||||||
@ -124,10 +125,8 @@ func (t *Template) renderRuleSet(ruleSets []option.RuleSet) []boxOption.RuleSet
|
|||||||
Format: C.RuleSetFormatBinary,
|
Format: C.RuleSetFormatBinary,
|
||||||
RemoteOptions: boxOption.RemoteRuleSet{
|
RemoteOptions: boxOption.RemoteRuleSet{
|
||||||
URL: downloadURL +
|
URL: downloadURL +
|
||||||
ruleSet.GitHubOptions.Owner + "/" +
|
ruleSet.GitHubOptions.Repository +
|
||||||
ruleSet.GitHubOptions.Repo +
|
|
||||||
branchSplit +
|
branchSplit +
|
||||||
ruleSet.GitHubOptions.Branch + "/" +
|
|
||||||
ruleSet.GitHubOptions.Path +
|
ruleSet.GitHubOptions.Path +
|
||||||
code + ".srs",
|
code + ".srs",
|
||||||
DownloadDetour: downloadDetour,
|
DownloadDetour: downloadDetour,
|
||||||
|
Loading…
Reference in New Issue
Block a user