mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-11-18 23:03:55 +08:00
feat: add domain validate for appinstall webUI (#8939)
Refs https://github.com/1Panel-dev/1Panel/issues/8936
This commit is contained in:
parent
349c97f06f
commit
721e370ad3
1 changed files with 31 additions and 2 deletions
|
|
@ -130,8 +130,8 @@ import { getAppInstallParams, updateAppInstallParams, updateInstallConfig } from
|
|||
import { reactive, ref } from 'vue';
|
||||
import { FormInstance } from 'element-plus';
|
||||
import { Rules, checkNumberRange } from '@/global/form-rules';
|
||||
import { MsgSuccess } from '@/utils/message';
|
||||
import { getLabel, splitHttp } from '@/utils/util';
|
||||
import { MsgError, MsgSuccess } from '@/utils/message';
|
||||
import { getLabel, splitHttp, checkIpV4V6, checkDomain } from '@/utils/util';
|
||||
import i18n from '@/lang';
|
||||
|
||||
interface ParamProps {
|
||||
|
|
@ -176,6 +176,31 @@ const webUI = reactive({
|
|||
domain: '',
|
||||
});
|
||||
|
||||
function checkWebUI() {
|
||||
if (webUI.domain !== '') {
|
||||
let domain = webUI.domain;
|
||||
let port = null;
|
||||
if (domain.includes(':')) {
|
||||
const parts = domain.split(':');
|
||||
domain = parts[0];
|
||||
port = parts[1];
|
||||
|
||||
if (!checkPort(port)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (checkIpV4V6(domain) && checkDomain(domain)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkPort(port: string) {
|
||||
const portNum = parseInt(port, 10);
|
||||
return !isNaN(portNum) && portNum > 0 && portNum <= 65535;
|
||||
}
|
||||
|
||||
const acceptParams = async (props: ParamProps) => {
|
||||
submitModel.value.installId = props.id;
|
||||
params.value = [];
|
||||
|
|
@ -297,6 +322,10 @@ const updateAppConfig = async () => {
|
|||
if (!webUI.domain || webUI.domain === '') {
|
||||
req.webUI = '';
|
||||
}
|
||||
if (!checkWebUI()) {
|
||||
MsgError(i18n.global.t('commons.rule.host'));
|
||||
return;
|
||||
}
|
||||
await updateInstallConfig(req);
|
||||
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
|
||||
handleClose();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue