From 298740f33e590beb184f439102b66c41378a6609 Mon Sep 17 00:00:00 2001 From: juanxincaigou Date: Tue, 1 Jul 2025 16:32:42 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=99=BD=E5=90=8D?= =?UTF-8?q?=E5=8D=95filterlist=E7=9A=84=E5=90=8E=E7=BC=80=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=90=AF=E5=8A=A8=E5=8F=82?= =?UTF-8?q?=E6=95=B0--blocklist=E5=B9=B6=E6=94=AF=E6=8C=81=E7=B2=BE?= =?UTF-8?q?=E7=A1=AE=E3=80=81=E5=89=8D=E5=90=8E=E7=BC=80=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/full_check/checker/base.go | 11 +-- src/full_check/common/common.go | 11 ++- src/full_check/common/trieTree.go | 113 +++++++++++++++++++++---- src/full_check/common/trieTree_test.go | 106 ++++++++++++++++++----- src/full_check/configure/conf.go | 2 +- src/full_check/full_check/scan.go | 11 ++- src/full_check/main.go | 22 ++++- 7 files changed, 223 insertions(+), 53 deletions(-) diff --git a/src/full_check/checker/base.go b/src/full_check/checker/base.go index 4c99b81..7bbd572 100644 --- a/src/full_check/checker/base.go +++ b/src/full_check/checker/base.go @@ -1,10 +1,10 @@ package checker import ( + "full_check/client" "full_check/common" - "sync" "full_check/metric" - "full_check/client" + "sync" ) type FullCheckParameter struct { @@ -16,11 +16,12 @@ type FullCheckParameter struct { BatchCount int Parallel int FilterTree *common.Trie + BlockTree *common.Trie } type VerifierBase struct { - Stat *metric.Stat - Param *FullCheckParameter + Stat *metric.Stat + Param *FullCheckParameter } func (p *VerifierBase) IncrKeyStat(oneKeyInfo *common.Key) { @@ -102,4 +103,4 @@ type IVerifier interface { type ValueOutlineVerifier struct { VerifierBase -} \ No newline at end of file +} diff --git a/src/full_check/common/common.go b/src/full_check/common/common.go index ec1b870..1398255 100644 --- a/src/full_check/common/common.go +++ b/src/full_check/common/common.go @@ -1,8 +1,8 @@ package common import ( - "github.com/cihub/seelog" "fmt" + "github.com/cihub/seelog" ) const ( @@ -42,6 +42,13 @@ func CheckFilter(filterTree *Trie, keyBytes []byte) bool { return filterTree.Search(keyBytes) } +func CheckBlock(filterTree *Trie, keyBytes []byte) bool { + if filterTree == nil { // all pass when filter list is empty + return false + } + return filterTree.Search(keyBytes) +} + func HandleLogLevel(logLevel string) (string, error) { // seelog library is disgusting switch logLevel { @@ -58,4 +65,4 @@ func HandleLogLevel(logLevel string) (string, error) { default: return "", fmt.Errorf("unknown log level[%v]", logLevel) } -} \ No newline at end of file +} diff --git a/src/full_check/common/trieTree.go b/src/full_check/common/trieTree.go index a5dfb5f..0d0eea5 100644 --- a/src/full_check/common/trieTree.go +++ b/src/full_check/common/trieTree.go @@ -1,17 +1,21 @@ package common -const ( - Star = byte('*') -) - type TrieNode struct { children map[byte]*TrieNode - isEnd bool - isStar bool // is ending by * + isEnd bool // 是否为精确匹配 + isPrefix bool // 是否为前缀匹配 + isSuffix bool // 是否为后缀匹配 + isAll bool // 是否为全匹配(空串或 "*") } func newTrieNode() *TrieNode { - return &TrieNode{children: make(map[byte]*TrieNode), isEnd: false, isStar: false} + return &TrieNode{ + children: make(map[byte]*TrieNode), + isEnd: false, + isPrefix: false, + isSuffix: false, + isAll: false, + } } type Trie struct { @@ -22,16 +26,50 @@ func NewTrie() *Trie { return &Trie{root: newTrieNode()} } +func reverse(word []byte) []byte { + for i, j := 0, len(word)-1; i < j; i, j = i+1, j-1 { + word[i], word[j] = word[j], word[i] + } + return word +} + func (trie *Trie) Insert(word []byte) { node := trie.root - for _, char := range word { - if char == Star { - node.isStar = true - break + + // 空串或 "*" 视为全匹配 + if len(word) == 0 || (len(word) == 1 && word[0] == '*') { + node.isAll = true + return + } + + // 前缀匹配 + if word[len(word)-1] == '*' { + for _, char := range word[:len(word)-1] { + if _, ok := node.children[char]; !ok { + node.children[char] = newTrieNode() + } + node = node.children[char] } + node.isPrefix = true + return + } + + // 后缀匹配 + if word[0] == '*' { + reversedWord := reverse(word[1:]) + for _, char := range reversedWord { + if _, ok := node.children[char]; !ok { + node.children[char] = newTrieNode() + } + node = node.children[char] + } + node.isSuffix = true + return + } - _, ok := node.children[char] - if !ok { + // 精确匹配 + for _, char := range word { + if _, ok := node.children[char]; !ok { node.children[char] = newTrieNode() } node = node.children[char] @@ -41,14 +79,55 @@ func (trie *Trie) Insert(word []byte) { func (trie *Trie) Search(word []byte) bool { node := trie.root + + if node.isAll { + return true + } + + // 精确匹配 + curr := node for _, char := range word { - if node.isStar { + if _, ok := curr.children[char]; !ok { + curr = nil + break + } + curr = curr.children[char] + } + if curr != nil && curr.isEnd { + return true + } + + // 前缀匹配 + curr = node + for _, char := range word { + if curr.isPrefix { return true } - if _, ok := node.children[char]; !ok { + if _, ok := curr.children[char]; !ok { + curr = nil + break + } + curr = curr.children[char] + } + if curr != nil && curr.isPrefix { + return true + } + + // 后缀匹配 + reversedWord := reverse(append([]byte(nil), word...)) + curr = node + for _, char := range reversedWord { + if curr.isSuffix { + return true + } + if _, ok := curr.children[char]; !ok { return false } - node = node.children[char] + curr = curr.children[char] } - return node.isEnd || node.isStar + if curr != nil && curr.isSuffix { + return true + } + + return false } diff --git a/src/full_check/common/trieTree_test.go b/src/full_check/common/trieTree_test.go index 850e9fc..d436bca 100644 --- a/src/full_check/common/trieTree_test.go +++ b/src/full_check/common/trieTree_test.go @@ -9,47 +9,111 @@ import ( func TestTrie(t *testing.T) { var nr int + + // 测试精确匹配 { nr++ - fmt.Printf("TestTrie case %d.\n", nr) + fmt.Printf("TestTrie case %d: 精确匹配.\n", nr) trie := NewTrie() - assert.Equal(t, false, trie.Search([]byte("abc")), "should be equal") - assert.Equal(t, false, trie.Search([]byte("df")), "should be equal") - assert.Equal(t, false, trie.Search([]byte("")), "should be equal") + insertList := []string{"abc", "def", "xyz"} + for _, element := range insertList { + trie.Insert([]byte(element)) + } + + assert.Equal(t, true, trie.Search([]byte("abc")), "精确匹配失败") + assert.Equal(t, true, trie.Search([]byte("def")), "精确匹配失败") + assert.Equal(t, true, trie.Search([]byte("xyz")), "精确匹配失败") + assert.Equal(t, false, trie.Search([]byte("abcd")), "精确匹配错误") + assert.Equal(t, false, trie.Search([]byte("xy")), "精确匹配错误") } + // 测试前缀匹配 { nr++ - fmt.Printf("TestTrie case %d.\n", nr) + fmt.Printf("TestTrie case %d: 前缀匹配.\n", nr) + trie := NewTrie() - insertList := []string{"abc", "adf" ,"bdf*", "m*"} + insertList := []string{"abc*", "def*", "xyz*"} for _, element := range insertList { trie.Insert([]byte(element)) } - assert.Equal(t, true, trie.Search([]byte("abc")), "should be equal") - assert.Equal(t, false, trie.Search([]byte("abcd")), "should be equal") - assert.Equal(t, false, trie.Search([]byte("adff")), "should be equal") - assert.Equal(t, true, trie.Search([]byte("m")), "should be equal") - assert.Equal(t, true, trie.Search([]byte("m1")), "should be equal") - assert.Equal(t, false, trie.Search([]byte("")), "should be equal") + assert.Equal(t, true, trie.Search([]byte("abc")), "前缀匹配失败") + assert.Equal(t, true, trie.Search([]byte("abc123")), "前缀匹配失败") + assert.Equal(t, true, trie.Search([]byte("def456")), "前缀匹配失败") + assert.Equal(t, false, trie.Search([]byte("ab")), "前缀匹配错误") + assert.Equal(t, false, trie.Search([]byte("xy")), "前缀匹配错误") } + // 测试后缀匹配 { nr++ - fmt.Printf("TestTrie case %d.\n", nr) + fmt.Printf("TestTrie case %d: 后缀匹配.\n", nr) + trie := NewTrie() - insertList := []string{"*"} + insertList := []string{"*abc", "*def", "*xyz"} for _, element := range insertList { trie.Insert([]byte(element)) } - assert.Equal(t, true, trie.Search([]byte("abc")), "should be equal") - assert.Equal(t, true, trie.Search([]byte("abcd")), "should be equal") - assert.Equal(t, true, trie.Search([]byte("adff")), "should be equal") - assert.Equal(t, true, trie.Search([]byte("m")), "should be equal") - assert.Equal(t, true, trie.Search([]byte("m1")), "should be equal") - assert.Equal(t, true, trie.Search([]byte("")), "should be equal") + assert.Equal(t, true, trie.Search([]byte("123abc")), "后缀匹配失败") + assert.Equal(t, true, trie.Search([]byte("456def")), "后缀匹配失败") + assert.Equal(t, true, trie.Search([]byte("789xyz")), "后缀匹配失败") + assert.Equal(t, false, trie.Search([]byte("abc123")), "后缀匹配错误") + assert.Equal(t, false, trie.Search([]byte("def456")), "后缀匹配错误") + } + + // 测试全匹配 * + { + nr++ + fmt.Printf("TestTrie case %d: 全匹配 *.\n", nr) + + trie := NewTrie() + trie.Insert([]byte("")) + + assert.Equal(t, true, trie.Search([]byte("abc")), "全匹配失败") + assert.Equal(t, true, trie.Search([]byte("123")), "全匹配失败") + assert.Equal(t, true, trie.Search([]byte("xyz789")), "全匹配失败") + assert.Equal(t, true, trie.Search([]byte("122111")), "全匹配失败") + } + + // 测试空 filterlist + { + nr++ + fmt.Printf("TestCheckFilter case %d: 空 filterlist.\n", nr) + + var trie *Trie = nil // 空 filterlist + assert.Equal(t, true, CheckFilter(trie, []byte("any_key")), "空 filterlist 匹配失败") + } +} + +func TestCheckBlock(t *testing.T) { + var nr int + + // 测试 blocklist 匹配 + { + nr++ + fmt.Printf("TestCheckBlock case %d: blocklist 匹配.\n", nr) + + trie := NewTrie() + blockList := []string{"block1*", "*block2", "block3"} + for _, element := range blockList { + trie.Insert([]byte(element)) + } + + assert.Equal(t, true, CheckBlock(trie, []byte("block11")), "blocklist 匹配失败") + assert.Equal(t, true, CheckBlock(trie, []byte("fblock2")), "blocklist 匹配失败") + assert.Equal(t, true, CheckBlock(trie, []byte("block3")), "blocklist 匹配失败") + assert.Equal(t, false, CheckBlock(trie, []byte("not_in_blocklist")), "blocklist 匹配错误") + } + + // 测试空 blocklist + { + nr++ + fmt.Printf("TestCheckBlock case %d: 空 blocklist.\n", nr) + + var trie *Trie = nil // 空 blocklist + assert.Equal(t, false, CheckBlock(trie, []byte("any_key")), "空 blocklist 匹配失败") } -} \ No newline at end of file +} diff --git a/src/full_check/configure/conf.go b/src/full_check/configure/conf.go index dca7612..d17c188 100644 --- a/src/full_check/configure/conf.go +++ b/src/full_check/configure/conf.go @@ -27,6 +27,6 @@ var Opts struct { MetricPrint bool `long:"metric" value-name:"BOOL" description:"print metric in log"` BigKeyThreshold int64 `long:"bigkeythreshold" value-name:"COUNT" default:"16384"` FilterList string `short:"f" long:"filterlist" value-name:"FILTER" default:"" description:"if the filter list isn't empty, all elements in list will be synced. The input should be split by '|'. The end of the string is followed by a * to indicate a prefix match, otherwise it is a full match. e.g.: 'abc*|efg|m*' matches 'abc', 'abc1', 'efg', 'm', 'mxyz', but 'efgh', 'p' aren't'"` - SystemProfile uint `long:"systemprofile" value-name:"SYSTEM-PROFILE" default:"20445" description:"port that used to print golang inner head and stack message"` + BlockList string `short:"b" long:"blocklist" value-name:"BLOCK" default:"" description:"if the block list isn't empty, all elements in list will be blocked. The input should be split by '|'. The end of the string is followed by a * to indicate a prefix match, otherwise it is a full match. e.g.: 'abc*|efg|m*' blocks 'abc', 'abc1', 'efg', 'm', 'mxyz', but 'efgh', 'p' aren't'"` Version bool `short:"v" long:"version"` } diff --git a/src/full_check/full_check/scan.go b/src/full_check/full_check/scan.go index e1c24ac..921adc6 100644 --- a/src/full_check/full_check/scan.go +++ b/src/full_check/full_check/scan.go @@ -1,11 +1,11 @@ package full_check import ( - "strconv" "fmt" + "strconv" - "full_check/common" "full_check/client" + "full_check/common" "github.com/jinzhu/copier" "sync" @@ -94,6 +94,11 @@ func (p *FullCheck) ScanFromSourceRedis(allKeys chan<- []*common.Key) { continue } + // Check block list + if common.CheckBlock(p.BlockTree, bytes) == true { + continue + } + keysInfo = append(keysInfo, &common.Key{ Key: bytes, Tp: common.EndKeyType, @@ -204,4 +209,4 @@ func (p *FullCheck) ScanFromDB(allKeys chan<- []*common.Key) { p.IncrScanStat(len(keyInfo)) allKeys <- keyInfo } // for{} -} \ No newline at end of file +} diff --git a/src/full_check/main.go b/src/full_check/main.go index 1b9ec3a..f1b4e2a 100644 --- a/src/full_check/main.go +++ b/src/full_check/main.go @@ -6,14 +6,13 @@ import ( "strconv" "strings" - "full_check/configure" - "full_check/full_check" "full_check/checker" "full_check/client" "full_check/common" + "full_check/configure" + "full_check/full_check" "github.com/jessevdk/go-flags" - "github.com/gugemichael/nimo4go" ) var VERSION = "$" @@ -54,7 +53,7 @@ func main() { os.Exit(1) } - nimo.Profiling(int(conf.Opts.SystemProfile)) + //nimo.Profiling(int(conf.Opts.SystemProfile)) common.Logger, err = common.InitLog(conf.Opts.LogFile, logLevel) if err != nil { @@ -132,6 +131,20 @@ func main() { common.Logger.Infof("filter list enabled: %v", filterList) } + // block list + var blockTree *common.Trie + if len(conf.Opts.BlockList) != 0 { + blockTree = common.NewTrie() + blockList := strings.Split(conf.Opts.BlockList, "|") + for _, block := range blockList { + if block == "" { + panic(common.Logger.Errorf("invalid input block list: %v", blockList)) + } + blockTree.Insert([]byte(block)) + } + common.Logger.Infof("block list enabled: %v", blockList) + } + // remove result file if has if len(conf.Opts.ResultFile) > 0 { os.Remove(conf.Opts.ResultFile) @@ -162,6 +175,7 @@ func main() { BatchCount: batchCount, Parallel: parallel, FilterTree: filterTree, + BlockTree: blockTree, } common.Logger.Info("configuration: ", conf.Opts) From 07a7c2af1fe4a7bb15a41f3c594eb0aa4595f64f Mon Sep 17 00:00:00 2001 From: juanxincaigou Date: Tue, 1 Jul 2025 18:08:09 +0800 Subject: [PATCH 2/4] =?UTF-8?q?go=E9=A1=B9=E7=9B=AE=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- USE_GO.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 USE_GO.md diff --git a/USE_GO.md b/USE_GO.md new file mode 100644 index 0000000..c64ec5c --- /dev/null +++ b/USE_GO.md @@ -0,0 +1,6 @@ +初始化项目要进入 full-check中进行这两个命令 +go mod init full_check +go mod tidy + +执行模块下的断言 +go test D:\IntelliJIDEA2022.3.3\idea-project\RedisFullCheck\src\full_check\common -v From 75daa72749fccbbd489943742179e668653c1124 Mon Sep 17 00:00:00 2001 From: juanxincaigou Date: Fri, 4 Jul 2025 17:46:58 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=AD=A3=E5=88=99?= =?UTF-8?q?=E8=A1=A8=E8=BE=BE=E5=BC=8F=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- USE_GO.md | 8 +++- src/full_check/common/trieTree.go | 64 ++++++++++++++++++++------ src/full_check/common/trieTree_test.go | 23 +++++++++ src/full_check/go.mod | 22 --------- src/full_check/go.sum | 30 ------------ 5 files changed, 79 insertions(+), 68 deletions(-) delete mode 100644 src/full_check/go.mod delete mode 100644 src/full_check/go.sum diff --git a/USE_GO.md b/USE_GO.md index c64ec5c..ac66b00 100644 --- a/USE_GO.md +++ b/USE_GO.md @@ -1,6 +1,10 @@ -初始化项目要进入 full-check中进行这两个命令 +# 初始化项目要进入 full-check中进行这两个命令 go mod init full_check go mod tidy -执行模块下的断言 +# 自动下载缺失的模块并更新 go.sum 文件 +go get -t ./common + +# 执行模块下的断言 go test D:\IntelliJIDEA2022.3.3\idea-project\RedisFullCheck\src\full_check\common -v +go test ./common -v diff --git a/src/full_check/common/trieTree.go b/src/full_check/common/trieTree.go index 0d0eea5..d61b079 100644 --- a/src/full_check/common/trieTree.go +++ b/src/full_check/common/trieTree.go @@ -1,29 +1,34 @@ package common +import ( + "regexp" + "strings" +) + type TrieNode struct { children map[byte]*TrieNode - isEnd bool // 是否为精确匹配 - isPrefix bool // 是否为前缀匹配 - isSuffix bool // 是否为后缀匹配 - isAll bool // 是否为全匹配(空串或 "*") + isEnd bool // 精确匹配 + isPrefix bool // 前缀匹配 + isSuffix bool // 后缀匹配 + isAll bool // 全匹配(空串或 "*") } func newTrieNode() *TrieNode { return &TrieNode{ children: make(map[byte]*TrieNode), - isEnd: false, - isPrefix: false, - isSuffix: false, - isAll: false, } } type Trie struct { - root *TrieNode + root *TrieNode + regexList []*regexp.Regexp // 存储正则表达式 } func NewTrie() *Trie { - return &Trie{root: newTrieNode()} + return &Trie{ + root: newTrieNode(), + regexList: make([]*regexp.Regexp, 0), + } } func reverse(word []byte) []byte { @@ -33,16 +38,39 @@ func reverse(word []byte) []byte { return word } +//func isRegex(str string) bool { +// // 简单判断是否是正则表达式(也可以用更严谨的规则) +// return strings.HasPrefix(str, "^") || strings.HasSuffix(str, "$") || strings.Contains(str, ".*") +//} + +func isRegex(str string) bool { + // 如果是前缀或后缀匹配(单个 * 在开头或结尾),不算正则表达式 + if strings.HasSuffix(str, "*") || strings.HasPrefix(str, "*") { + return false + } + // 如果包含真正的正则符号,则认为是正则表达式 + return strings.ContainsAny(str, "^$+?.[](){}|\\") +} + func (trie *Trie) Insert(word []byte) { node := trie.root + str := string(word) + + // 如果是正则表达式,直接加入 regexList + if isRegex(str) { + if re, err := regexp.Compile(str); err == nil { + trie.regexList = append(trie.regexList, re) + } + return + } - // 空串或 "*" 视为全匹配 + // 全匹配 if len(word) == 0 || (len(word) == 1 && word[0] == '*') { node.isAll = true return } - // 前缀匹配 + // 前缀匹配(xxx*) if word[len(word)-1] == '*' { for _, char := range word[:len(word)-1] { if _, ok := node.children[char]; !ok { @@ -54,7 +82,7 @@ func (trie *Trie) Insert(word []byte) { return } - // 后缀匹配 + // 后缀匹配(*xxx) if word[0] == '*' { reversedWord := reverse(word[1:]) for _, char := range reversedWord { @@ -121,7 +149,8 @@ func (trie *Trie) Search(word []byte) bool { return true } if _, ok := curr.children[char]; !ok { - return false + curr = nil + break } curr = curr.children[char] } @@ -129,5 +158,12 @@ func (trie *Trie) Search(word []byte) bool { return true } + // 正则匹配 + for _, re := range trie.regexList { + if re.Match(word) { + return true + } + } + return false } diff --git a/src/full_check/common/trieTree_test.go b/src/full_check/common/trieTree_test.go index d436bca..3a91680 100644 --- a/src/full_check/common/trieTree_test.go +++ b/src/full_check/common/trieTree_test.go @@ -117,3 +117,26 @@ func TestCheckBlock(t *testing.T) { assert.Equal(t, false, CheckBlock(trie, []byte("any_key")), "空 blocklist 匹配失败") } } + +func TestTrieRegex(t *testing.T) { + var nr int + + nr++ + fmt.Printf("TestTrie case %d: 正则表达式匹配.\n", nr) + + trie := NewTrie() + regexList := []string{"^test.*$", "^[0-9]+$", ".*end$"} + for _, element := range regexList { + trie.Insert([]byte(element)) + } + + // 匹配正则的 + assert.Equal(t, true, trie.Search([]byte("test123")), "正则表达式匹配失败") + assert.Equal(t, true, trie.Search([]byte("12345")), "正则表达式匹配失败") + assert.Equal(t, true, trie.Search([]byte("this_is_the_end")), "正则表达式匹配失败") + + // 不匹配正则的 + assert.Equal(t, false, trie.Search([]byte("example")), "正则表达式匹配错误") + assert.Equal(t, false, trie.Search([]byte("abc123")), "正则表达式匹配错误") + assert.Equal(t, false, trie.Search([]byte("start_middle")), "正则表达式匹配错误") +} diff --git a/src/full_check/go.mod b/src/full_check/go.mod deleted file mode 100644 index d3cc12a..0000000 --- a/src/full_check/go.mod +++ /dev/null @@ -1,22 +0,0 @@ -module full_check - -go 1.17 - -require ( - github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575 - github.com/gomodule/redigo v1.8.9 - github.com/gugemichael/nimo4go v0.0.0-20210413043712-ccb2ff0d7b40 - github.com/jessevdk/go-flags v1.5.0 - github.com/jinzhu/copier v0.3.5 - github.com/mattn/go-sqlite3 v1.14.16 - github.com/najoast/redis-go-cluster v1.0.0 - github.com/stretchr/testify v1.8.1 - github.com/vinllen/redis-go-cluster v1.0.0 -) - -require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) diff --git a/src/full_check/go.sum b/src/full_check/go.sum deleted file mode 100644 index 23529b9..0000000 --- a/src/full_check/go.sum +++ /dev/null @@ -1,30 +0,0 @@ -github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575 h1:kHaBemcxl8o/pQ5VM1c8PVE1PubbNx3mjUr09OqWGCs= -github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575/go.mod h1:9d6lWj8KzO/fd/NrVaLscBKmPigpZpn5YawRPw+e3Yo= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gomodule/redigo v1.8.9 h1:Sl3u+2BI/kk+VEatbj0scLdrFhjPmbxOc1myhDP41ws= -github.com/gomodule/redigo v1.8.9/go.mod h1:7ArFNvsTjH8GMMzB4uy1snslv2BwmginuMs06a1uzZE= -github.com/gugemichael/nimo4go v0.0.0-20210413043712-ccb2ff0d7b40 h1:6TWAiHVyKs75ZHEn7XtVv7SO7M4rHwvY/5Tf7xdJBkc= -github.com/gugemichael/nimo4go v0.0.0-20210413043712-ccb2ff0d7b40/go.mod h1:ibO7uKpO8fOH/bKD4trmwm5tHhHKiAjC0u288Rd+GnI= -github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc= -github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= -github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg= -github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= -github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= -github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= -github.com/najoast/redis-go-cluster v1.0.0 h1:GJhtiwitgaQ0Kc9ZcRE9FJCcu1GLCIIW7u7vpRrgE6k= -github.com/najoast/redis-go-cluster v1.0.0/go.mod h1:lGMMsVLZW+0gAuA+oo1YrFTZjjaIhkmhR6cA77/etiw= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/vinllen/redis-go-cluster v1.0.0/go.mod h1:xig5hQAOZX1K+KNUVDqAbhTRzMTPcb257nJl7OCHrI4= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 h1:EZ2mChiOa8udjfp6rRmswTbtZN/QzUQp4ptM4rnjHvc= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 18d4b4a0a06ce2a0ef3a571f7a63722313436fdf Mon Sep 17 00:00:00 2001 From: juanxincaigou Date: Mon, 7 Jul 2025 10:21:46 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9filterlist=E3=80=81blockl?= =?UTF-8?q?ist=E7=9A=84=E5=88=86=E9=9A=94=E7=AC=A6=EF=BC=8C=E4=BB=A5?= =?UTF-8?q?=E5=85=8D=E6=AD=A3=E5=88=99=E8=A1=A8=E8=BE=BE=E5=BC=8F=E5=8E=BB?= =?UTF-8?q?=E5=85=B6=E4=BA=A7=E7=94=9F=E5=B9=B2=E6=89=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/full_check/configure/conf.go | 4 ++-- src/full_check/main.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/full_check/configure/conf.go b/src/full_check/configure/conf.go index d17c188..28163c3 100644 --- a/src/full_check/configure/conf.go +++ b/src/full_check/configure/conf.go @@ -26,7 +26,7 @@ var Opts struct { LogLevel string `long:"loglevel" value-name:"LEVEL" description:"log level: 'debug', 'info', 'warn', 'error', default is 'info'"` MetricPrint bool `long:"metric" value-name:"BOOL" description:"print metric in log"` BigKeyThreshold int64 `long:"bigkeythreshold" value-name:"COUNT" default:"16384"` - FilterList string `short:"f" long:"filterlist" value-name:"FILTER" default:"" description:"if the filter list isn't empty, all elements in list will be synced. The input should be split by '|'. The end of the string is followed by a * to indicate a prefix match, otherwise it is a full match. e.g.: 'abc*|efg|m*' matches 'abc', 'abc1', 'efg', 'm', 'mxyz', but 'efgh', 'p' aren't'"` - BlockList string `short:"b" long:"blocklist" value-name:"BLOCK" default:"" description:"if the block list isn't empty, all elements in list will be blocked. The input should be split by '|'. The end of the string is followed by a * to indicate a prefix match, otherwise it is a full match. e.g.: 'abc*|efg|m*' blocks 'abc', 'abc1', 'efg', 'm', 'mxyz', but 'efgh', 'p' aren't'"` + FilterList string `short:"f" long:"filterlist" value-name:"FILTER" default:"" description:"if the filter list isn't empty, all elements in list will be synced. The input should be split by ';'. The end of the string is followed by a * to indicate a prefix match, otherwise it is a full match. e.g.: 'abc*|efg|m*' matches 'abc', 'abc1', 'efg', 'm', 'mxyz', but 'efgh', 'p' aren't'"` + BlockList string `short:"b" long:"blocklist" value-name:"BLOCK" default:"" description:"if the block list isn't empty, all elements in list will be blocked. The input should be split by ';'. The end of the string is followed by a * to indicate a prefix match, otherwise it is a full match. e.g.: 'abc*|efg|m*' blocks 'abc', 'abc1', 'efg', 'm', 'mxyz', but 'efgh', 'p' aren't'"` Version bool `short:"v" long:"version"` } diff --git a/src/full_check/main.go b/src/full_check/main.go index f1b4e2a..96866cb 100644 --- a/src/full_check/main.go +++ b/src/full_check/main.go @@ -121,7 +121,7 @@ func main() { var filterTree *common.Trie if len(conf.Opts.FilterList) != 0 { filterTree = common.NewTrie() - filterList := strings.Split(conf.Opts.FilterList, "|") + filterList := strings.Split(conf.Opts.FilterList, ";") for _, filter := range filterList { if filter == "" { panic(common.Logger.Errorf("invalid input filter list: %v", filterList)) @@ -135,7 +135,7 @@ func main() { var blockTree *common.Trie if len(conf.Opts.BlockList) != 0 { blockTree = common.NewTrie() - blockList := strings.Split(conf.Opts.BlockList, "|") + blockList := strings.Split(conf.Opts.BlockList, ";") for _, block := range blockList { if block == "" { panic(common.Logger.Errorf("invalid input block list: %v", blockList))