fix: 解决防火墙筛选失效的问题 (#5677)

This commit is contained in:
ssongliu 2024-07-04 16:04:33 +08:00 committed by GitHub
parent 08125b150a
commit 9a38dcd2a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 8 deletions

View File

@ -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)
}
}

View File

@ -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],

View File

@ -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,

View File

@ -44,12 +44,7 @@
<el-table-column type="selection" fix />
<el-table-column :label="$t('commons.table.protocol')" :min-width="70" prop="protocol" />
<el-table-column :label="$t('firewall.sourcePort')" :min-width="70" prop="port" />
<el-table-column :min-width="80" :label="$t('firewall.targetIP')" prop="targetIP">
<template #default="{ row }">
<span v-if="row.targetIP">{{ row.targetIP }}</span>
<span v-else>127.0.0.1</span>
</template>
</el-table-column>
<el-table-column :min-width="80" :label="$t('firewall.targetIP')" prop="targetIP" />
<el-table-column :label="$t('firewall.targetPort')" :min-width="70" prop="targetPort" />
<fu-table-operations
width="200px"