2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 16:10:59 +08:00

fix(safe): null rule

This commit is contained in:
耗子
2023-08-04 00:33:27 +08:00
parent 4dc2895781
commit 1abb9691f4
2 changed files with 12 additions and 2 deletions

View File

@@ -62,6 +62,10 @@ panel
- [无畏云加速](https://su.sctes.com/register?code=8st689ujpmm2p)
- [AnyCast.Ai](https://www.anycast.ai/)
- [迅捷盾](https://console.fastdun.com/)
### DevOps
- [极狐GitLab](https://www.jihulab.com/)

View File

@@ -55,7 +55,10 @@ func (r *SafeController) GetFirewallRules(ctx http.Context) {
out := tools.ExecShell("firewall-cmd --list-all 2>&1")
match := regexp.MustCompile(`ports: (.*)`).FindStringSubmatch(out)
if len(match) == 0 {
Success(ctx, nil)
Success(ctx, http.Json{
"total": 0,
"items": []map[string]string{},
})
return
}
ports := strings.Split(match[1], " ")
@@ -89,7 +92,10 @@ func (r *SafeController) GetFirewallRules(ctx http.Context) {
} else {
out := tools.ExecShell("ufw status | grep -v '(v6)' | grep ALLOW | awk '{print $1}'")
if len(out) == 0 {
Success(ctx, nil)
Success(ctx, http.Json{
"total": 0,
"items": []map[string]string{},
})
return
}
var rules []map[string]string