From 1abb9691f43d9e0cefeb0ea71a9771c1dc6e8e2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Fri, 4 Aug 2023 00:33:27 +0800 Subject: [PATCH] fix(safe): null rule --- README.md | 4 ++++ app/http/controllers/safe_controller.go | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a572c25b..e6c27278 100644 --- a/README.md +++ b/README.md @@ -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/) diff --git a/app/http/controllers/safe_controller.go b/app/http/controllers/safe_controller.go index c11c8d52..53c8a4a8 100644 --- a/app/http/controllers/safe_controller.go +++ b/app/http/controllers/safe_controller.go @@ -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