fix: 解决 UFW 防火墙列表解析错误的问题 (#5724)
Some checks failed
Build Test / build-linux-binary (push) Failing after -6m20s
Build / SonarCloud (push) Failing after -6m22s
sync2gitee / repo-sync (push) Failing after -6m24s

This commit is contained in:
ssongliu 2024-07-09 11:35:23 +08:00 committed by GitHub
parent 02e7c2e974
commit d01e34aa40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 11 deletions

View file

@ -223,7 +223,7 @@ func (f *Ufw) RichRules(rule FireInfo, operation string) error {
stdout, err := cmd.Exec(ruleStr)
if err != nil {
if strings.Contains(stdout, "ERROR: Invalid position") {
if strings.Contains(stdout, "ERROR: Invalid position") || strings.Contains(stdout, "ERROR: 无效位置") {
stdout, err := cmd.Exec(strings.ReplaceAll(ruleStr, "insert 1 ", ""))
if err != nil {
return fmt.Errorf("%s rich rules (%s), failed, err: %s", operation, ruleStr, stdout)
@ -270,6 +270,9 @@ func (f *Ufw) loadInfo(line string, fireType string) FireInfo {
itemInfo.Strategy = "accept"
}
if fields[1] == "(v6)" {
if fields[2] == "ALLOW" {
itemInfo.Strategy = "accept"
}
itemInfo.Address = fields[4]
} else {
itemInfo.Address = fields[3]

View file

@ -29,12 +29,7 @@
<template #main>
<div>
<el-select
v-if="!canUpdate()"
style="width: 20%"
@change="search(activeName)"
v-model.number="tail"
>
<el-select v-if="!canUpdate()" style="width: 20%" @change="search()" v-model.number="tail">
<template #prefix>{{ $t('toolbox.clam.tail') }}</template>
<el-option :value="0" :label="$t('commons.table.all')" />
<el-option :value="10" :label="10" />
@ -89,7 +84,7 @@ const handleReady = (payload) => {
};
const activeName = ref('clamd');
const tail = ref(0);
const tail = ref(200);
const content = ref();
const confirmRef = ref();
@ -105,9 +100,12 @@ const canUpdate = () => {
return activeName.value.indexOf('-log') === -1;
};
const search = async (itemName: string) => {
const search = async (itemName?: string) => {
if (itemName) {
tail.value = itemName.indexOf('-log') === -1 ? 0 : 200;
activeName.value = itemName;
}
loading.value = true;
activeName.value = itemName;
await searchClamFile(activeName.value, tail.value + '')
.then((res) => {
loading.value = false;
@ -140,7 +138,7 @@ const onSubmit = async () => {
.then(() => {
loading.value = false;
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
search(activeName.value);
search();
})
.catch(() => {
loading.value = false;