Skip to content

Commit 8c19272

Browse files
feat: add OpenResty version restriction for TCP/UDP proxy
1 parent 15bc6cf commit 8c19272

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

agent/init/db/db.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func Init() {
1515
global.GPUMonitorDB = common.LoadDBConnByPath(path.Join(global.Dir.DbDir, "gpu_monitor.db"), "gpu_monitor")
1616
global.AlertDB = common.LoadDBConnByPath(path.Join(global.Dir.DbDir, "alert.db"), "alert")
1717

18-
if _, err := os.Stat("/usr/bin/1panel-core"); err == nil {
18+
if _, err := os.Stat(path.Join(global.Dir.DbDir, "core.db")); err == nil {
1919
global.CoreDB = common.LoadDBConnByPath(path.Join(global.Dir.DbDir, "core.db"), "core")
2020
}
2121
}

frontend/src/views/website/website/create/index.vue

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
</el-radio-button>
1818
</el-radio-group>
1919
</el-form-item>
20-
<SSLAlert :websiteType="website.type" class="mb-2" />
20+
<SSLAlert :websiteType="website.type" class="mb-2" :versionNotMatch="versionNotMatch" />
21+
2122
<GroupSelect
2223
v-model="website.webSiteGroupId"
2324
:prop="'webSiteGroupId'"
@@ -389,7 +390,11 @@
389390
</div>
390391
<template #footer>
391392
<el-button @click="handleClose" :disabled="loading">{{ $t('commons.button.cancel') }}</el-button>
392-
<el-button type="primary" @click="submit(websiteForm)" :disabled="loading">
393+
<el-button
394+
type="primary"
395+
@click="submit(websiteForm)"
396+
:disabled="loading || (website.type == 'stream' && versionNotMatch)"
397+
>
393398
{{ $t('commons.button.confirm') }}
394399
</el-button>
395400
</template>
@@ -437,6 +442,7 @@ import { getAccountName } from '@/utils/util';
437442
import { Website } from '@/api/interface/website';
438443
import { getPathByType } from '@/api/modules/files';
439444
import { getWebsiteTypes } from '@/global/mimetype';
445+
import { compareVersion } from '@/utils/version';
440446
441447
type SSLItem = Website.SSLDTO & {
442448
organization?: string;
@@ -572,6 +578,7 @@ const runtimePorts = ref([]);
572578
const WebsiteTypes = getWebsiteTypes();
573579
const installFormRef = ref();
574580
const lbFormRef = ref();
581+
const versionNotMatch = ref();
575582
const steamConfig = ref({
576583
name: '',
577584
algorithm: 'default',
@@ -719,7 +726,11 @@ const getRuntimes = async () => {
719726
} catch (error) {}
720727
};
721728
722-
const acceptParams = async () => {
729+
const acceptParams = async (openrestyVersion: string) => {
730+
versionNotMatch.value = false;
731+
if (!compareVersion(openrestyVersion, '1.27.1.2-3-3-focal')) {
732+
versionNotMatch.value = true;
733+
}
723734
website.value = initData();
724735
if (websiteForm.value) {
725736
websiteForm.value.resetFields();

frontend/src/views/website/website/create/site-alert/index.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@
2525
:closable="false"
2626
/>
2727
<el-alert v-if="websiteType == 'subsite'" :title="$t('website.subsiteHelper')" type="info" :closable="false" />
28-
<el-alert v-if="websiteType == 'stream'" :title="$t('website.streamHelper')" type="info" :closable="false" />
28+
<el-alert
29+
v-if="websiteType == 'stream'"
30+
:title="
31+
versionNotMatch ? $t('xpack.waf.openRestyAlert', ['1.27.1.2-2-3-focal']) : $t('website.streamHelper')
32+
"
33+
:type="versionNotMatch ? 'error' : 'info'"
34+
:closable="false"
35+
/>
2936
</div>
3037
</template>
3138

@@ -35,5 +42,9 @@ defineProps({
3542
type: String,
3643
default: 'deployment',
3744
},
45+
versionNotMatch: {
46+
type: Boolean,
47+
default: false,
48+
},
3849
});
3950
</script>

frontend/src/views/website/website/index.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ const taskLogRef = ref();
346346
const opRef = ref();
347347
const batchSetGroupRef = ref();
348348
const batchSetHttpsRef = ref();
349+
const nginxVersion = ref();
349350
350351
const paginationConfig = reactive({
351352
cacheSizeKey: 'website-page-size',
@@ -568,7 +569,7 @@ const openDelete = (website: Website.Website) => {
568569
};
569570
570571
const openCreate = () => {
571-
createRef.value.acceptParams();
572+
createRef.value.acceptParams(nginxVersion.value);
572573
};
573574
574575
const openGroup = () => {
@@ -588,6 +589,7 @@ const checkExist = (data: App.CheckInstalled) => {
588589
containerName.value = data.containerName;
589590
nginxStatus.value = data.status;
590591
websiteDir.value = data.websiteDir;
592+
nginxVersion.value = data.version;
591593
};
592594
593595
const checkDate = (date: Date) => {

0 commit comments

Comments
 (0)