fix: 解决防火墙 ip 规则批量操作失败的问题 (#2435)

Refs #2421 #2430
pull/2436/head
ssongliu 1 year ago committed by GitHub
parent bca9777a43
commit 6b1cc1088e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -233,6 +233,7 @@ func (u *FirewallService) OperatePortRule(req dto.PortRuleOperate, reload bool)
}(req)
}
}
wg.Wait()
return nil
}
if req.Protocol == "tcp/udp" {
@ -314,20 +315,20 @@ func (u *FirewallService) OperateAddressRule(req dto.AddrRuleOperate, reload boo
var wg sync.WaitGroup
addressList := strings.Split(req.Address, ",")
for _, addr := range addressList {
if len(addr) == 0 {
for i := 0; i < len(addressList); i++ {
if len(addressList[i]) == 0 {
continue
}
fireInfo.Address = addr
wg.Add(1)
go func(req dto.AddrRuleOperate) {
go func(addr string) {
defer wg.Done()
fireInfo.Address = addr
if err := client.RichRules(fireInfo, req.Operation); err != nil {
global.LOG.Errorf("%s address %s failed (strategy: %s), err: %v", req.Operation, req.Address, req.Strategy, err)
global.LOG.Errorf("%s address %s failed (strategy: %s), err: %v", req.Operation, addr, req.Strategy, err)
}
req.Address = fireInfo.Address
req.Address = addr
_ = u.addAddressRecord(req)
}(req)
}(addressList[i])
}
wg.Wait()
if reload {
@ -397,6 +398,7 @@ func (u *FirewallService) BatchOperateRule(req dto.BatchRuleOperate) error {
_ = u.OperateAddressRule(item, false)
}(itemRule)
}
wgBatch.Wait()
return client.Reload()
}

Loading…
Cancel
Save