完善解析

This commit is contained in:
shikong 2023-11-02 20:19:38 +08:00
parent ccec58bfb9
commit 2a107c474b
2 changed files with 15 additions and 0 deletions

View File

@ -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"`
}

View File

@ -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)
}