From 2a107c474bab38b5af81d66fe637a0fc32f6bfdb Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Thu, 2 Nov 2023 20:19:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/utils/iptables/iptables.go | 8 ++++++++ pkg/utils/iptables/parser.go | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/pkg/utils/iptables/iptables.go b/pkg/utils/iptables/iptables.go index c75a949..86efab5 100644 --- a/pkg/utils/iptables/iptables.go +++ b/pkg/utils/iptables/iptables.go @@ -48,4 +48,12 @@ type Rule struct { Protocol string `json:"protocol"` // ! -p [proto] example: all, tcp, udp, icmp ExcludeProtocol string `json:"excludeProtocol"` + + // -m [match] 用于匹配扩展模块 example: tcp udp icmp + Match string `json:"match"` + + // --sport example: 22 80 + SrcPort string `json:"srcPort"` + // --dport example: 80 + DstPort string `json:"dstPort"` } diff --git a/pkg/utils/iptables/parser.go b/pkg/utils/iptables/parser.go index 19fec3b..e0fded2 100644 --- a/pkg/utils/iptables/parser.go +++ b/pkg/utils/iptables/parser.go @@ -80,6 +80,10 @@ func Parse(rules string) { jump := flagSet.StringP("jump", "j", "", "") gotoChain := flagSet.StringP("goto", "g", "", "") + match := flagSet.StringP("match", "m", "", "") + + srcPort := flagSet.String("sport", "", "") + dstPort := flagSet.String("dport", "", "") _ = flagSet.Parse(args) r := Rule{ @@ -100,6 +104,9 @@ func Parse(rules string) { ExcludeProtocol: *excludeProtocol, Jump: Chain(*jump), Goto: Chain(*gotoChain), + Match: *match, + SrcPort: *srcPort, + DstPort: *dstPort, } ruleList = append(ruleList, r) }