Browse Source

fix: 解决 UFW 防火墙列表解析错误的问题 (#5724)

pull/5730/head
ssongliu 5 months ago committed by GitHub
parent
commit
d01e34aa40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      backend/utils/firewall/client/ufw.go
  2. 18
      frontend/src/views/toolbox/clam/setting/index.vue

5
backend/utils/firewall/client/ufw.go

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

18
frontend/src/views/toolbox/clam/setting/index.vue

@ -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) => {
loading.value = true;
const search = async (itemName?: string) => {
if (itemName) {
tail.value = itemName.indexOf('-log') === -1 ? 0 : 200;
activeName.value = itemName;
}
loading.value = true;
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;

Loading…
Cancel
Save