mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-09-13 18:15:31 +08:00
parent
a1311a2a0d
commit
acbb151b15
2 changed files with 15 additions and 12 deletions
|
@ -83,6 +83,7 @@
|
||||||
<el-option :label="$t('commons.status.waiting')" value="Waiting" />
|
<el-option :label="$t('commons.status.waiting')" value="Waiting" />
|
||||||
<el-option :label="$t('commons.status.failed')" value="Failed" />
|
<el-option :label="$t('commons.status.failed')" value="Failed" />
|
||||||
</el-select>
|
</el-select>
|
||||||
|
<TableRefresh @search="search(false)" />
|
||||||
</template>
|
</template>
|
||||||
<template #main>
|
<template #main>
|
||||||
<div class="mainClass">
|
<div class="mainClass">
|
||||||
|
|
|
@ -20,7 +20,7 @@ import i18n from '@/lang';
|
||||||
import { MsgSuccess } from '@/utils/message';
|
import { MsgSuccess } from '@/utils/message';
|
||||||
import { updateSetting } from '@/api/modules/setting';
|
import { updateSetting } from '@/api/modules/setting';
|
||||||
import { ElMessageBox, FormInstance } from 'element-plus';
|
import { ElMessageBox, FormInstance } from 'element-plus';
|
||||||
import { checkCidr, checkIpV4V6 } from '@/utils/util';
|
import { checkCidr, checkCidrV6, checkIpV4V6 } from '@/utils/util';
|
||||||
|
|
||||||
const emit = defineEmits<{ (e: 'search'): void }>();
|
const emit = defineEmits<{ (e: 'search'): void }>();
|
||||||
|
|
||||||
|
@ -28,26 +28,28 @@ const form = reactive({
|
||||||
allowIPs: '',
|
allowIPs: '',
|
||||||
});
|
});
|
||||||
const rules = reactive({
|
const rules = reactive({
|
||||||
allowIPs: [{ validator: checkAddress, trigger: 'blur' }],
|
allowIPs: [{ validator: checkIPs, trigger: 'blur' }],
|
||||||
});
|
});
|
||||||
function checkAddress(rule: any, value: any, callback: any) {
|
function checkIPs(rule: any, value: any, callback: any) {
|
||||||
if (form.allowIPs !== '') {
|
if (typeof value === 'string' && value.trim() !== '') {
|
||||||
let addrs = form.allowIPs.split('\n');
|
let addr = value.split('\n');
|
||||||
for (const item of addrs) {
|
for (const item of addr) {
|
||||||
if (item === '') {
|
if (item === '') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (item === '0.0.0.0') {
|
if (item === '0.0.0.0' || item === '::') {
|
||||||
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
||||||
}
|
}
|
||||||
if (item.indexOf('/') !== -1) {
|
if (item.indexOf('/') !== -1) {
|
||||||
if (checkCidr(item)) {
|
if (item.indexOf(':') !== -1) {
|
||||||
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
if (checkCidrV6(item)) {
|
||||||
}
|
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
||||||
} else {
|
}
|
||||||
if (checkIpV4V6(item)) {
|
} else if (checkCidr(item)) {
|
||||||
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
||||||
}
|
}
|
||||||
|
} else if (checkIpV4V6(item)) {
|
||||||
|
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue