1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-03-14 01:34:47 +08:00

fix: 防火墙端口校验规则修改 (#560)

This commit is contained in:
ssongliu 2023-04-10 14:46:22 +08:00 committed by GitHub
parent 47d090d481
commit 2bd289defa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -168,6 +168,9 @@ export function checkIp(value: string): boolean {
} }
export function checkPort(value: string): boolean { export function checkPort(value: string): boolean {
if (Number(value) <= 0) {
return true;
}
const reg = /^([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5])$/; const reg = /^([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5])$/;
if (!reg.test(value) && value !== '') { if (!reg.test(value) && value !== '') {
return true; return true;

View File

@ -123,9 +123,12 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
dialogData.value.rowData.address = ''; dialogData.value.rowData.address = '';
} }
let ports = []; let ports = [];
if (dialogData.value.rowData.port.indexOf('-') !== -1) { if (dialogData.value.rowData.port.indexOf('-') !== -1 && !dialogData.value.rowData.port.startsWith('-')) {
ports = dialogData.value.rowData.port.split('-'); ports = dialogData.value.rowData.port.split('-');
} else if (dialogData.value.rowData.port.indexOf(',') !== -1) { } else if (
dialogData.value.rowData.port.indexOf(',') !== -1 &&
!dialogData.value.rowData.port.startsWith(',')
) {
ports = dialogData.value.rowData.port.split(','); ports = dialogData.value.rowData.port.split(',');
} else { } else {
ports.push(dialogData.value.rowData.port); ports.push(dialogData.value.rowData.port);