mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
chore: better converter
Some checks are pending
Trigger CMFA Update / trigger-CMFA-update (push) Waiting to run
Some checks are pending
Trigger CMFA Update / trigger-CMFA-update (push) Waiting to run
This commit is contained in:
parent
4f8a5a5f54
commit
1db3e4583b
|
@ -942,7 +942,12 @@ rule-providers:
|
|||
interval: 259200
|
||||
path: /path/to/save/file.yaml
|
||||
type: file
|
||||
rule3: # mrs类型ruleset,目前仅支持domain和ipcidr,可以通过“mihomo convert-ruleset domain yaml XXX.yaml XXX.mrs”转换得到
|
||||
rule3:
|
||||
# mrs类型ruleset,目前仅支持domain和ipcidr(即不支持classical),
|
||||
# behavior=domain,format=yaml 可以通过“mihomo convert-ruleset domain yaml XXX.yaml XXX.mrs”转换得到
|
||||
# behavior=domain,format=text 可以通过“mihomo convert-ruleset domain text XXX.text XXX.mrs”转换得到
|
||||
# behavior=ipcidr,format=yaml 可以通过“mihomo convert-ruleset ipcidr yaml XXX.yaml XXX.mrs”转换得到
|
||||
# behavior=ipcidr,format=text 可以通过“mihomo convert-ruleset ipcidr text XXX.text XXX.mrs”转换得到
|
||||
type: http
|
||||
url: "url"
|
||||
format: mrs
|
||||
|
|
|
@ -3,6 +3,7 @@ package provider
|
|||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/metacubex/mihomo/component/trie"
|
||||
C "github.com/metacubex/mihomo/constant"
|
||||
|
@ -43,6 +44,10 @@ func (d *domainStrategy) Reset() {
|
|||
}
|
||||
|
||||
func (d *domainStrategy) Insert(rule string) {
|
||||
if strings.ContainsRune(rule, '/') {
|
||||
log.Warnln("invalid domain:[%s]", rule)
|
||||
return
|
||||
}
|
||||
err := d.domainTrie.Insert(rule, struct{}{})
|
||||
if err != nil {
|
||||
log.Warnln("invalid domain:[%s]", rule)
|
||||
|
|
|
@ -2,6 +2,7 @@ package provider
|
|||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
|
@ -16,6 +17,9 @@ func ConvertToMrs(buf []byte, behavior P.RuleBehavior, format P.RuleFormat, w io
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if strategy.Count() == 0 {
|
||||
return errors.New("empty rule")
|
||||
}
|
||||
if _strategy, ok := strategy.(mrsRuleStrategy); ok {
|
||||
var encoder *zstd.Encoder
|
||||
encoder, err = zstd.NewWriter(w)
|
||||
|
|
Loading…
Reference in New Issue
Block a user