diff --git a/backend/app/service/firewall.go b/backend/app/service/firewall.go
index fe6f948c5..cef2fab59 100644
--- a/backend/app/service/firewall.go
+++ b/backend/app/service/firewall.go
@@ -96,7 +96,10 @@ func (u *FirewallService) SearchWithPage(req dto.RuleSearch) (int64, interface{}
if len(req.Info) != 0 {
for _, addr := range rules {
- if strings.Contains(addr.Address, req.Info) {
+ if strings.Contains(addr.Address, req.Info) ||
+ strings.Contains(addr.Port, req.Info) ||
+ strings.Contains(addr.TargetPort, req.Info) ||
+ strings.Contains(addr.TargetIP, req.Info) {
datas = append(datas, addr)
}
}
diff --git a/backend/utils/firewall/client/firewalld.go b/backend/utils/firewall/client/firewalld.go
index 84fa4e016..61e084c51 100644
--- a/backend/utils/firewall/client/firewalld.go
+++ b/backend/utils/firewall/client/firewalld.go
@@ -129,6 +129,12 @@ func (f *Firewall) ListForward() ([]FireInfo, error) {
})
if ForwardListRegex.MatchString(line) {
match := ForwardListRegex.FindStringSubmatch(line)
+ if len(match) < 4 {
+ continue
+ }
+ if len(match[4]) == 0 {
+ match[4] = "127.0.0.1"
+ }
datas = append(datas, FireInfo{
Port: match[1],
Protocol: match[2],
diff --git a/backend/utils/firewall/client/ufw.go b/backend/utils/firewall/client/ufw.go
index 86e3f4554..678a9afa0 100644
--- a/backend/utils/firewall/client/ufw.go
+++ b/backend/utils/firewall/client/ufw.go
@@ -115,7 +115,13 @@ func (f *Ufw) ListForward() ([]FireInfo, error) {
var list []FireInfo
for _, rule := range rules {
- dest := strings.SplitN(rule.DestPort, ":", 2)
+ dest := strings.Split(rule.DestPort, ":")
+ if len(dest) < 2 {
+ continue
+ }
+ if len(dest[0]) == 0 {
+ dest[0] = "127.0.0.1"
+ }
list = append(list, FireInfo{
Num: rule.Num,
Protocol: rule.Protocol,
diff --git a/frontend/src/views/host/firewall/forward/index.vue b/frontend/src/views/host/firewall/forward/index.vue
index 69b1443e0..9bde10fba 100644
--- a/frontend/src/views/host/firewall/forward/index.vue
+++ b/frontend/src/views/host/firewall/forward/index.vue
@@ -44,12 +44,7 @@
-
-
- {{ row.targetIP }}
- 127.0.0.1
-
-
+