fix: 修改 UFW IP 规则优先级 (#2508)

This commit is contained in:
ssongliu 2023-10-11 17:12:34 +08:00 committed by GitHub
parent f9e22166c1
commit faf4174adf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -233,13 +233,13 @@ func (u *FirewallService) OperatePortRule(req dto.PortRuleOperate, reload bool)
} }
return nil return nil
} }
if req.Protocol == "tcp/udp" {
req.Protocol = ""
}
for _, addr := range itemAddress { for _, addr := range itemAddress {
if len(addr) == 0 { if len(addr) == 0 {
addr = "Anywhere" addr = "Anywhere"
} }
if req.Protocol == "tcp/udp" {
req.Protocol = ""
}
req.Address = addr req.Address = addr
if err := u.operatePort(client, req); err != nil { if err := u.operatePort(client, req); err != nil {
global.LOG.Errorf("%s port %s/%s failed (strategy: %s, address: %s), err: %v", req.Operation, req.Port, req.Protocol, req.Strategy, req.Address, err) global.LOG.Errorf("%s port %s/%s failed (strategy: %s, address: %s), err: %v", req.Operation, req.Port, req.Protocol, req.Strategy, req.Address, err)

View File

@ -165,7 +165,7 @@ func (f *Ufw) RichRules(rule FireInfo, operation string) error {
return buserr.New(constant.ErrCmdIllegal) return buserr.New(constant.ErrCmdIllegal)
} }
ruleStr := fmt.Sprintf("%s %s ", f.CmdStr, rule.Strategy) ruleStr := fmt.Sprintf("%s insert 1 %s ", f.CmdStr, rule.Strategy)
if operation == "remove" { if operation == "remove" {
ruleStr = fmt.Sprintf("%s delete %s ", f.CmdStr, rule.Strategy) ruleStr = fmt.Sprintf("%s delete %s ", f.CmdStr, rule.Strategy)
} }