mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-18 22:22:59 +08:00
style: 修改WAF规则添加方式
This commit is contained in:
parent
b406ee1f10
commit
2ca45d31e8
@ -78,7 +78,6 @@ type DNSParam struct {
|
||||
}
|
||||
|
||||
func (c *AcmeClient) UseDns(dnsType DnsType, params string) error {
|
||||
|
||||
var param DNSParam
|
||||
if err := json.Unmarshal([]byte(params), ¶m); err != nil {
|
||||
return err
|
||||
@ -148,7 +147,6 @@ func (c *AcmeClient) UseHTTP(path string) error {
|
||||
}
|
||||
|
||||
func (c *AcmeClient) ObtainSSL(domains []string) (certificate.Resource, error) {
|
||||
|
||||
request := certificate.ObtainRequest{
|
||||
Domains: domains,
|
||||
Bundle: true,
|
||||
@ -163,7 +161,6 @@ func (c *AcmeClient) ObtainSSL(domains []string) (certificate.Resource, error) {
|
||||
}
|
||||
|
||||
func (c *AcmeClient) RenewSSL(certUrl string) (certificate.Resource, error) {
|
||||
|
||||
certificates, err := c.Client.Certificate.Get(certUrl, true)
|
||||
if err != nil {
|
||||
return certificate.Resource{}, err
|
||||
|
@ -116,6 +116,7 @@ export default {
|
||||
selectHelper: '请选择正确的 {0} 文件',
|
||||
domain: '域名格式错误',
|
||||
databaseName: '支持英文、数字、_,长度1-30',
|
||||
ipErr: 'IP [{0}] 格式错误,请检查',
|
||||
},
|
||||
res: {
|
||||
paramError: '请求失败,请稍后重试!',
|
||||
@ -942,6 +943,10 @@ export default {
|
||||
notSecurity: ' 不安全',
|
||||
encryptHelper:
|
||||
"Let's Encrypt 签发证书有频率限制,但足以满足正常需求,过于频繁操作会导致签发失败。具体限制请看 <a target=“_blank” href='https://letsencrypt.org/zh-cn/docs/rate-limits/'>官方文档</a> ",
|
||||
ipValue: 'IP值',
|
||||
ext: '文件扩展名',
|
||||
wafInputHelper: '按行输入数据,一行一个',
|
||||
data: '数据',
|
||||
},
|
||||
nginx: {
|
||||
serverNamesHashBucketSizeHelper: '服务器名字的hash表大小',
|
||||
|
@ -70,9 +70,11 @@
|
||||
<el-divider content-position="left">{{ $t('website.SSLProConfig') }}</el-divider>
|
||||
<el-form-item :label="$t('website.supportProtocol')" prop="SSLProtocol">
|
||||
<el-checkbox-group v-model="form.SSLProtocol">
|
||||
<el-checkbox :label="'TLSv1.3'">{{ 'TLS 1.3' }}</el-checkbox>
|
||||
<el-checkbox :label="'TLSv1.2'">{{ 'TLS 1.2' }}</el-checkbox>
|
||||
<el-checkbox :label="'TLSv1.1'">{{ 'TLS 1.1' }}</el-checkbox>
|
||||
<el-checkbox :label="'TLSv1'">{{ 'TLS 1.0' }}</el-checkbox>
|
||||
<br />
|
||||
<el-checkbox :label="'SSLv3'">
|
||||
{{ 'SSL V3' + $t('website.notSecurity') }}
|
||||
</el-checkbox>
|
||||
@ -134,7 +136,7 @@ let form = reactive({
|
||||
httpConfig: 'HTTPToHTTPS',
|
||||
algorithm:
|
||||
'EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5',
|
||||
SSLProtocol: ['TLSv1.2', 'TLSv1.1', 'TLSv1'],
|
||||
SSLProtocol: ['TLSv1.3', 'TLSv1.2', 'TLSv1.1', 'TLSv1'],
|
||||
});
|
||||
let loading = ref(false);
|
||||
const ssls = ref();
|
||||
|
@ -4,21 +4,21 @@
|
||||
<el-form-item prop="enable" :label="$t('website.enable')">
|
||||
<el-switch v-model="enableUpdate.enable" @change="updateEnable"></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('website.ext')">
|
||||
<el-input
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 4, maxRows: 8 }"
|
||||
v-model="exts"
|
||||
:placeholder="$t('website.wafInputHelper')"
|
||||
/>
|
||||
</el-form-item>
|
||||
<ComplexTable :data="data" v-loading="loading">
|
||||
<template #toolbar>
|
||||
<el-button type="primary" icon="Plus" @click="openCreate">
|
||||
{{ $t('commons.button.add') }}
|
||||
</el-button>
|
||||
</template>
|
||||
<el-table-column :label="$t('website.fileExt')">
|
||||
<template #default="{ row }">
|
||||
<fu-read-write-switch :data="row.file" v-model="row.edit" write-trigger="onDblclick">
|
||||
<el-form-item :error="row.error">
|
||||
<el-input v-model="row.file" @blur="row.edit = false" />
|
||||
</el-form-item>
|
||||
</fu-read-write-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('website.fileExt')" prop="file"></el-table-column>
|
||||
<el-table-column :label="$t('commons.table.operate')">
|
||||
<template #default="{ $index }">
|
||||
<el-button link type="primary" @click="remove($index)">
|
||||
@ -27,12 +27,6 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</ComplexTable>
|
||||
<br />
|
||||
<el-alert :title="$t('website.mustSave')" type="info" :closable="false"></el-alert>
|
||||
<br />
|
||||
<el-button type="primary" :loading="loading" @click="submit">
|
||||
{{ $t('commons.button.save') }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
@ -71,6 +65,7 @@ let enableUpdate = ref<Website.WafUpdate>({
|
||||
key: '$fileExtDeny',
|
||||
enable: false,
|
||||
});
|
||||
let exts = ref();
|
||||
|
||||
const get = async () => {
|
||||
data.value = [];
|
||||
@ -80,11 +75,9 @@ const get = async () => {
|
||||
|
||||
if (res.data.content != '') {
|
||||
const ipList = JSON.parse(res.data.content);
|
||||
ipList.forEach((value) => {
|
||||
ipList.forEach((value: string) => {
|
||||
data.value.push({
|
||||
file: value,
|
||||
eidt: false,
|
||||
error: '',
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -95,24 +88,30 @@ const get = async () => {
|
||||
|
||||
const remove = (index: number) => {
|
||||
data.value.splice(index, 1);
|
||||
const extArray = [];
|
||||
data.value.forEach((d) => {
|
||||
extArray.push(d.file);
|
||||
});
|
||||
submit(extArray);
|
||||
};
|
||||
|
||||
const openCreate = () => {
|
||||
data.value.unshift({ file: '', edit: true, error: '' });
|
||||
const extArray = exts.value.split('\n');
|
||||
if (extArray.length === 0) {
|
||||
return;
|
||||
}
|
||||
data.value.forEach((d) => {
|
||||
extArray.push(d.file);
|
||||
});
|
||||
submit(extArray);
|
||||
};
|
||||
|
||||
const submit = async () => {
|
||||
let fileArray = [];
|
||||
data.value.forEach((row) => {
|
||||
if (row.file != '') {
|
||||
fileArray.push(row.file);
|
||||
}
|
||||
});
|
||||
|
||||
fileUpdate.content = JSON.stringify(fileArray);
|
||||
const submit = async (extArray: string[]) => {
|
||||
fileUpdate.content = JSON.stringify(extArray);
|
||||
loading.value = true;
|
||||
SaveFileContent(fileUpdate)
|
||||
.then(() => {
|
||||
exts.value = '';
|
||||
ElMessage.success(i18n.global.t('commons.msg.updateSuccess'));
|
||||
get();
|
||||
})
|
||||
|
@ -4,21 +4,21 @@
|
||||
<el-form-item prop="enable" :label="$t('website.enable')">
|
||||
<el-switch v-model="enableUpdate.enable" @change="updateEnable"></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('website.ipValue')">
|
||||
<el-input
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 4, maxRows: 8 }"
|
||||
v-model="ips"
|
||||
:placeholder="$t('website.wafInputHelper')"
|
||||
/>
|
||||
</el-form-item>
|
||||
<ComplexTable :data="data" v-loading="loading">
|
||||
<template #toolbar>
|
||||
<el-button type="primary" icon="Plus" @click="openCreate">
|
||||
{{ $t('commons.button.add') }}
|
||||
</el-button>
|
||||
</template>
|
||||
<el-table-column label="IP" prop="ip">
|
||||
<template #default="{ row }">
|
||||
<fu-read-write-switch :data="row.ip" v-model="row.edit" write-trigger="onDblclick">
|
||||
<el-form-item :error="row.error">
|
||||
<el-input v-model="row.ip" @blur="row.edit = false" @input="checkIpRule(row)" />
|
||||
</el-form-item>
|
||||
</fu-read-write-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="IP" prop="ip"></el-table-column>
|
||||
<el-table-column :label="$t('commons.table.operate')">
|
||||
<template #default="{ $index }">
|
||||
<el-button link type="primary" @click="removeIp($index)">
|
||||
@ -27,12 +27,6 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</ComplexTable>
|
||||
<br />
|
||||
<el-alert :title="$t('website.mustSave')" type="info" :closable="false"></el-alert>
|
||||
<br />
|
||||
<el-button type="primary" :loading="loading" @click="submit">
|
||||
{{ $t('commons.button.save') }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
@ -86,6 +80,7 @@ let enableUpdate = ref<Website.WafUpdate>({
|
||||
key: '$ipWhiteAllow',
|
||||
enable: false,
|
||||
});
|
||||
let ips = ref();
|
||||
|
||||
const get = async () => {
|
||||
data.value = [];
|
||||
@ -95,11 +90,9 @@ const get = async () => {
|
||||
|
||||
if (res.data.content != '') {
|
||||
const ipList = JSON.parse(res.data.content);
|
||||
ipList.forEach((value) => {
|
||||
ipList.forEach((ip: string) => {
|
||||
data.value.push({
|
||||
ip: value,
|
||||
eidt: false,
|
||||
error: '',
|
||||
ip: ip,
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -109,32 +102,39 @@ const get = async () => {
|
||||
|
||||
const removeIp = (index: number) => {
|
||||
data.value.splice(index, 1);
|
||||
let ipArray = [];
|
||||
data.value.forEach((d) => {
|
||||
ipArray.push(d.ip);
|
||||
});
|
||||
submit(ipArray);
|
||||
};
|
||||
|
||||
const openCreate = () => {
|
||||
data.value.unshift({ ip: '', edit: true, error: '' });
|
||||
};
|
||||
|
||||
const submit = async () => {
|
||||
let canCommit = true;
|
||||
for (const row of data.value) {
|
||||
if (row.ip != '' && row.error != '') {
|
||||
row.edit = true;
|
||||
canCommit = false;
|
||||
}
|
||||
}
|
||||
if (!canCommit) {
|
||||
console.log(ips.value);
|
||||
const ipArray = ips.value.split('\n');
|
||||
if (ipArray.length == 0) {
|
||||
return;
|
||||
}
|
||||
let ipArray = [];
|
||||
data.value.forEach((row) => {
|
||||
ipArray.push(row.ip);
|
||||
});
|
||||
for (const id in ipArray) {
|
||||
if (checkIp(ipArray[id])) {
|
||||
ElMessage.error(i18n.global.t('commons.rule.ipErr', [ipArray[id]]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fileUpdate.content = JSON.stringify(ipArray);
|
||||
data.value.forEach((d) => {
|
||||
ipArray.push(d.ip);
|
||||
});
|
||||
submit(ipArray);
|
||||
};
|
||||
|
||||
const submit = async (ipList: string[]) => {
|
||||
fileUpdate.content = JSON.stringify(ipList);
|
||||
loading.value = true;
|
||||
SaveFileContent(fileUpdate)
|
||||
.then(() => {
|
||||
ips.value = '';
|
||||
get();
|
||||
ElMessage.success(i18n.global.t('commons.msg.updateSuccess'));
|
||||
})
|
||||
.finally(() => {
|
||||
@ -149,14 +149,6 @@ const updateEnable = async (enable: boolean) => {
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
const checkIpRule = (row: any) => {
|
||||
if (checkIp(row.ip)) {
|
||||
row.error = i18n.global.t('commons.rule.ip');
|
||||
} else {
|
||||
row.error = '';
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
req.value.websiteId = id.value;
|
||||
req.value.rule = rule.value;
|
||||
|
@ -4,26 +4,21 @@
|
||||
<el-form-item prop="enable" :label="$t('website.enable')">
|
||||
<el-switch v-model="enableUpdate.enable" @change="updateEnable"></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('website.data')">
|
||||
<el-input
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 4, maxRows: 8 }"
|
||||
v-model="add"
|
||||
:placeholder="$t('website.wafInputHelper')"
|
||||
/>
|
||||
</el-form-item>
|
||||
<ComplexTable :data="data" v-loading="loading">
|
||||
<template #toolbar>
|
||||
<el-button type="primary" icon="Plus" @click="openCreate">
|
||||
{{ $t('commons.button.add') }}
|
||||
</el-button>
|
||||
</template>
|
||||
<el-table-column :label="$t('website.value')">
|
||||
<template #default="{ row }">
|
||||
<fu-read-write-switch :data="row.value" v-model="row.edit" write-trigger="onDblclick">
|
||||
<el-form-item :error="row.error">
|
||||
<el-input
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 2, maxRows: 8 }"
|
||||
v-model="row.value"
|
||||
@blur="row.edit = false"
|
||||
/>
|
||||
</el-form-item>
|
||||
</fu-read-write-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('website.value')" prop="value"></el-table-column>
|
||||
<el-table-column :label="$t('commons.table.operate')" width="100px">
|
||||
<template #default="{ $index }">
|
||||
<el-button link type="primary" @click="remove($index)">
|
||||
@ -32,12 +27,6 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</ComplexTable>
|
||||
<br />
|
||||
<el-alert :title="$t('website.mustSave')" type="info" :closable="false"></el-alert>
|
||||
<br />
|
||||
<el-button type="primary" :loading="loading" @click="submit">
|
||||
{{ $t('commons.button.save') }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
@ -90,6 +79,7 @@ let enableUpdate = ref<Website.WafUpdate>({
|
||||
key: '$UrlDeny',
|
||||
enable: false,
|
||||
});
|
||||
let add = ref();
|
||||
|
||||
const get = async () => {
|
||||
data.value = [];
|
||||
@ -103,22 +93,31 @@ const get = async () => {
|
||||
if (value != '') {
|
||||
data.value.push({
|
||||
value: value,
|
||||
eidt: false,
|
||||
error: '',
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fileUpdate.path = res.data.filePath;
|
||||
};
|
||||
|
||||
const remove = (index: number) => {
|
||||
data.value.splice(index, 1);
|
||||
const addArray = [];
|
||||
data.value.forEach((d) => {
|
||||
addArray.push(d.value);
|
||||
});
|
||||
submit(addArray);
|
||||
};
|
||||
|
||||
const openCreate = () => {
|
||||
data.value.unshift({ value: '', edit: true, error: '' });
|
||||
const addArray = add.value.split('\n');
|
||||
if (addArray.length == 0) {
|
||||
return;
|
||||
}
|
||||
data.value.forEach((d) => {
|
||||
addArray.push(d.value);
|
||||
});
|
||||
submit(addArray);
|
||||
};
|
||||
|
||||
const updateEnable = async (enable: boolean) => {
|
||||
@ -128,18 +127,17 @@ const updateEnable = async (enable: boolean) => {
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
const submit = async () => {
|
||||
const submit = async (addArray: string[]) => {
|
||||
let urlList = '';
|
||||
data.value.forEach((row) => {
|
||||
if (row.value != '') {
|
||||
urlList = urlList + row.value + '\n';
|
||||
}
|
||||
addArray.forEach((row) => {
|
||||
urlList = urlList + row + '\n';
|
||||
});
|
||||
|
||||
fileUpdate.content = urlList;
|
||||
loading.value = true;
|
||||
SaveFileContent(fileUpdate)
|
||||
.then(() => {
|
||||
add.value = '';
|
||||
ElMessage.success(i18n.global.t('commons.msg.updateSuccess'));
|
||||
get();
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user