fix: 解决 firewalld 防火墙规则 ipv6 下不生效的问题 (#2613)

Refs #2144
This commit is contained in:
ssongliu 2023-10-21 22:44:52 +08:00 committed by GitHub
parent b38abf852d
commit 8a7e61e9e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -156,7 +156,7 @@ func (f *Firewall) RichRules(rule FireInfo, operation string) error {
}
ruleStr = fmt.Sprintf("rule source ipset=%s %s", rule.Address, rule.Strategy)
} else {
ruleStr = "rule family=ipv4 "
ruleStr = "rule "
if len(rule.Address) != 0 {
ruleStr += fmt.Sprintf("source address=%s ", rule.Address)
}

View file

@ -207,6 +207,9 @@ func (f *Ufw) PortForward(info Forward, operation string) error {
func (f *Ufw) loadInfo(line string, fireType string) FireInfo {
fields := strings.Fields(line)
var itemInfo FireInfo
if strings.Contains(line, "LIMIT") || strings.Contains(line, "ALLOW FWD") {
return itemInfo
}
if len(fields) < 4 {
return itemInfo
}