fix: Fix the issue of abnormal ufw status loading (#10949)

This commit is contained in:
ssongliu 2025-11-13 21:36:35 +08:00 committed by GitHub
parent 402931862f
commit e4fbd3cf86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 9 deletions

View file

@ -59,21 +59,15 @@ func (u *FirewallService) LoadBaseInfo(tab string) (dto.FirewallBaseInfo, error)
baseInfo.Name = client.Name()
var wg sync.WaitGroup
wg.Add(4)
wg.Add(2)
go func() {
defer wg.Done()
baseInfo.PingStatus = u.pingStatus()
}()
go func() {
defer wg.Done()
baseInfo.IsActive, _ = client.Status()
}()
go func() {
defer wg.Done()
baseInfo.Version, _ = client.Version()
}()
go func() {
defer wg.Done()
baseInfo.IsActive, _ = client.Status()
baseInfo.IsInit, baseInfo.IsBind = loadInitStatus(baseInfo.Name, tab)
}()
wg.Wait()

View file

@ -97,7 +97,7 @@ func CheckChainExist(tab, chain string) (bool, error) {
return true, nil
}
func CheckChainBind(tab, parentChain, chain string) (bool, error) {
stdout, err := RunWithStd(tab, fmt.Sprintf("-L %s | grep -w %s", parentChain, chain))
stdout, err := RunWithStd(tab, fmt.Sprintf("-S %s | grep -- '-j %s'", parentChain, chain))
if err != nil {
global.LOG.Errorf("check chain %s from tab %s is bind to %s failed, err: %v", chain, tab, parentChain, err)
return false, fmt.Errorf("check chain %s from tab %s is bind to %s failed, err: %v", chain, tab, parentChain, err)