feat: 支持编辑失败状态下的 Fail2ban 配置 (#3322)

pull/3324/head
ssongliu 12 months ago committed by GitHub
parent e8d3b5fe93
commit 18cbcb7f13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -39,12 +39,16 @@ func (u *Fail2BanService) LoadBaseInfo() (dto.Fail2BanBaseInfo, error) {
baseInfo.IsEnable, baseInfo.IsActive, baseInfo.IsExist = client.Status()
if !baseInfo.IsActive {
baseInfo.Version = "-"
return baseInfo, nil
} else {
baseInfo.Version = client.Version()
}
baseInfo.Version = client.Version()
conf, err := os.ReadFile(defaultFail2BanPath)
if err != nil {
return baseInfo, fmt.Errorf("read fail2ban conf of %s failed, err: %v", defaultFail2BanPath, err)
if baseInfo.IsActive {
return baseInfo, fmt.Errorf("read fail2ban conf of %s failed, err: %v", defaultFail2BanPath, err)
} else {
return baseInfo, nil
}
}
lines := strings.Split(string(conf), "\n")

@ -40,17 +40,14 @@
</div>
<div v-if="form.isExist">
<el-card v-if="!form.isActive" class="mask-prompt">
<span>{{ $t('toolbox.fail2ban.unActive') }}</span>
</el-card>
<LayoutContent title="Fail2ban" :divider="true" :class="{ mask: !form.isActive }">
<LayoutContent title="Fail2ban" :divider="true">
<template #toolbar>
<el-row>
<el-col :span="16">
<el-button type="primary" plain @click="onLoadList('ignore')">
<el-button :disabled="!form.isActive" type="primary" plain @click="onLoadList('ignore')">
{{ $t('toolbox.fail2ban.ignoreIP') }}
</el-button>
<el-button type="primary" plain @click="onLoadList('banned')">
<el-button :disabled="!form.isActive" type="primary" plain @click="onLoadList('banned')">
{{ $t('toolbox.fail2ban.bannedIP') }}
</el-button>
</el-col>

Loading…
Cancel
Save