From 4af94df142d4ab070e38569a0422ebd7154f8da3 Mon Sep 17 00:00:00 2001 From: "Vincent.Shi" Date: Fri, 5 Jan 2024 15:07:49 +0800 Subject: [PATCH 1/3] chore: Redundant function calls. (#956) --- main.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/main.go b/main.go index 425b4661..748fa2e3 100644 --- a/main.go +++ b/main.go @@ -72,11 +72,10 @@ func main() { currentDir, _ := os.Getwd() configFile = filepath.Join(currentDir, configFile) } - C.SetConfig(configFile) } else { configFile = filepath.Join(C.Path.HomeDir(), C.Path.Config()) - C.SetConfig(configFile) } + C.SetConfig(configFile) if geodataMode { C.GeodataMode = true From 6bc915526fdf7044ab14ecb89f7a1de7812ea720 Mon Sep 17 00:00:00 2001 From: Larvan2 <78135608+Larvan2@users.noreply.github.com> Date: Sat, 6 Jan 2024 17:54:09 +0800 Subject: [PATCH 2/3] fix: resolve IPv6 rule-set issue #959. --- component/trie/ipcidr_trie.go | 4 ++++ component/trie/trie_test.go | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/component/trie/ipcidr_trie.go b/component/trie/ipcidr_trie.go index a2ccfa16..ee8659be 100644 --- a/component/trie/ipcidr_trie.go +++ b/component/trie/ipcidr_trie.go @@ -185,6 +185,10 @@ func addIpv6Cidr(trie *IpCidrTrie, ip net.IP, groupSize int) { } for i := 2; i < groupSize; i += 2 { + if ip[i] == 0 && ip[i+1] == 0 { + node.Mark = true + } + if node.Mark { return } diff --git a/component/trie/trie_test.go b/component/trie/trie_test.go index e1b20103..a589b7ca 100644 --- a/component/trie/trie_test.go +++ b/component/trie/trie_test.go @@ -74,6 +74,14 @@ func TestIpv6AddFail(t *testing.T) { assert.IsType(t, new(net.ParseError), err) } +func TestIpv6SearchSub(t *testing.T) { + trie := NewIpCidrTrie() + assert.NoError(t, trie.AddIpCidrForString("240e::/18")) + + assert.Equal(t, true, trie.IsContainForString("240e:964:ea02:100:1800::71")) + +} + func TestIpv6Search(t *testing.T) { trie := NewIpCidrTrie() From 7e3e38d0548a738d36ff8d4e92567f2cab16863e Mon Sep 17 00:00:00 2001 From: Cesaryuan <35998162+cesaryuan@users.noreply.github.com> Date: Sat, 6 Jan 2024 22:25:51 +0800 Subject: [PATCH 3/3] fix: SUB-RULE with PROCESS-NAME rule payload not working (#953) --- rules/logic/logic.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rules/logic/logic.go b/rules/logic/logic.go index fde96e19..af8c31a4 100644 --- a/rules/logic/logic.go +++ b/rules/logic/logic.go @@ -217,6 +217,13 @@ func (logic *Logic) parsePayload(payload string, parseRule ParseRuleFunc) error return err } + if rule.ShouldResolveIP() { + logic.needIP = true + } + if rule.ShouldFindProcess() { + logic.needProcess = true + } + rules = append(rules, rule) }