域名解析
This commit is contained in:
@@ -10,12 +10,12 @@
|
||||
<!-- <el-select v-model="listQuery.protocal" placeholder="请选择协议" clearable style="margin-right:10px;width: 120px;">
|
||||
<el-option v-for="item in protocalList" :key="item.name" :label="item.name" :value="item.name" :disabled="!item.enable" />
|
||||
</el-select> -->
|
||||
<el-input v-model="listQuery.domain" type="text" style="width:145px;margin-right:10px" class="filter-item" placeholder="请输入域名关键词" :maxlength="5" show-word-limit />
|
||||
<el-input v-model="listQuery.domain" type="text" style="width:145px;margin-right:10px" class="filter-item" placeholder="请输入域名关键词" />
|
||||
<el-select v-model="listQuery.isOnline" placeholder="请选择在线状态" clearable style="width:145px;margin-right:10px">
|
||||
<el-option v-for="item in selectObj.onlineOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
<el-option v-for="(value, key) in onlineOptions" :key="key" :label="value" :value="key" />
|
||||
</el-select>
|
||||
<el-select v-model="listQuery.enable" placeholder="请选择启用状态" clearable style="width:145px;margin-right:10px">
|
||||
<el-option v-for="item in selectObj.statusOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
<el-option v-for="(value, key) in statusOptions" :key="key" :label="value" :value="key" />
|
||||
</el-select>
|
||||
<el-input v-model="listQuery.description" type="text" style="width:145px;margin-right:10px" class="filter-item" placeholder="请输入描述详情" show-word-limit />
|
||||
<el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">{{
|
||||
@@ -54,7 +54,6 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.serverPort')" width="80">
|
||||
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.serverPort }}</span>
|
||||
</template>
|
||||
@@ -92,19 +91,19 @@
|
||||
<el-table-column class-name="status-col" :label="$t('table.enableStatus')" width="100">
|
||||
|
||||
<template slot-scope="scope">
|
||||
<el-tag :type="scope.row.enable | statusFilter">{{ scope.row.enable | statusName }}</el-tag>
|
||||
<el-tag :type="colorOption[scope.row.enable]">{{ statusOptions[scope.row.enable] }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column class-name="status-col" :label="$t('table.isOnline')" width="100">
|
||||
|
||||
<template slot-scope="scope">
|
||||
<el-tag :type="scope.row.isOnline | statusFilter">{{ scope.row.isOnline | isOnlineName }}</el-tag>
|
||||
<el-tag :type="colorOption[scope.row.isOnline]">{{ onlineOptions[scope.row.isOnline] }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column class-name="status-col" :label="$t('table.access')" width="120">
|
||||
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" v-if="(scope.row.protocal === 'HTTP' || scope.row.protocal === 'HTTP(S)')" @click="handleOpenWebPage(scope.row)">{{ $t('table.openWebPage') }}</el-button>
|
||||
<el-button size="mini" @click="handleOpenWebPage(scope.row)">{{ $t('table.openWebPage') }}</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.actions')" width="320" class-name="small-padding fixed-width">
|
||||
@@ -113,8 +112,7 @@
|
||||
<el-button type="primary" size="mini" @click="handleUpdate(scope.row)">{{ $t('table.edit') }}</el-button>
|
||||
<el-button v-if="scope.row.enable == '1'" size="mini" type="danger" @click="handleModifyStatus(scope.row, 2)">{{ $t('table.disable') }}</el-button>
|
||||
<el-button v-if="scope.row.enable == '2'" size="mini" type="success" @click="handleModifyStatus(scope.row, 1)">{{ $t('table.enable') }}</el-button>
|
||||
<!-- <el-button size="mini" type="danger" @click="handleDelete(scope.row,'deleted')">{{$t('table.delete')}}</el-button>-->
|
||||
<ButtonPopover @handleCommitClick="handleDelete2(scope.row)" style="margin-left: 10px" />
|
||||
<ButtonPopover @handleCommitClick="handleDelete(scope.row)" style="margin-left: 10px" />
|
||||
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -128,58 +126,21 @@
|
||||
|
||||
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
|
||||
<el-form :rules="rules" ref="dataForm" :model="temp" label-position="left" label-width="120px" style='width: 400px; margin-left:50px;'>
|
||||
<!-- <el-form-item :label="$t('License')" prop="licenseId">-->
|
||||
<!-- <el-select style="width: 280px;" class="filter-item" v-model="temp.licenseId" placeholder="请选择" :disabled="dialogStatus=='update'">-->
|
||||
<!-- <el-option v-for="item in licenseList" :key="item.id" :label="item.name" :value="item.id">-->
|
||||
<!-- </el-option>-->
|
||||
<!-- </el-select>-->
|
||||
<!-- </el-form-item>-->
|
||||
|
||||
<el-form-item :label="$t('License')" prop="licenseId">
|
||||
<DropdownTable v-model="temp.licenseId" :name.sync="temp.licenseName" :tableData="licenseAuthList" @selectedData="selectedFeeItem" placeholder="请选择" :width="280"
|
||||
:disabled="dialogStatus === 'update'" />
|
||||
<!-- <DropdownTable
|
||||
:columns="countryColumns"
|
||||
:data="licenseList"
|
||||
v-model="temp.licenseId"
|
||||
:value="temp.licenseName"
|
||||
@rowClick="selectedFeeItem"
|
||||
disabled
|
||||
:disabled="dialogStatus==='update'"
|
||||
style="width: 280px"
|
||||
/>-->
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('协议')" prop="protocal">
|
||||
<el-select style="width: 280px;" class="filter-item" v-model="temp.protocal" placeholder="请选择">
|
||||
<el-option v-for="item in protocalList" :key="item.name" :label="item.name" :value="item.name" :disabled="!item.enable">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-form-item :label="$t('域名')" prop="domain">
|
||||
<el-input v-model="temp.domain">
|
||||
<template slot="prepend">http(s):</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('服务端端口')" prop="serverPort">
|
||||
<load-select style="width: 280px;" class="filter-item" v-model="temp.serverPort" :data="serverPortList" :page="loadServerPortQuery.page" :hasMore="more" :clearable="false"
|
||||
:dictLabel="'port'" :dictValue="'port'" :request="loadServerPort" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('客户端IP')" prop="clientIp">
|
||||
<el-input v-model="temp.clientIp"></el-input>
|
||||
<el-form-item :label="$t('目标地址')" prop="targetPath">
|
||||
<el-input v-model="temp.targetPath"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('客户端端口')" prop="clientPort">
|
||||
<el-input v-model="temp.clientPort"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('域名')" prop="subdomain" v-if="(temp.protocal === 'HTTP' || temp.protocal === 'HTTP(S)') && domainName && domainName != ''">
|
||||
<el-input v-model="temp.subdomain">
|
||||
|
||||
<template slot="append">.{{ domainName }}</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('响应数量')" prop="proxyResponses" v-if="temp.protocal === 'UDP'">
|
||||
<el-input v-model="temp.proxyResponses"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('超时时间')" prop="proxyTimeoutMs" v-if="temp.protocal === 'UDP'">
|
||||
<el-input v-model="temp.proxyTimeoutMs">
|
||||
|
||||
<template slot="append">毫秒</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('table.securityGroup')" prop="securityGroup">
|
||||
<el-select style="width: 280px;" class="filter-item" v-model="temp.securityGroupId" clearable>
|
||||
<el-option v-for="item in securityGroupList" :key="item.id" :label="item.name" :value="item.id">
|
||||
@@ -223,38 +184,20 @@ import { fetchList, createUserPortMapping, updateUserPortMapping, updateEnableSt
|
||||
import { fetchGroupList } from '@/api/securityGroup'
|
||||
import { availablePortList, portAvailable } from '@/api/portPool'
|
||||
import { licenseList, licenseAuthList } from '@/api/license'
|
||||
import { protocalList } from '@/api/protocal'
|
||||
import { userList } from '@/api/user'
|
||||
import { domainNameBindInfo } from '@/api/domain'
|
||||
import waves from '@/directive/waves' // 水波纹指令
|
||||
import { parseTime } from '@/utils'
|
||||
import ButtonPopover from '../../components/Button/buttonPopover'
|
||||
import DropdownTable from '../../components/Dropdown/DropdownTable'
|
||||
// 下拉选择加载组件
|
||||
import loadSelect from "@/components/Select/SelectLoadMore";
|
||||
|
||||
const calendarTypeOptions = [
|
||||
{ key: 'CN', display_name: 'China' },
|
||||
{ key: 'US', display_name: 'USA' },
|
||||
{ key: 'JP', display_name: 'Japan' },
|
||||
{ key: 'EU', display_name: 'Eurozone' }
|
||||
]
|
||||
|
||||
// arr to obj ,such as { CN : "China", US : "USA" }
|
||||
const calendarTypeKeyValue = calendarTypeOptions.reduce((acc, cur) => {
|
||||
acc[cur.key] = cur.display_name
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
export default {
|
||||
name: 'complexTable',
|
||||
name: 'DmainMaping',
|
||||
directives: {
|
||||
waves
|
||||
},
|
||||
components: {
|
||||
DropdownTable,
|
||||
ButtonPopover,
|
||||
loadSelect
|
||||
ButtonPopover
|
||||
},
|
||||
data() {
|
||||
const isPortAvailable = (rule, value, callback) => {
|
||||
@@ -278,7 +221,6 @@ export default {
|
||||
current: 1,
|
||||
size: 10,
|
||||
domain: null,
|
||||
importance: undefined,
|
||||
title: undefined,
|
||||
type: undefined,
|
||||
userId: undefined,
|
||||
@@ -287,33 +229,32 @@ export default {
|
||||
isOnline: undefined,
|
||||
enable: undefined,
|
||||
description: undefined
|
||||
|
||||
},
|
||||
importanceOptions: [1, 2, 3],
|
||||
calendarTypeOptions,
|
||||
sortOptions: [{ label: 'ID Ascending', key: '+id' }, { label: 'ID Descending', key: '-id' }],
|
||||
statusOptions: ['published', 'draft', 'deleted'],
|
||||
userList: [],
|
||||
licenseList: [],
|
||||
protocalList: [],
|
||||
licenseAuthList: [],
|
||||
serverPortList: [],
|
||||
domainName: '',
|
||||
showReviewer: false,
|
||||
temp: {
|
||||
id: undefined,
|
||||
licenseId: undefined,
|
||||
licenseName: undefined,
|
||||
serverPort: undefined,
|
||||
clientIp: undefined,
|
||||
clientPort: undefined,
|
||||
protocal: undefined,
|
||||
proxyResponses: undefined,
|
||||
proxyTimeoutMs: undefined
|
||||
},
|
||||
selectObj: {
|
||||
statusOptions: [{ label: '启用', value: 1 }, { label: '禁用', value: 2 }],
|
||||
onlineOptions: [{ label: '在线', value: 1 }, { label: '离线', value: 2 }]
|
||||
statusOptions: {
|
||||
1: '启用',
|
||||
2: '禁用',
|
||||
},
|
||||
onlineOptions: {
|
||||
1: '在线',
|
||||
2: '离线'
|
||||
},
|
||||
colorOption: {
|
||||
1: 'success',
|
||||
2: 'danger'
|
||||
},
|
||||
dialogFormVisible: false,
|
||||
dialogStatus: '',
|
||||
@@ -330,54 +271,18 @@ export default {
|
||||
],
|
||||
clientIp: [{ required: true, message: '请输入客户端IP', trigger: 'blur' }],
|
||||
clientPort: [{ required: true, message: '请输入客户端端口', trigger: 'blur' }],
|
||||
protocal: [{ required: true, message: '请选择协议', trigger: 'blur' }]
|
||||
},
|
||||
downloadLoading: false,
|
||||
countryColumns: [
|
||||
{ prop: 'userName', label: '用户名', align: 'center' },
|
||||
{ prop: 'name', label: 'License', align: 'center' }
|
||||
],
|
||||
loadServerPortQuery: { //下拉框加载数据请求参数
|
||||
page: 1,
|
||||
size: 50,
|
||||
licenseId: null,
|
||||
},
|
||||
more: true,
|
||||
securityGroupList: []
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
statusName(status) {
|
||||
const statusMap = {
|
||||
1: '启用',
|
||||
2: '禁用'
|
||||
}
|
||||
return statusMap[status]
|
||||
},
|
||||
isOnlineName(isOnline) {
|
||||
const isOnlineMap = {
|
||||
1: '在线',
|
||||
2: '离线'
|
||||
}
|
||||
return isOnlineMap[isOnline]
|
||||
},
|
||||
statusFilter(status) {
|
||||
const statusMap = {
|
||||
1: 'success',
|
||||
2: 'danger'
|
||||
}
|
||||
return statusMap[status]
|
||||
},
|
||||
typeFilter(type) {
|
||||
return calendarTypeKeyValue[type]
|
||||
}
|
||||
},
|
||||
// filters: {
|
||||
// },
|
||||
created() {
|
||||
this.getDomainNameBindInfo()
|
||||
this.getDataList()
|
||||
this.getLicenseList()
|
||||
this.getLicenseAuthList()
|
||||
this.getProtocalList()
|
||||
this.fetchSecurityGroupList()
|
||||
},
|
||||
methods: {
|
||||
@@ -412,10 +317,6 @@ export default {
|
||||
this.domainName = response.data.data
|
||||
})
|
||||
},
|
||||
getAvailablePortList(licenseId) {
|
||||
this.loadServerPortQuery.licenseId = licenseId;
|
||||
this.serverPortList = []; //清掉数据
|
||||
},
|
||||
getAllUserList() {
|
||||
userList().then(response => {
|
||||
this.userList = response.data.data
|
||||
@@ -426,11 +327,6 @@ export default {
|
||||
this.licenseList = response.data.data
|
||||
})
|
||||
},
|
||||
getProtocalList() {
|
||||
protocalList().then(response => {
|
||||
this.protocalList = response.data.data
|
||||
})
|
||||
},
|
||||
getLicenseAuthList() {
|
||||
licenseAuthList().then(response => {
|
||||
this.licenseAuthList = response.data.data
|
||||
@@ -465,15 +361,12 @@ export default {
|
||||
id: undefined,
|
||||
licenseId: undefined,
|
||||
licenseName: undefined,
|
||||
serverPort: undefined,
|
||||
clientIp: '127.0.0.1',
|
||||
clientPort: undefined,
|
||||
userId: undefined,
|
||||
proxyResponses: undefined,
|
||||
proxyTimeoutMs: undefined
|
||||
}
|
||||
this.serverPortList = []
|
||||
this.loadServerPortQuery.licenseId = null;
|
||||
this.more = true;
|
||||
},
|
||||
handleCreate() {
|
||||
@@ -502,36 +395,12 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
handleOpenWebPage(row) {
|
||||
let url = location.protocol + '//' + location.hostname + ':' + row.serverPort
|
||||
if (row.domain) {
|
||||
url = location.protocol + '//' + row.domain
|
||||
}
|
||||
open(url)
|
||||
},
|
||||
handleUpdate(row) {
|
||||
this.temp = Object.assign({}, row) // copy obj
|
||||
if (row.securityGroupId === 0) {
|
||||
this.temp.securityGroupId = null
|
||||
}
|
||||
this.temp.timestamp = new Date(this.temp.timestamp)
|
||||
this.dialogStatus = 'update'
|
||||
this.dialogFormVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].clearValidate()
|
||||
})
|
||||
this.getAvailablePortList(row.licenseId)
|
||||
},
|
||||
updateData() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
const tempData = Object.assign({}, this.temp)
|
||||
updateUserPortMapping(tempData).then(response => {
|
||||
if (response.data.code === 0) {
|
||||
// this.$message({
|
||||
// message: '操作成功',
|
||||
// type: 'success'
|
||||
// })
|
||||
this.$notify({
|
||||
title: '成功',
|
||||
message: '更新成功',
|
||||
@@ -545,11 +414,25 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
handleOpenWebPage(row) {
|
||||
open(location.protocol + '//' + row.domain)
|
||||
},
|
||||
handleUpdate(row) {
|
||||
this.temp = Object.assign({}, row) // copy obj
|
||||
if (row.securityGroupId === 0) {
|
||||
this.temp.securityGroupId = null
|
||||
}
|
||||
this.temp.timestamp = new Date(this.temp.timestamp)
|
||||
this.dialogStatus = 'update'
|
||||
this.dialogFormVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].clearValidate()
|
||||
})
|
||||
},
|
||||
selectedFeeItem(row, list) {
|
||||
if (this.temp.licenseId !== row.id) {
|
||||
this.temp.licenseId = row.id
|
||||
this.temp.licenseName = row.name
|
||||
this.getAvailablePortList(row.id)
|
||||
this.temp.serverPort = null
|
||||
}
|
||||
},
|
||||
@@ -572,68 +455,6 @@ export default {
|
||||
})
|
||||
}).catch(() => { })
|
||||
},
|
||||
handleDelete2(row) {
|
||||
deletePortMapping(row.id).then(response => {
|
||||
if (response.data.code === 0) {
|
||||
this.$notify({
|
||||
title: '成功',
|
||||
message: '删除成功',
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
},
|
||||
handleDownload() {
|
||||
this.downloadLoading = true
|
||||
import('@/vendor/Export2Excel').then(excel => {
|
||||
const tHeader = ['timestamp', 'title', 'type', 'importance', 'status']
|
||||
const filterVal = ['timestamp', 'title', 'type', 'importance', 'status']
|
||||
const data = this.formatJson(filterVal, this.list)
|
||||
excel.export_json_to_excel(tHeader, data, 'table-list')
|
||||
this.downloadLoading = false
|
||||
})
|
||||
},
|
||||
formatJson(filterVal, jsonData) {
|
||||
return jsonData.map(v => filterVal.map(j => {
|
||||
if (j === 'timestamp') {
|
||||
return parseTime(v[j])
|
||||
} else {
|
||||
return v[j]
|
||||
}
|
||||
}))
|
||||
},
|
||||
// 传入给load-select组件的函数
|
||||
loadServerPort({ page = 1, more = false, keyword = "" } = {}) {
|
||||
if (this.loadServerPortQuery.licenseId == null || this.loadServerPortQuery.licenseId == '') {
|
||||
this.more = false;
|
||||
this.$message({
|
||||
message: '请先选择License',
|
||||
type: 'warning'
|
||||
})
|
||||
return;
|
||||
}
|
||||
return new Promise(resolve => {
|
||||
this.loadServerPortQuery.page = page;
|
||||
this.loadServerPortQuery.keyword = keyword;
|
||||
// 访问后端接口API
|
||||
availablePortList(this.loadServerPortQuery).then(res => {
|
||||
let result = res.data;
|
||||
if (more) {
|
||||
this.serverPortList = [...this.serverPortList, ...result.data.records];
|
||||
} else {
|
||||
this.serverPortList = result.data.records;
|
||||
}
|
||||
|
||||
// this.loadServerPortQuery.page = result.data.current;
|
||||
let { total, current, size } = result.data;
|
||||
this.more = page * size < total;
|
||||
this.loadServerPortQuery.page = current;
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -105,9 +105,7 @@
|
||||
<el-button type="primary" size="mini" @click="handleUpdate(scope.row)">{{ $t('table.edit') }}</el-button>
|
||||
<el-button v-if="scope.row.enable == '1'" size="mini" type="danger" @click="handleModifyStatus(scope.row, 2)">{{$t('table.disable')}}</el-button>
|
||||
<el-button v-if="scope.row.enable == '2'" size="mini" type="success" @click="handleModifyStatus(scope.row, 1)">{{ $t('table.enable') }}</el-button>
|
||||
<!-- <el-button size="mini" type="danger" @click="handleDelete(scope.row,'deleted')">{{$t('table.delete')}}</el-button>-->
|
||||
<ButtonPopover @handleCommitClick="handleDelete2(scope.row)" style="margin-left: 10px" />
|
||||
|
||||
<ButtonPopover @handleCommitClick="handleDelete(scope.row)" style="margin-left: 10px" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -122,26 +120,9 @@
|
||||
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
|
||||
<el-form :rules="rules" ref="dataForm" :model="temp" label-position="left" label-width="120px"
|
||||
style='width: 400px; margin-left:50px;'>
|
||||
<!-- <el-form-item :label="$t('License')" prop="licenseId">-->
|
||||
<!-- <el-select style="width: 280px;" class="filter-item" v-model="temp.licenseId" placeholder="请选择" :disabled="dialogStatus=='update'">-->
|
||||
<!-- <el-option v-for="item in licenseList" :key="item.id" :label="item.name" :value="item.id">-->
|
||||
<!-- </el-option>-->
|
||||
<!-- </el-select>-->
|
||||
<!-- </el-form-item>-->
|
||||
|
||||
<el-form-item :label="$t('License')" prop="licenseId">
|
||||
<DropdownTable v-model="temp.licenseId" :name.sync="temp.licenseName" :tableData="licenseAuthList"
|
||||
@selectedData="selectedFeeItem" placeholder="请选择" :width="280" :disabled="dialogStatus === 'update'" />
|
||||
<!-- <DropdownTable
|
||||
:columns="countryColumns"
|
||||
:data="licenseList"
|
||||
v-model="temp.licenseId"
|
||||
:value="temp.licenseName"
|
||||
@rowClick="selectedFeeItem"
|
||||
disabled
|
||||
:disabled="dialogStatus==='update'"
|
||||
style="width: 280px"
|
||||
/>-->
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('协议')" prop="protocal">
|
||||
<el-select style="width: 280px;" class="filter-item" v-model="temp.protocal" placeholder="请选择">
|
||||
@@ -232,20 +213,6 @@ import ButtonPopover from '../../components/Button/buttonPopover'
|
||||
import DropdownTable from '../../components/Dropdown/DropdownTable'
|
||||
// 下拉选择加载组件
|
||||
import loadSelect from "@/components/Select/SelectLoadMore";
|
||||
|
||||
const calendarTypeOptions = [
|
||||
{ key: 'CN', display_name: 'China' },
|
||||
{ key: 'US', display_name: 'USA' },
|
||||
{ key: 'JP', display_name: 'Japan' },
|
||||
{ key: 'EU', display_name: 'Eurozone' }
|
||||
]
|
||||
|
||||
// arr to obj ,such as { CN : "China", US : "USA" }
|
||||
const calendarTypeKeyValue = calendarTypeOptions.reduce((acc, cur) => {
|
||||
acc[cur.key] = cur.display_name
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
export default {
|
||||
name: 'complexTable',
|
||||
directives: {
|
||||
@@ -277,7 +244,6 @@ export default {
|
||||
listQuery: {
|
||||
current: 1,
|
||||
size: 10,
|
||||
importance: undefined,
|
||||
title: undefined,
|
||||
type: undefined,
|
||||
userId: undefined,
|
||||
@@ -288,7 +254,6 @@ export default {
|
||||
description: undefined
|
||||
|
||||
},
|
||||
importanceOptions: [1, 2, 3],
|
||||
calendarTypeOptions,
|
||||
sortOptions: [{ label: 'ID Ascending', key: '+id' }, { label: 'ID Descending', key: '-id' }],
|
||||
statusOptions: ['published', 'draft', 'deleted'],
|
||||
@@ -367,9 +332,6 @@ export default {
|
||||
}
|
||||
return statusMap[status]
|
||||
},
|
||||
typeFilter(type) {
|
||||
return calendarTypeKeyValue[type]
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getDomainNameBindInfo()
|
||||
@@ -571,29 +533,6 @@ export default {
|
||||
})
|
||||
}).catch(() => { })
|
||||
},
|
||||
handleDelete2(row) {
|
||||
deletePortMapping(row.id).then(response => {
|
||||
if (response.data.code === 0) {
|
||||
this.$notify({
|
||||
title: '成功',
|
||||
message: '删除成功',
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
},
|
||||
handleDownload() {
|
||||
this.downloadLoading = true
|
||||
import('@/vendor/Export2Excel').then(excel => {
|
||||
const tHeader = ['timestamp', 'title', 'type', 'importance', 'status']
|
||||
const filterVal = ['timestamp', 'title', 'type', 'importance', 'status']
|
||||
const data = this.formatJson(filterVal, this.list)
|
||||
excel.export_json_to_excel(tHeader, data, 'table-list')
|
||||
this.downloadLoading = false
|
||||
})
|
||||
},
|
||||
formatJson(filterVal, jsonData) {
|
||||
return jsonData.map(v => filterVal.map(j => {
|
||||
if (j === 'timestamp') {
|
||||
|
||||
+11
-40
@@ -37,44 +37,22 @@ public class DomainController {
|
||||
|
||||
@Get
|
||||
@Mapping("/page")
|
||||
public PageInfo<PortMappingListRes> page(PageQuery pageQuery, PortMappingListReq req) {
|
||||
public PageInfo<DomainMappingDto> page(PageQuery pageQuery, DomainMappingDto req) {
|
||||
ParamCheckUtil.checkNotNull(pageQuery, "pageQuery");
|
||||
return domainMappingService.page(pageQuery, req);
|
||||
}
|
||||
|
||||
@Post
|
||||
@Mapping("/modify")
|
||||
public PortMappingCreateRes create(PortMappingCreateReq req) {
|
||||
ParamCheckUtil.checkNotNull(req, "req");
|
||||
ParamCheckUtil.checkNotNull(req.getLicenseId(), "licenseId");
|
||||
ParamCheckUtil.checkNotNull(req.getServerPort(), "serverPort");
|
||||
ParamCheckUtil.checkNotNull(req.getClientPort(), "clientPort");
|
||||
ParamCheckUtil.checkNotEmpty(req.getProtocal(), "protocal");
|
||||
ParamCheckUtil.checkMaxLength(req.getDescription(), 50, "描述", "50");
|
||||
ParamCheckUtil.checkBytesDesc(req.getUpLimitRate(), "upLimitRate");
|
||||
ParamCheckUtil.checkBytesDesc(req.getDownLimitRate(), "downLimitRate");
|
||||
if (StringUtils.isBlank(req.getClientIp())) {
|
||||
// 没传客户端ip,默认为127.0.0.1
|
||||
req.setClientIp("127.0.0.1");
|
||||
}
|
||||
NetworkProtocolEnum networkProtocolEnum = NetworkProtocolEnum.of(req.getProtocal());
|
||||
ParamCheckUtil.checkNotNull(networkProtocolEnum, ExceptionConstant.AN_UNSUPPORTED_PROTOCOL, req.getProtocal());
|
||||
if (networkProtocolEnum != NetworkProtocolEnum.HTTP) {
|
||||
// 目前仅HTTP支持绑定域名
|
||||
req.setSubdomain(null);
|
||||
}
|
||||
req.setProtocal(networkProtocolEnum.getDesc());
|
||||
if (null == req.getProxyResponses()) {
|
||||
req.setProxyResponses(0);
|
||||
}
|
||||
if (null == req.getProxyTimeoutMs()) {
|
||||
req.setProxyTimeoutMs(0L);
|
||||
public PortMappingCreateRes modify(DomainMappingDto req) {
|
||||
if (StringUtils.isBlank(req.getTargetPath())) {// targetPath,默认为127.0.0.1
|
||||
req.setTargetPath("127.0.0.1");
|
||||
}
|
||||
req.setProtocal(NetworkProtocolEnum.HTTP.getDesc());
|
||||
if (null == req.getSecurityGroupId()) {
|
||||
req.setSecurityGroupId(0);
|
||||
}
|
||||
|
||||
return domainMappingService.create(req);
|
||||
return domainMappingService.modify(req);
|
||||
}
|
||||
|
||||
@Get
|
||||
@@ -86,20 +64,13 @@ public class DomainController {
|
||||
@Post
|
||||
@Mapping("/update/enable-status")
|
||||
public PortMappingUpdateEnableStatusRes updateEnableStatus(PortMappingUpdateEnableStatusReq req) {
|
||||
ParamCheckUtil.checkNotNull(req, "req");
|
||||
ParamCheckUtil.checkNotNull(req.getId(), "id");
|
||||
ParamCheckUtil.checkNotNull(req.getEnable(), "enable");
|
||||
|
||||
return domainMappingService.updateEnableStatus(req);
|
||||
}
|
||||
|
||||
@Post
|
||||
@Mapping("/delete")
|
||||
public void delete(PortMappingDeleteReq req) {
|
||||
ParamCheckUtil.checkNotNull(req, "req");
|
||||
ParamCheckUtil.checkNotNull(req.getId(), "id");
|
||||
|
||||
domainMappingService.delete(req.getId());
|
||||
@Mapping("/delete/{id}")
|
||||
public void delete(Integer id) {
|
||||
domainMappingService.delete(id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,7 +80,7 @@ public class DomainController {
|
||||
@Post
|
||||
@Mapping("/bind/security-group")
|
||||
public void bindSecurityGroup(PortMappingBindSecurityGroupReq req) {
|
||||
domainMappingService.portBindSecurityGroup(req.getId(), req.getSecurityGroupId());
|
||||
domainMappingService.domainBindSecurityGroup(req.getId(), req.getSecurityGroupId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,7 +90,7 @@ public class DomainController {
|
||||
@Post
|
||||
@Mapping("/unbind/security-group")
|
||||
public void unbindSecurityGroup(Integer id) {
|
||||
domainMappingService.portUnbindSecurityGroup(id);
|
||||
domainMappingService.domainUnbindSecurityGroup(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
@@ -22,6 +22,7 @@
|
||||
package org.dromara.neutrinoproxy.server.controller.req.proxy;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
||||
/**
|
||||
* 端口映射更新启用状态请求
|
||||
@@ -34,10 +35,12 @@ public class PortMappingUpdateEnableStatusReq {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@NonNull
|
||||
private Integer id;
|
||||
/**
|
||||
* 启用状态
|
||||
*/
|
||||
@NonNull
|
||||
private Integer enable;
|
||||
|
||||
}
|
||||
|
||||
+6
-28
@@ -10,6 +10,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.proxy.PortMappingListReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.proxy.DomainMappingDto;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.DomainMappingDO;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.DomainMappingDO;
|
||||
|
||||
@@ -64,9 +65,9 @@ public interface DomainMappingMapper extends BaseMapper<DomainMappingDO> {
|
||||
);
|
||||
}
|
||||
|
||||
default List<DomainMappingDO> findListByServerPort(Integer serverPort) {
|
||||
default List<DomainMappingDO> findListByServerPort(String domain) {
|
||||
return this.selectList(new LambdaQueryWrapper<DomainMappingDO>()
|
||||
.eq(DomainMappingDO::getServerPort, serverPort)
|
||||
.eq(DomainMappingDO::getDomain, domain)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -76,37 +77,14 @@ public interface DomainMappingMapper extends BaseMapper<DomainMappingDO> {
|
||||
);
|
||||
}
|
||||
|
||||
default DomainMappingDO findByLicenseIdAndServerPort(Integer licenseId, Integer serverPort) {
|
||||
default DomainMappingDO findByLicenseIdAndServerPort(Integer licenseId, String domain) {
|
||||
return this.selectOne(new LambdaQueryWrapper<DomainMappingDO>()
|
||||
.eq(DomainMappingDO::getLicenseId, licenseId)
|
||||
.eq(DomainMappingDO::getServerPort, serverPort)
|
||||
.eq(DomainMappingDO::getDomain, domain)
|
||||
.last("limit 1")
|
||||
);
|
||||
}
|
||||
|
||||
default void updateOnlineStatus(Integer licenseId,Integer serverPort, Integer isOnline, Date updateTime) {
|
||||
this.update(null, new LambdaUpdateWrapper<DomainMappingDO>()
|
||||
.eq(DomainMappingDO::getLicenseId, licenseId)
|
||||
.eq(DomainMappingDO::getServerPort, serverPort)
|
||||
.set(DomainMappingDO::getIsOnline, isOnline)
|
||||
.set(DomainMappingDO::getUpdateTime, updateTime)
|
||||
);
|
||||
}
|
||||
|
||||
default void updateOnlineStatus(Integer licenseId, Integer isOnline, Date updateTime) {
|
||||
this.update(null, new LambdaUpdateWrapper<DomainMappingDO>()
|
||||
.eq(DomainMappingDO::getLicenseId, licenseId)
|
||||
.set(DomainMappingDO::getIsOnline, isOnline)
|
||||
.set(DomainMappingDO::getUpdateTime, updateTime)
|
||||
);
|
||||
}
|
||||
|
||||
default void updateOnlineStatus(Integer isOnline, Date updateTime) {
|
||||
this.update(null, new LambdaUpdateWrapper<DomainMappingDO>()
|
||||
.set(DomainMappingDO::getIsOnline, isOnline)
|
||||
.set(DomainMappingDO::getUpdateTime, updateTime)
|
||||
);
|
||||
}
|
||||
|
||||
List<DomainMappingDO> selectDomainMappingByCondition(IPage<DomainMappingDO> page, @Param("req") PortMappingListReq req);
|
||||
List<DomainMappingDO> selectDomainMappingByCondition(IPage<DomainMappingDO> page, @Param("req") DomainMappingDto req);
|
||||
}
|
||||
|
||||
+52
-67
@@ -77,13 +77,13 @@ public class DomainMappingService implements LifecycleBean {
|
||||
/**
|
||||
* 域名 到 域名解析id的映射
|
||||
*/
|
||||
private final Cache<Integer, Integer> domainToDomainMappingIdCache = CacheUtil.newLRUCache(500, 1000 * 60 * 10);
|
||||
private final Cache<String, Integer> domainToDomainMappingIdCache = CacheUtil.newLRUCache(500, 1000 * 60 * 10);
|
||||
// 域名解析id到licenseId
|
||||
private final Cache<Integer, Integer> idToLicenseIdCache = CacheUtil.newLRUCache(500, 1000 * 60 * 10);
|
||||
// 流量限制缓存
|
||||
private final Cache<Integer, FlowLimitBO> flowLimitCache = CacheUtil.newLRUCache(500, 1000 * 60 * 5);
|
||||
|
||||
public PageInfo<DomainMappingDto> page(PageQuery pageQuery, PortMappingListReq req) {
|
||||
public PageInfo<DomainMappingDto> page(PageQuery pageQuery, DomainMappingDto req) {
|
||||
if (StringUtils.isNotEmpty(req.getDescription())) {
|
||||
//描述字段为模糊查询,在应用层处理,否则sqlite不支持
|
||||
req.setDescription("%" + req.getDescription() + "%");
|
||||
@@ -145,55 +145,42 @@ public class DomainMappingService implements LifecycleBean {
|
||||
// 临时处理,如果当前用户不是管理员,则操作userId不能为1
|
||||
ParamCheckUtil.checkExpression(!licenseDO.getUserId().equals(1), ExceptionConstant.NO_PERMISSION_VISIT);
|
||||
}
|
||||
PortPoolDO portPoolDO = portPoolMapper.findByPort(req.getDomain());
|
||||
ParamCheckUtil.checkNotNull(portPoolDO, ExceptionConstant.PORT_NOT_EXIST);
|
||||
// PortPoolDO portPoolDO = portPoolMapper.findByPort(req.getDomain());
|
||||
// ParamCheckUtil.checkNotNull(portPoolDO, ExceptionConstant.PORT_NOT_EXIST);
|
||||
ParamCheckUtil.checkExpression(null == domainMappingMapper.findByDomain(req.getDomain(), null), ExceptionConstant.PORT_CANNOT_REPEAT_MAPPING, req.getDomain());
|
||||
ParamCheckUtil.checkExpression(!domainMappingMapper.checkRepeatByDomain(req.getDomain(), null), ExceptionConstant.PORT_MAPPING_SUBDONAME_CONNOT_REPEAT);
|
||||
|
||||
Date now = new Date();
|
||||
PortMappingDO portMappingDO = ;
|
||||
portMappingDO.setLicenseId(req.getLicenseId());
|
||||
portMappingDO.setProtocal(req.getProtocal());
|
||||
portMappingDO.setSubdomain(req.getSubdomain());
|
||||
portMappingDO.setServerPort(req.getServerPort());
|
||||
portMappingDO.setClientIp(req.getClientIp());
|
||||
portMappingDO.setClientPort(req.getClientPort());
|
||||
portMappingDO.setUpLimitRate(req.getUpLimitRate());
|
||||
portMappingDO.setDownLimitRate(req.getDownLimitRate());
|
||||
portMappingDO.setProxyResponses(req.getProxyResponses());
|
||||
portMappingDO.setProxyTimeoutMs(req.getProxyTimeoutMs());
|
||||
portMappingDO.setDescription(req.getDescription());
|
||||
portMappingDO.setIsOnline(OnlineStatusEnum.OFFLINE.getStatus());
|
||||
portMappingDO.setEnable(EnableStatusEnum.ENABLE.getStatus());
|
||||
portMappingDO.setCreateTime(now);
|
||||
portMappingDO.setUpdateTime(now);
|
||||
domainMappingMapper.insert(portMappingDO);
|
||||
DomainMappingDO domainMappingDO = (DomainMappingDO) req;
|
||||
domainMappingDO.setIsOnline(OnlineStatusEnum.OFFLINE.getStatus());
|
||||
domainMappingDO.setEnable(EnableStatusEnum.ENABLE.getStatus());
|
||||
domainMappingDO.setCreateTime(now);
|
||||
domainMappingDO.setUpdateTime(now);
|
||||
domainMappingMapper.insert(domainMappingDO);
|
||||
// 更新VisitorChannel
|
||||
visitorChannelService.addVisitorChannelByPortMapping(portMappingDO);
|
||||
// visitorChannelService.addVisitorChannelByPortMapping(domainMappingDO);
|
||||
// 更新域名映射
|
||||
if (NetworkProtocolEnum.isHttp(portMappingDO.getProtocal()) && StrUtil.isNotBlank(proxyConfig.getServer().getTcp().getDomainName()) && StrUtil.isNotBlank(portMappingDO.getSubdomain())) {
|
||||
ProxyUtil.setSubdomainToServerPort(portMappingDO.getSubdomain(), portMappingDO.getServerPort());
|
||||
if (NetworkProtocolEnum.isHttp(domainMappingDO.getProtocal()) && StrUtil.isNotBlank(proxyConfig.getServer().getTcp().getDomainName()) && StrUtil.isNotBlank(domainMappingDO.getDomain())) {
|
||||
// ProxyUtil.setSubdomainToServerPort(domainMappingDO.getDomain(), domainMappingDO.getServerPort());
|
||||
}
|
||||
|
||||
updateMappingDomainToSecurityGroupMap(portMappingDO.getServerPort(), req.getSecurityGroupId());
|
||||
updateMappingDomainToSecurityGroupMap(domainMappingDO.getDomain(), req.getSecurityGroupId());
|
||||
|
||||
// 更新端口到映射的缓存
|
||||
domainToDomainMappingIdCache.put(req.getServerPort(), portMappingDO.getId());
|
||||
domainToDomainMappingIdCache.put(req.getDomain(), domainMappingDO.getId());
|
||||
// 更新端口映射到licenseId的缓存
|
||||
idToLicenseIdCache.put(portMappingDO.getId(), portMappingDO.getLicenseId());
|
||||
idToLicenseIdCache.put(domainMappingDO.getId(), domainMappingDO.getLicenseId());
|
||||
// 刷新流量限制缓存
|
||||
refreshFlowLimitCache(portMappingDO.getId(), portMappingDO.getUpLimitRate(), portMappingDO.getDownLimitRate());
|
||||
refreshFlowLimitCache(domainMappingDO.getId(), domainMappingDO.getUpLimitRate(), domainMappingDO.getDownLimitRate());
|
||||
|
||||
return new PortMappingCreateRes();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public PortMappingUpdateEnableStatusRes updateEnableStatus(PortMappingUpdateEnableStatusReq req) {
|
||||
PortMappingDO portMappingDO = domainMappingMapper.findById(req.getId());
|
||||
ParamCheckUtil.checkNotNull(portMappingDO, ExceptionConstant.PORT_MAPPING_NOT_EXIST);
|
||||
DomainMappingDO domainMappingDO = domainMappingMapper.findById(req.getId());
|
||||
ParamCheckUtil.checkNotNull(domainMappingDO, ExceptionConstant.PORT_MAPPING_NOT_EXIST);
|
||||
|
||||
LicenseDO licenseDO = licenseMapper.findById(portMappingDO.getLicenseId());
|
||||
LicenseDO licenseDO = licenseMapper.findById(domainMappingDO.getLicenseId());
|
||||
ParamCheckUtil.checkNotNull(licenseDO, ExceptionConstant.LICENSE_NOT_EXIST);
|
||||
if (!SystemContextHolder.isAdmin()) {
|
||||
ParamCheckUtil.checkExpression(!licenseDO.getUserId().equals(1), ExceptionConstant.NO_PERMISSION_VISIT);
|
||||
@@ -202,21 +189,21 @@ public class DomainMappingService implements LifecycleBean {
|
||||
domainMappingMapper.updateEnableStatus(req.getId(), req.getEnable(), new Date());
|
||||
|
||||
// 更新VisitorChannel
|
||||
portMappingDO.setEnable(req.getEnable());
|
||||
domainMappingDO.setEnable(req.getEnable());
|
||||
if (EnableStatusEnum.ENABLE == EnableStatusEnum.of(req.getEnable())) {
|
||||
visitorChannelService.addVisitorChannelByPortMapping(portMappingDO);
|
||||
// visitorChannelService.addVisitorChannelByPortMapping(domainMappingDO);
|
||||
} else {
|
||||
visitorChannelService.removeVisitorChannelByPortMapping(portMappingDO);
|
||||
// visitorChannelService.removeVisitorChannelByPortMapping(domainMappingDO);
|
||||
}
|
||||
|
||||
return new PortMappingUpdateEnableStatusRes();
|
||||
}
|
||||
|
||||
public void delete(Integer id) {
|
||||
PortMappingDO portMappingDO = domainMappingMapper.findById(id);
|
||||
ParamCheckUtil.checkNotNull(portMappingDO, ExceptionConstant.PORT_MAPPING_NOT_EXIST);
|
||||
DomainMappingDO domainMappingDO = domainMappingMapper.findById(id);
|
||||
ParamCheckUtil.checkNotNull(domainMappingDO, ExceptionConstant.PORT_MAPPING_NOT_EXIST);
|
||||
|
||||
LicenseDO licenseDO = licenseMapper.findById(portMappingDO.getLicenseId());
|
||||
LicenseDO licenseDO = licenseMapper.findById(domainMappingDO.getLicenseId());
|
||||
if (null != licenseDO && !SystemContextHolder.isAdmin()) {
|
||||
// 临时处理,如果当前用户不是管理员,则操作userId不能为1
|
||||
ParamCheckUtil.checkExpression(!licenseDO.getUserId().equals(1), ExceptionConstant.NO_PERMISSION_VISIT);
|
||||
@@ -225,13 +212,14 @@ public class DomainMappingService implements LifecycleBean {
|
||||
domainMappingMapper.deleteById(id);
|
||||
|
||||
// 更新VisitorChannel
|
||||
visitorChannelService.removeVisitorChannelByPortMapping(portMappingDO);
|
||||
// visitorChannelService.removeVisitorChannelByPortMapping(domainMappingDO);
|
||||
|
||||
// 更新域名映射
|
||||
if (NetworkProtocolEnum.isHttp(portMappingDO.getProtocal()) && StrUtil.isNotBlank(portMappingDO.getSubdomain())) {
|
||||
ProxyUtil.removeSubdomainToServerPort(portMappingDO.getSubdomain());
|
||||
if (NetworkProtocolEnum.isHttp(domainMappingDO.getProtocal()) && StrUtil.isNotBlank(domainMappingDO.getDomain())) {
|
||||
ProxyUtil.removeSubdomainToServerPort(domainMappingDO.getDomain());
|
||||
}
|
||||
|
||||
updateMappingDomainToSecurityGroupMap(portMappingDO.getServerPort(), null);
|
||||
updateMappingDomainToSecurityGroupMap(domainMappingDO.getDomain(), null);
|
||||
|
||||
// 删除id到licenseId的映射
|
||||
idToLicenseIdCache.remove(id);
|
||||
@@ -239,26 +227,26 @@ public class DomainMappingService implements LifecycleBean {
|
||||
flowLimitCache.remove(id);
|
||||
}
|
||||
|
||||
public void portBindSecurityGroup(Integer portMappingId, Integer groupId) {
|
||||
PortMappingDO mappingDO = domainMappingMapper.findById(portMappingId);
|
||||
public void domainBindSecurityGroup(Integer portMappingId, Integer groupId) {
|
||||
DomainMappingDO mappingDO = domainMappingMapper.findById(portMappingId);
|
||||
if (mappingDO == null) {
|
||||
throw new RuntimeException("指定的端口映射不存在");
|
||||
}
|
||||
mappingDO.setSecurityGroupId(groupId);
|
||||
mappingDO.setUpdateTime(new Date());
|
||||
domainMappingMapper.updateById(mappingDO);
|
||||
updateMappingDomainToSecurityGroupMap(mappingDO.getServerPort(), groupId);
|
||||
updateMappingDomainToSecurityGroupMap(mappingDO.getDomain(), groupId);
|
||||
}
|
||||
|
||||
public void portUnbindSecurityGroup(Integer portMappingId) {
|
||||
PortMappingDO mappingDO = domainMappingMapper.findById(portMappingId);
|
||||
public void domainUnbindSecurityGroup(Integer portMappingId) {
|
||||
DomainMappingDO mappingDO = domainMappingMapper.findById(portMappingId);
|
||||
if (mappingDO == null) {
|
||||
throw new RuntimeException("指定的端口映射不存在");
|
||||
}
|
||||
mappingDO.setSecurityGroupId(0);
|
||||
mappingDO.setUpdateTime(new Date());
|
||||
domainMappingMapper.updateById(mappingDO);
|
||||
updateMappingDomainToSecurityGroupMap(mappingDO.getServerPort(), null);
|
||||
updateMappingDomainToSecurityGroupMap(mappingDO.getDomain(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,7 +255,7 @@ public class DomainMappingService implements LifecycleBean {
|
||||
* @param licenseId
|
||||
* @return
|
||||
*/
|
||||
public List<PortMappingDO> findEnableListByLicenseId(Integer licenseId) {
|
||||
public List<DomainMappingDO> findEnableListByLicenseId(Integer licenseId) {
|
||||
return domainMappingMapper.findEnableListByLicenseId(licenseId);
|
||||
}
|
||||
|
||||
@@ -286,7 +274,7 @@ public class DomainMappingService implements LifecycleBean {
|
||||
return;
|
||||
}
|
||||
// 服务刚启动,所以默认所有license都是离线状态。解决服务突然关闭,在线状态来不及更新的问题
|
||||
domainMappingMapper.updateOnlineStatus(OnlineStatusEnum.OFFLINE.getStatus(), new Date());
|
||||
// domainMappingMapper.updateOnlineStatus(OnlineStatusEnum.OFFLINE.getStatus(), new Date());
|
||||
|
||||
List<DomainMappingDO> allMappingDOList = domainMappingMapper.selectList(Wrappers.lambdaQuery(DomainMappingDO.class));
|
||||
allMappingDOList.forEach(item -> {
|
||||
@@ -306,17 +294,17 @@ public class DomainMappingService implements LifecycleBean {
|
||||
if (StrUtil.isBlank(proxyConfig.getServer().getTcp().getDomainName())) {
|
||||
return;
|
||||
}
|
||||
List<PortMappingDO> portMappingDOList = allMappingDOList.stream()
|
||||
List<DomainMappingDO> portMappingDOList = allMappingDOList.stream()
|
||||
.filter(item -> NetworkProtocolEnum.HTTP.getDesc().equals(item.getProtocal()) && item.getDomain() != null)
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtil.isEmpty(portMappingDOList)) {
|
||||
return;
|
||||
}
|
||||
portMappingDOList.forEach(item -> {
|
||||
if (StrUtil.isBlank(item.getSubdomain())) {
|
||||
if (StrUtil.isBlank(item.getDomain())) {
|
||||
return;
|
||||
}
|
||||
ProxyUtil.setSubdomainToServerPort(item.getSubdomain(), item.getServerPort());
|
||||
// ProxyUtil.setSubdomainToServerPort(item.getDomain(), item.getServerPort());
|
||||
|
||||
});
|
||||
}
|
||||
@@ -354,21 +342,18 @@ public class DomainMappingService implements LifecycleBean {
|
||||
return res;
|
||||
}
|
||||
|
||||
public Integer getDomainMappingIdByServerPort(Integer serverPort) {
|
||||
if (null == serverPort) {
|
||||
return null;
|
||||
}
|
||||
Integer id = domainToDomainMappingIdCache.get(serverPort);
|
||||
public Integer getDomainMappingIdByDomain(String domain) {
|
||||
Integer id = domainToDomainMappingIdCache.get(domain);
|
||||
if (null != id) {
|
||||
return id;
|
||||
}
|
||||
List<DomainMappingDO> domainMappingDOList = domainMappingMapper.findListByServerPort(serverPort);
|
||||
List<DomainMappingDO> domainMappingDOList = domainMappingMapper.findListByServerPort(domain);
|
||||
// 不存在 或者 有多条记录,都不处理
|
||||
if (CollectionUtils.isEmpty(domainMappingDOList) || domainMappingDOList.size() > 1) {
|
||||
return null;
|
||||
}
|
||||
id = domainMappingDOList.get(0).getId();
|
||||
domainToDomainMappingIdCache.put(serverPort, id);
|
||||
domainToDomainMappingIdCache.put(domain, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -384,8 +369,8 @@ public class DomainMappingService implements LifecycleBean {
|
||||
return licenseId;
|
||||
}
|
||||
|
||||
public FlowLimitBO getFlowLimitByServerPort(Integer serverPort) {
|
||||
Integer id = getPortMappingIdByServerPort(serverPort);
|
||||
public FlowLimitBO getFlowLimitByServerPort(String domain) {
|
||||
Integer id = getDomainMappingIdByDomain(domain);
|
||||
if (null == id) {
|
||||
return null;
|
||||
}
|
||||
@@ -399,12 +384,12 @@ public class DomainMappingService implements LifecycleBean {
|
||||
return res;
|
||||
}
|
||||
|
||||
private void updateMappingDomainToSecurityGroupMap(Integer serverPort, Integer securityGroupId) {
|
||||
private void updateMappingDomainToSecurityGroupMap(String domain, Integer securityGroupId) {
|
||||
if (securityGroupId == null || securityGroupId == 0) {
|
||||
mappingDomainToSecurityGroupMap.remove(serverPort);
|
||||
mappingDomainToSecurityGroupMap.remove(domain);
|
||||
return;
|
||||
}
|
||||
mappingDomainToSecurityGroupMap.put(serverPort, securityGroupId);
|
||||
mappingDomainToSecurityGroupMap.put(domain, securityGroupId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -417,7 +402,7 @@ public class DomainMappingService implements LifecycleBean {
|
||||
*/
|
||||
@Override
|
||||
public void stop() throws Throwable {
|
||||
domainMappingMapper.updateOnlineStatus(OnlineStatusEnum.OFFLINE.getStatus(), new Date());
|
||||
// domainMappingMapper.updateOnlineStatus(OnlineStatusEnum.OFFLINE.getStatus(), new Date());
|
||||
}
|
||||
|
||||
public DomainMappingDto one(Integer id) {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.neutrinoproxy.server.dal.PortMappingMapper">
|
||||
<mapper namespace="org.dromara.neutrinoproxy.server.dal.DomainMappingMapper">
|
||||
|
||||
<select id="selectDomainMappingByCondition" resultType="org.dromara.neutrinoproxy.server.dal.entity.PortMappingDO">
|
||||
SELECT pm.*
|
||||
FROM port_mapping pm
|
||||
<select id="selectDomainMappingByCondition" resultType="org.dromara.neutrinoproxy.server.dal.entity.DomainMappingDO">
|
||||
SELECT pm.*,l.is_online as isOnline
|
||||
FROM domain_mapping pm
|
||||
LEFT JOIN license l ON pm.license_id = l.`id`
|
||||
<where>
|
||||
<if test="req.userId != null">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.neutrinoproxy.server.dal.PortMappingMapper">
|
||||
|
||||
<select id="selectPortMappingByCondition" resultType="org.dromara.neutrinoproxy.server.dal.entity.DomainMappingDO">
|
||||
<select id="selectPortMappingByCondition" resultType="org.dromara.neutrinoproxy.server.dal.entity.PortMappingDO">
|
||||
SELECT pm.* from port_mapping pm left join license on pm.license_id = license.`id`
|
||||
<where>
|
||||
<if test="req.userId != null">
|
||||
|
||||
Reference in New Issue
Block a user