mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-02-07 17:10:07 +08:00
feat: 防火墙操作支持 ipv6 网段 (#6415)
This commit is contained in:
parent
466617847f
commit
ab825a1a70
@ -347,6 +347,19 @@ export function checkCidr(value: string): boolean {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export function checkCidrV6(value: string): boolean {
|
||||||
|
if (value === '') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (checkIpV6(value.split('/')[0])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
const reg = /^(?:[1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])$/;
|
||||||
|
if (!reg.test(value.split('/')[1])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
export function checkPort(value: string): boolean {
|
export function checkPort(value: string): boolean {
|
||||||
if (Number(value) <= 0) {
|
if (Number(value) <= 0) {
|
||||||
|
@ -59,7 +59,7 @@ import DrawerHeader from '@/components/drawer-header/index.vue';
|
|||||||
import { MsgSuccess } from '@/utils/message';
|
import { MsgSuccess } from '@/utils/message';
|
||||||
import { Host } from '@/api/interface/host';
|
import { Host } from '@/api/interface/host';
|
||||||
import { operateForwardRule } from '@/api/modules/host';
|
import { operateForwardRule } from '@/api/modules/host';
|
||||||
import { checkCidr, checkIp, checkPort, deepCopy } from '@/utils/util';
|
import { checkCidr, checkCidrV6, checkIp, checkPort, deepCopy } from '@/utils/util';
|
||||||
|
|
||||||
const loading = ref();
|
const loading = ref();
|
||||||
const oldRule = ref<Host.RuleForward>();
|
const oldRule = ref<Host.RuleForward>();
|
||||||
@ -111,9 +111,15 @@ function checkAddress(rule: any, value: string, callback: any) {
|
|||||||
let addrs = value.split(',');
|
let addrs = value.split(',');
|
||||||
for (const item of addrs) {
|
for (const item of addrs) {
|
||||||
if (item.indexOf('/') !== -1) {
|
if (item.indexOf('/') !== -1) {
|
||||||
|
if (item.indexOf(':') !== -1) {
|
||||||
|
if (checkCidrV6(item)) {
|
||||||
|
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (checkCidr(item)) {
|
if (checkCidr(item)) {
|
||||||
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (checkIp(item)) {
|
if (checkIp(item)) {
|
||||||
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
||||||
|
@ -56,7 +56,7 @@ import DrawerHeader from '@/components/drawer-header/index.vue';
|
|||||||
import { MsgSuccess } from '@/utils/message';
|
import { MsgSuccess } from '@/utils/message';
|
||||||
import { Host } from '@/api/interface/host';
|
import { Host } from '@/api/interface/host';
|
||||||
import { operateIPRule, updateAddrRule } from '@/api/modules/host';
|
import { operateIPRule, updateAddrRule } from '@/api/modules/host';
|
||||||
import { checkCidr, checkIpV4V6, deepCopy } from '@/utils/util';
|
import { checkCidr, checkCidrV6, checkIpV4V6, deepCopy } from '@/utils/util';
|
||||||
|
|
||||||
const loading = ref();
|
const loading = ref();
|
||||||
const oldRule = ref<Host.RuleIP>();
|
const oldRule = ref<Host.RuleIP>();
|
||||||
@ -95,9 +95,15 @@ function checkAddress(rule: any, value: any, callback: any) {
|
|||||||
let addrs = dialogData.value.rowData.address.split(',');
|
let addrs = dialogData.value.rowData.address.split(',');
|
||||||
for (const item of addrs) {
|
for (const item of addrs) {
|
||||||
if (item.indexOf('/') !== -1) {
|
if (item.indexOf('/') !== -1) {
|
||||||
|
if (item.indexOf(':') !== -1) {
|
||||||
|
if (checkCidrV6(item)) {
|
||||||
|
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (checkCidr(item)) {
|
if (checkCidr(item)) {
|
||||||
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (checkIpV4V6(item)) {
|
if (checkIpV4V6(item)) {
|
||||||
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
||||||
|
@ -81,7 +81,7 @@ import DrawerHeader from '@/components/drawer-header/index.vue';
|
|||||||
import { MsgError, MsgSuccess } from '@/utils/message';
|
import { MsgError, MsgSuccess } from '@/utils/message';
|
||||||
import { Host } from '@/api/interface/host';
|
import { Host } from '@/api/interface/host';
|
||||||
import { operatePortRule, updatePortRule } from '@/api/modules/host';
|
import { operatePortRule, updatePortRule } from '@/api/modules/host';
|
||||||
import { checkCidr, checkIpV4V6, checkPort, deepCopy } from '@/utils/util';
|
import { checkCidr, checkCidrV6, checkIpV4V6, checkPort, deepCopy } from '@/utils/util';
|
||||||
|
|
||||||
const loading = ref();
|
const loading = ref();
|
||||||
const oldRule = ref<Host.RulePort>();
|
const oldRule = ref<Host.RulePort>();
|
||||||
@ -128,9 +128,15 @@ function checkAddress(rule: any, value: any, callback: any) {
|
|||||||
let addrs = dialogData.value.rowData.address.split(',');
|
let addrs = dialogData.value.rowData.address.split(',');
|
||||||
for (const item of addrs) {
|
for (const item of addrs) {
|
||||||
if (item.indexOf('/') !== -1) {
|
if (item.indexOf('/') !== -1) {
|
||||||
|
if (item.indexOf(':') !== -1) {
|
||||||
|
if (checkCidrV6(item)) {
|
||||||
|
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (checkCidr(item)) {
|
if (checkCidr(item)) {
|
||||||
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (checkIpV4V6(item)) {
|
if (checkIpV4V6(item)) {
|
||||||
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user