Unique rule-set names

This commit is contained in:
世界 2024-06-26 00:45:10 +08:00
parent b1e5788e9f
commit 03c0e6367a
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
15 changed files with 57 additions and 57 deletions

View file

@ -6,7 +6,7 @@ import (
var commandRuleSet = &cobra.Command{
Use: "rule-set",
Short: "Manage rule sets",
Short: "Manage rule-sets",
}
func init() {

View file

@ -23,7 +23,7 @@ var flagRuleSetMatchFormat string
var commandRuleSetMatch = &cobra.Command{
Use: "match <rule-set path> <IP address/domain>",
Short: "Check if an IP address or a domain matches the rule set",
Short: "Check if an IP address or a domain matches the rule-set",
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
err := ruleSetMatch(args[0], args[1])
@ -70,7 +70,7 @@ func ruleSetMatch(sourcePath string, domain string) error {
return err
}
default:
return E.New("unknown rule set format: ", flagRuleSetMatchFormat)
return E.New("unknown rule-set format: ", flagRuleSetMatchFormat)
}
ipAddress := M.ParseAddr(domain)
var metadata adapter.InboundContext

View file

@ -46,7 +46,7 @@ func Read(reader io.Reader, recover bool) (ruleSet option.PlainRuleSet, err erro
return
}
if magicBytes != MagicBytes {
err = E.New("invalid sing-box rule set file")
err = E.New("invalid sing-box rule-set file")
return
}
var version uint8

View file

@ -318,7 +318,7 @@ See [Address Filter Fields](/configuration/dns/rule#address-filter-fields).
Important changes since 1.7:
* Migrate cache file from Clash API to independent options **1**
* Introducing [Rule Set](/configuration/rule-set/) **2**
* Introducing [rule-set](/configuration/rule-set/) **2**
* Add `sing-box geoip`, `sing-box geosite` and `sing-box rule-set` commands **3**
* Allow nested logical rules **4**
* Independent `source_ip_is_private` and `ip_is_private` rules **5**
@ -338,7 +338,7 @@ See [Cache File](/configuration/experimental/cache-file/) and
**2**:
Rule set is independent collections of rules that can be compiled into binaries to improve performance.
rule-set is independent collections of rules that can be compiled into binaries to improve performance.
Compared to legacy GeoIP and Geosite resources,
it can include more types of rules, load faster,
use less memory, and update automatically.
@ -346,16 +346,16 @@ use less memory, and update automatically.
See [Route#rule_set](/configuration/route/#rule_set),
[Route Rule](/configuration/route/rule/),
[DNS Rule](/configuration/dns/rule/),
[Rule Set](/configuration/rule-set/),
[rule-set](/configuration/rule-set/),
[Source Format](/configuration/rule-set/source-format/) and
[Headless Rule](/configuration/rule-set/headless-rule/).
For GEO resources migration, see [Migrate GeoIP to rule sets](/migration/#migrate-geoip-to-rule-sets) and
[Migrate Geosite to rule sets](/migration/#migrate-geosite-to-rule-sets).
For GEO resources migration, see [Migrate GeoIP to rule-sets](/migration/#migrate-geoip-to-rule-sets) and
[Migrate Geosite to rule-sets](/migration/#migrate-geosite-to-rule-sets).
**3**:
New commands manage GeoIP, Geosite and rule set resources, and help you migrate GEO resources to rule sets.
New commands manage GeoIP, Geosite and rule-set resources, and help you migrate GEO resources to rule-sets.
**4**:
@ -552,7 +552,7 @@ This change is intended to break incorrect usage and essentially requires no act
**1**:
Now the rules in the `rule_set` rule item can be logically considered to be merged into the rule using rule sets,
Now the rules in the `rule_set` rule item can be logically considered to be merged into the rule using rule-sets,
rather than completely following the AND logic.
#### 1.8.0-alpha.5
@ -568,7 +568,7 @@ Since GeoIP was deprecated, we made this rule independent, see [Migration](/migr
#### 1.8.0-alpha.1
* Migrate cache file from Clash API to independent options **1**
* Introducing [Rule Set](/configuration/rule-set/) **2**
* Introducing [rule-set](/configuration/rule-set/) **2**
* Add `sing-box geoip`, `sing-box geosite` and `sing-box rule-set` commands **3**
* Allow nested logical rules **4**
@ -579,7 +579,7 @@ See [Cache File](/configuration/experimental/cache-file/) and
**2**:
Rule set is independent collections of rules that can be compiled into binaries to improve performance.
rule-set is independent collections of rules that can be compiled into binaries to improve performance.
Compared to legacy GeoIP and Geosite resources,
it can include more types of rules, load faster,
use less memory, and update automatically.
@ -587,16 +587,16 @@ use less memory, and update automatically.
See [Route#rule_set](/configuration/route/#rule_set),
[Route Rule](/configuration/route/rule/),
[DNS Rule](/configuration/dns/rule/),
[Rule Set](/configuration/rule-set/),
[rule-set](/configuration/rule-set/),
[Source Format](/configuration/rule-set/source-format/) and
[Headless Rule](/configuration/rule-set/headless-rule/).
For GEO resources migration, see [Migrate GeoIP to rule sets](/migration/#migrate-geoip-to-rule-sets) and
[Migrate Geosite to rule sets](/migration/#migrate-geosite-to-rule-sets).
For GEO resources migration, see [Migrate GeoIP to rule-sets](/migration/#migrate-geoip-to-rule-sets) and
[Migrate Geosite to rule-sets](/migration/#migrate-geosite-to-rule-sets).
**3**:
New commands manage GeoIP, Geosite and rule set resources, and help you migrate GEO resources to rule sets.
New commands manage GeoIP, Geosite and rule-set resources, and help you migrate GEO resources to rule-sets.
**4**:

View file

@ -166,7 +166,7 @@ icon: material/new-box
(`source_port` || `source_port_range`) &&
`other fields`
Additionally, included rule sets can be considered merged rather than as a single rule sub-item.
Additionally, included rule-sets can be considered merged rather than as a single rule sub-item.
#### inbound
@ -312,7 +312,7 @@ Match WiFi BSSID.
!!! question "Since sing-box 1.8.0"
Match [Rule Set](/configuration/route/#rule_set).
Match [rule-set](/configuration/route/#rule_set).
#### rule_set_ipcidr_match_source
@ -322,13 +322,13 @@ Match [Rule Set](/configuration/route/#rule_set).
`rule_set_ipcidr_match_source` is renamed to `rule_set_ip_cidr_match_source` and will be remove in sing-box 1.11.0.
Make `ip_cidr` rule items in rule sets match the source IP.
Make `ip_cidr` rule items in rule-sets match the source IP.
#### rule_set_ip_cidr_match_source
!!! question "Since sing-box 1.10.0"
Make `ip_cidr` rule items in rule sets match the source IP.
Make `ip_cidr` rule items in rule-sets match the source IP.
#### invert
@ -370,7 +370,7 @@ Only takes effect for address requests (A/AAAA/HTTPS). When the query results do
!!! info ""
`ip_cidr` items in included rule sets also takes effect as an address filtering field.
`ip_cidr` items in included rule-sets also takes effect as an address filtering field.
!!! note ""
@ -398,7 +398,7 @@ Match private IP with query response.
!!! question "Since sing-box 1.10.0"
Make `ip_cidr` rules in rule sets accept empty query response.
Make `ip_cidr` rules in rule-sets accept empty query response.
### Logical Fields

View file

@ -39,7 +39,7 @@ List of [Route Rule](./rule/)
!!! question "Since sing-box 1.8.0"
List of [Rule Set](/configuration/rule-set/)
List of [rule-set](/configuration/rule-set/)
#### final

View file

@ -148,7 +148,7 @@ icon: material/alert-decagram
(`source_port` || `source_port_range`) &&
`other fields`
Additionally, included rule sets can be considered merged rather than as a single rule sub-item.
Additionally, included rule-sets can be considered merged rather than as a single rule sub-item.
#### inbound
@ -308,7 +308,7 @@ Match WiFi BSSID.
!!! question "Since sing-box 1.8.0"
Match [Rule Set](/configuration/route/#rule_set).
Match [rule-set](/configuration/route/#rule_set).
#### rule_set_ipcidr_match_source
@ -318,13 +318,13 @@ Match [Rule Set](/configuration/route/#rule_set).
`rule_set_ipcidr_match_source` is renamed to `rule_set_ip_cidr_match_source` and will be remove in sing-box 1.11.0.
Make `ip_cidr` in rule sets match the source IP.
Make `ip_cidr` in rule-sets match the source IP.
#### rule_set_ip_cidr_match_source
!!! question "Since sing-box 1.10.0"
Make `ip_cidr` in rule sets match the source IP.
Make `ip_cidr` in rule-sets match the source IP.
#### invert

View file

@ -1,4 +1,4 @@
# Rule Set
# rule-set
!!! question "Since sing-box 1.8.0"
@ -50,19 +50,19 @@
==Required==
Type of Rule Set, `local` or `remote`.
Type of rule-set, `local` or `remote`.
#### tag
==Required==
Tag of Rule Set.
Tag of rule-set.
#### format
==Required==
Format of Rule Set, `source` or `binary`.
Format of rule-set, `source` or `binary`.
### Local Fields
@ -70,7 +70,7 @@ Format of Rule Set, `source` or `binary`.
==Required==
File path of Rule Set.
File path of rule-set.
### Remote Fields
@ -78,7 +78,7 @@ File path of Rule Set.
==Required==
Download URL of Rule Set.
Download URL of rule-set.
#### download_detour
@ -88,6 +88,6 @@ Default outbound will be used if empty.
#### update_interval
Update interval of Rule Set.
Update interval of rule-set.
`1d` will be used if empty.

View file

@ -33,7 +33,7 @@ The maxmind GeoIP National Database, as an IP classification database,
is not entirely suitable for traffic bypassing,
and all existing implementations suffer from high memory usage and difficult management.
sing-box 1.8.0 introduces [Rule Set](/configuration/rule-set/), which can completely replace GeoIP,
sing-box 1.8.0 introduces [rule-set](/configuration/rule-set/), which can completely replace GeoIP,
check [Migration](/migration/#migrate-geoip-to-rule-sets).
#### Geosite
@ -43,7 +43,7 @@ Geosite is deprecated and may be removed in the future.
Geosite, the `domain-list-community` project maintained by V2Ray as an early traffic bypassing solution,
suffers from a number of problems, including lack of maintenance, inaccurate rules, and difficult management.
sing-box 1.8.0 introduces [Rule Set](/configuration/rule-set/), which can completely replace Geosite,
sing-box 1.8.0 introduces [rule-set](/configuration/rule-set/), which can completely replace Geosite,
check [Migration](/migration/#migrate-geosite-to-rule-sets).
## 1.6.0

View file

@ -128,7 +128,7 @@ which will disrupt the existing `process_path` use cases in Windows.
}
```
### :material-checkbox-intermediate: Migrate GeoIP to rule sets
### :material-checkbox-intermediate: Migrate GeoIP to rule-sets
!!! info "References"
@ -136,11 +136,11 @@ which will disrupt the existing `process_path` use cases in Windows.
[Route](/configuration/route/) /
[Route Rule](/configuration/route/rule/) /
[DNS Rule](/configuration/dns/rule/) /
[Rule Set](/configuration/rule-set/)
[rule-set](/configuration/rule-set/)
!!! tip
`sing-box geoip` commands can help you convert custom GeoIP into rule sets.
`sing-box geoip` commands can help you convert custom GeoIP into rule-sets.
=== ":material-card-remove: Deprecated"
@ -207,13 +207,13 @@ which will disrupt the existing `process_path` use cases in Windows.
},
"experimental": {
"cache_file": {
"enabled": true // required to save Rule Set cache
"enabled": true // required to save rule-set cache
}
}
}
```
### :material-checkbox-intermediate: Migrate Geosite to rule sets
### :material-checkbox-intermediate: Migrate Geosite to rule-sets
!!! info "References"
@ -221,11 +221,11 @@ which will disrupt the existing `process_path` use cases in Windows.
[Route](/configuration/route/) /
[Route Rule](/configuration/route/rule/) /
[DNS Rule](/configuration/dns/rule/) /
[Rule Set](/configuration/rule-set/)
[rule-set](/configuration/rule-set/)
!!! tip
`sing-box geosite` commands can help you convert custom Geosite into rule sets.
`sing-box geosite` commands can help you convert custom Geosite into rule-sets.
=== ":material-card-remove: Deprecated"
@ -268,7 +268,7 @@ which will disrupt the existing `process_path` use cases in Windows.
},
"experimental": {
"cache_file": {
"enabled": true // required to save Rule Set cache
"enabled": true // required to save rule-set cache
}
}
}

View file

@ -206,7 +206,7 @@ sing-box 1.9.0 使 QueryFullProcessImageNameW 输出 Win32 路径(如 `C:\fold
},
"experimental": {
"cache_file": {
"enabled": true // required to save Rule Set cache
"enabled": true // required to save rule-set cache
}
}
}
@ -267,7 +267,7 @@ sing-box 1.9.0 使 QueryFullProcessImageNameW 输出 Win32 路径(如 `C:\fold
},
"experimental": {
"cache_file": {
"enabled": true // required to save Rule Set cache
"enabled": true // required to save rule-set cache
}
}
}

View file

@ -31,7 +31,7 @@ func (r RuleSet) MarshalJSON() ([]byte, error) {
case C.RuleSetTypeRemote:
v = r.RemoteOptions
default:
return nil, E.New("unknown rule set type: " + r.Type)
return nil, E.New("unknown rule-set type: " + r.Type)
}
return MarshallObjects((_RuleSet)(r), v)
}
@ -49,7 +49,7 @@ func (r *RuleSet) UnmarshalJSON(bytes []byte) error {
return E.New("missing format")
case C.RuleSetFormatSource, C.RuleSetFormatBinary:
default:
return E.New("unknown rule set format: " + r.Format)
return E.New("unknown rule-set format: " + r.Format)
}
var v any
switch r.Type {
@ -60,7 +60,7 @@ func (r *RuleSet) UnmarshalJSON(bytes []byte) error {
case "":
return E.New("missing type")
default:
return E.New("unknown rule set type: " + r.Type)
return E.New("unknown rule-set type: " + r.Type)
}
err = UnmarshallExcluded(bytes, (*_RuleSet)(r), v)
if err != nil {
@ -188,7 +188,7 @@ func (r PlainRuleSetCompat) MarshalJSON() ([]byte, error) {
case C.RuleSetVersion1, C.RuleSetVersion2:
v = r.Options
default:
return nil, E.New("unknown rule set version: ", r.Version)
return nil, E.New("unknown rule-set version: ", r.Version)
}
return MarshallObjects((_PlainRuleSetCompat)(r), v)
}
@ -203,9 +203,9 @@ func (r *PlainRuleSetCompat) UnmarshalJSON(bytes []byte) error {
case C.RuleSetVersion1, C.RuleSetVersion2:
v = &r.Options
case 0:
return E.New("missing rule set version")
return E.New("missing rule-set version")
default:
return E.New("unknown rule set version: ", r.Version)
return E.New("unknown rule-set version: ", r.Version)
}
err = UnmarshallExcluded(bytes, (*_PlainRuleSetCompat)(r), v)
if err != nil {
@ -220,7 +220,7 @@ func (r PlainRuleSetCompat) Upgrade() PlainRuleSet {
case C.RuleSetVersion1, C.RuleSetVersion2:
result = r.Options
default:
panic("unknown rule set version: " + F.ToString(r.Version))
panic("unknown rule-set version: " + F.ToString(r.Version))
}
return result
}

View file

@ -25,7 +25,7 @@ func NewRuleSet(ctx context.Context, router adapter.Router, logger logger.Contex
case C.RuleSetTypeRemote:
return NewRemoteRuleSet(ctx, router, logger, options), nil
default:
return nil, E.New("unknown rule set type: ", options.Type)
return nil, E.New("unknown rule-set type: ", options.Type)
}
}

View file

@ -51,7 +51,7 @@ func NewLocalRuleSet(router adapter.Router, options option.RuleSet) (*LocalRuleS
return nil, err
}
default:
return nil, E.New("unknown rule set format: ", options.Format)
return nil, E.New("unknown rule-set format: ", options.Format)
}
rules := make([]adapter.HeadlessRule, len(plainRuleSet.Rules))
var err error

View file

@ -175,7 +175,7 @@ func (s *RemoteRuleSet) loadBytes(content []byte) error {
return err
}
default:
return E.New("unknown rule set format: ", s.options.Format)
return E.New("unknown rule-set format: ", s.options.Format)
}
rules := make([]adapter.HeadlessRule, len(plainRuleSet.Rules))
for i, ruleOptions := range plainRuleSet.Rules {