域名解析完成
不通过客户端,服务端直接转发到服务端端口 待完成
This commit is contained in:
@@ -1,36 +1,39 @@
|
||||
'use strict'
|
||||
const path = require('path')
|
||||
const utils = require('./utils')
|
||||
const webpack = require('webpack')
|
||||
const config = require('../config')
|
||||
const merge = require('webpack-merge')
|
||||
const baseWebpackConfig = require('./webpack.base.conf')
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
|
||||
const portfinder = require('portfinder')
|
||||
"use strict";
|
||||
const path = require("path");
|
||||
const utils = require("./utils");
|
||||
const webpack = require("webpack");
|
||||
const config = require("../config");
|
||||
const merge = require("webpack-merge");
|
||||
const baseWebpackConfig = require("./webpack.base.conf");
|
||||
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||
const FriendlyErrorsPlugin = require("friendly-errors-webpack-plugin");
|
||||
const portfinder = require("portfinder");
|
||||
|
||||
function resolve (dir) {
|
||||
return path.join(__dirname, '..', dir)
|
||||
function resolve(dir) {
|
||||
return path.join(__dirname, "..", dir);
|
||||
}
|
||||
|
||||
const HOST = process.env.HOST
|
||||
const PORT = process.env.PORT && Number(process.env.PORT)
|
||||
const HOST = process.env.HOST;
|
||||
const PORT = process.env.PORT && Number(process.env.PORT);
|
||||
|
||||
const devWebpackConfig = merge(baseWebpackConfig, {
|
||||
module: {
|
||||
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true })
|
||||
rules: utils.styleLoaders({
|
||||
sourceMap: config.dev.cssSourceMap,
|
||||
usePostCSS: true
|
||||
})
|
||||
},
|
||||
// cheap-module-eval-source-map is faster for development
|
||||
devtool: config.dev.devtool,
|
||||
|
||||
// these devServer options should be customized in /config/index.js
|
||||
devServer: {
|
||||
clientLogLevel: 'warning',
|
||||
clientLogLevel: "warning",
|
||||
historyApiFallback: true,
|
||||
hot: true,
|
||||
compress: true,
|
||||
host: HOST || config.dev.host,
|
||||
port: PORT || config.dev.port,
|
||||
allowedHosts: ["localhost", "server.com", ".server.com"],
|
||||
open: config.dev.autoOpenBrowser,
|
||||
overlay: config.dev.errorOverlay
|
||||
? { warnings: false, errors: true }
|
||||
@@ -39,50 +42,54 @@ const devWebpackConfig = merge(baseWebpackConfig, {
|
||||
proxy: config.dev.proxyTable,
|
||||
quiet: true, // necessary for FriendlyErrorsPlugin
|
||||
watchOptions: {
|
||||
poll: config.dev.poll,
|
||||
poll: config.dev.poll
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': require('../config/local.env')
|
||||
"process.env": require("../config/local.env")
|
||||
}),
|
||||
new webpack.HotModuleReplacementPlugin(),
|
||||
new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update.
|
||||
new webpack.NoEmitOnErrorsPlugin(),
|
||||
// https://github.com/ampedandwired/html-webpack-plugin
|
||||
new HtmlWebpackPlugin({
|
||||
filename: 'index.html',
|
||||
template: 'index.html',
|
||||
filename: "index.html",
|
||||
template: "index.html",
|
||||
inject: true,
|
||||
favicon: resolve('favicon.ico'),
|
||||
title: 'vue-element-admin',
|
||||
favicon: resolve("favicon.ico"),
|
||||
title: "vue-element-admin",
|
||||
path: config.dev.assetsPublicPath + config.dev.assetsSubDirectory
|
||||
}),
|
||||
})
|
||||
]
|
||||
})
|
||||
});
|
||||
|
||||
module.exports = new Promise((resolve, reject) => {
|
||||
portfinder.basePort = process.env.PORT || config.dev.port
|
||||
portfinder.basePort = process.env.PORT || config.dev.port;
|
||||
portfinder.getPort((err, port) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
reject(err);
|
||||
} else {
|
||||
// publish the new Port, necessary for e2e tests
|
||||
process.env.PORT = port
|
||||
process.env.PORT = port;
|
||||
// add port to devServer config
|
||||
devWebpackConfig.devServer.port = port
|
||||
|
||||
devWebpackConfig.devServer.port = port;
|
||||
console.log('devWebpackConfig', devWebpackConfig)
|
||||
// Add FriendlyErrorsPlugin
|
||||
devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
|
||||
compilationSuccessInfo: {
|
||||
messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`],
|
||||
},
|
||||
onErrors: config.dev.notifyOnErrors
|
||||
? utils.createNotifierCallback()
|
||||
: undefined
|
||||
}))
|
||||
devWebpackConfig.plugins.push(
|
||||
new FriendlyErrorsPlugin({
|
||||
compilationSuccessInfo: {
|
||||
messages: [
|
||||
`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`
|
||||
]
|
||||
},
|
||||
onErrors: config.dev.notifyOnErrors
|
||||
? utils.createNotifierCallback()
|
||||
: undefined
|
||||
})
|
||||
);
|
||||
|
||||
resolve(devWebpackConfig)
|
||||
resolve(devWebpackConfig);
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
@@ -11,7 +11,6 @@ module.exports = {
|
||||
assetsSubDirectory: 'static',
|
||||
assetsPublicPath: '/',
|
||||
proxyTable: {},
|
||||
|
||||
// Various Dev Server settings
|
||||
host: 'localhost', // can be overwritten by process.env.HOST
|
||||
port: 9527, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function domainNameBindInfo(query) {
|
||||
return request({
|
||||
url: '/domain/bind-info',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchList(query) {
|
||||
return request({
|
||||
@@ -26,11 +19,8 @@ export function mappingModify(data) {
|
||||
|
||||
export function deleteMapping(id) {
|
||||
return request({
|
||||
url: '/domain/delete',
|
||||
method: 'post',
|
||||
params: {
|
||||
id: id
|
||||
}
|
||||
url: '/domain/delete/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<span>{{ scope.row.description }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.domainName')" width="180">
|
||||
<el-table-column align="left" :label="$t('table.domainName')" width="180">
|
||||
<template slot-scope="scope">
|
||||
<el-link target="_blank" @click="handleOpenWebPage(scope.row)">http(s)://{{ scope.row.domain }}</el-link>
|
||||
</template>
|
||||
|
||||
@@ -49,11 +49,6 @@
|
||||
<span>{{ scope.row.protocal }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column align="center" :label="$t('table.domainName')" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.domain }}</span>
|
||||
</template>
|
||||
</el-table-column> -->
|
||||
<el-table-column align="center" :label="$t('table.serverPort')" width="80">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.serverPort }}</span>
|
||||
@@ -148,11 +143,6 @@
|
||||
<el-form-item :label="$t('客户端端口')" prop="clientPort">
|
||||
<el-input v-model="temp.clientPort" type="number" :step="1" controls-position="right" ></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>
|
||||
@@ -206,7 +196,6 @@ 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'
|
||||
@@ -335,7 +324,6 @@ export default {
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.getDomainNameBindInfo()
|
||||
this.getDataList()
|
||||
this.getLicenseList()
|
||||
this.getLicenseAuthList()
|
||||
@@ -369,11 +357,6 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
getDomainNameBindInfo() {
|
||||
domainNameBindInfo().then(response => {
|
||||
this.domainName = response.data.data
|
||||
})
|
||||
},
|
||||
getAvailablePortList(licenseId) {
|
||||
this.loadServerPortQuery.licenseId = licenseId;
|
||||
this.serverPortList = []; //清掉数据
|
||||
@@ -466,9 +449,6 @@ export default {
|
||||
},
|
||||
handleOpenWebPage(row) {
|
||||
let url = location.protocol + '//' + location.hostname + ':' + row.serverPort
|
||||
if (row.domain) {
|
||||
url = location.protocol + '//' + row.domain
|
||||
}
|
||||
open(url)
|
||||
},
|
||||
handleUpdate(row) {
|
||||
|
||||
-1
@@ -63,7 +63,6 @@ public class ProxyConfig {
|
||||
public static class Tcp {
|
||||
private Integer bossThreadCount;
|
||||
private Integer workThreadCount;
|
||||
private String domainName;
|
||||
private Integer httpProxyPort;
|
||||
private Integer httpsProxyPort;
|
||||
private String keyStorePassword;
|
||||
|
||||
+1
-8
@@ -32,13 +32,6 @@ public class DomainController {
|
||||
@Inject
|
||||
private DomainMappingService domainMappingService;
|
||||
|
||||
@Get
|
||||
@Mapping("/bind-info")
|
||||
public String bindInfo () {
|
||||
return proxyConfig.getServer().getTcp().getDomainName();
|
||||
}
|
||||
|
||||
|
||||
@Get
|
||||
@Mapping("/page")
|
||||
public PageInfo<DomainMappingDto> page(PageQuery pageQuery, DomainMappingDto req) {
|
||||
@@ -71,7 +64,7 @@ public class DomainController {
|
||||
return domainMappingService.updateEnableStatus(req);
|
||||
}
|
||||
|
||||
@Post
|
||||
@Get
|
||||
@Mapping("/delete/{id}")
|
||||
public void delete(Integer id) {
|
||||
domainMappingService.delete(id);
|
||||
|
||||
+2
-8
@@ -51,10 +51,7 @@ public class PortMappingController {
|
||||
}
|
||||
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);
|
||||
@@ -86,10 +83,7 @@ public class PortMappingController {
|
||||
}
|
||||
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);
|
||||
|
||||
-4
@@ -38,10 +38,6 @@ public class PortMappingCreateReq {
|
||||
* 协议
|
||||
*/
|
||||
private String protocal;
|
||||
/**
|
||||
* 子域名
|
||||
*/
|
||||
private String subdomain;
|
||||
/**
|
||||
* 服务端端口
|
||||
*/
|
||||
|
||||
-4
@@ -42,10 +42,6 @@ public class PortMappingUpdateReq {
|
||||
* 协议
|
||||
*/
|
||||
private String protocal;
|
||||
/**
|
||||
* 子域名
|
||||
*/
|
||||
private String subdomain;
|
||||
/**
|
||||
* 服务端端口
|
||||
*/
|
||||
|
||||
-4
@@ -43,10 +43,6 @@ public class PortMappingListRes {
|
||||
* 协议
|
||||
*/
|
||||
private String protocal;
|
||||
/**
|
||||
* 子域名
|
||||
*/
|
||||
private String subdomain;
|
||||
/**
|
||||
* 域名
|
||||
*/
|
||||
|
||||
-11
@@ -46,17 +46,6 @@ public interface DomainMappingMapper extends BaseMapper<DomainMappingDO> {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验域名是否重复
|
||||
* @param subdomain
|
||||
* @return
|
||||
*/
|
||||
default Boolean checkRepeatByDomain(String subdomain, Set<Integer> excludeIds) {
|
||||
return StringUtils.isEmpty(subdomain)? Boolean.FALSE : this.selectCount(new LambdaQueryWrapper<DomainMappingDO>()
|
||||
.eq(DomainMappingDO::getDomain, subdomain)
|
||||
.notIn(!CollectionUtil.isEmpty(excludeIds), DomainMappingDO::getId, excludeIds)
|
||||
).intValue() > 0;
|
||||
}
|
||||
|
||||
default List<DomainMappingDO> findEnableListByLicenseId(Integer licenseId) {
|
||||
return this.selectList(new LambdaQueryWrapper<DomainMappingDO>()
|
||||
|
||||
+2
@@ -118,4 +118,6 @@ public interface LicenseMapper extends BaseMapper<LicenseDO> {
|
||||
}
|
||||
|
||||
List<ProxyMapping> findEnableProxyMappingListByLicenseId(Integer licenseId);
|
||||
|
||||
List<ProxyMapping> findAllProxyMappingListByLicenseId(Integer licenseId);
|
||||
}
|
||||
|
||||
-12
@@ -44,18 +44,6 @@ public interface PortMappingMapper extends BaseMapper<PortMappingDO> {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验子域名是否重复
|
||||
* @param subdomain
|
||||
* @return
|
||||
*/
|
||||
default Boolean checkRepeatBySubdomain(String subdomain, Set<Integer> excludeIds) {
|
||||
return StringUtils.isEmpty(subdomain)? Boolean.FALSE : this.selectCount(new LambdaQueryWrapper<PortMappingDO>()
|
||||
.eq(PortMappingDO::getSubdomain, subdomain)
|
||||
.notIn(!CollectionUtil.isEmpty(excludeIds), PortMappingDO::getId, excludeIds)
|
||||
).intValue() > 0;
|
||||
}
|
||||
|
||||
default List<PortMappingDO> findEnableListByLicenseId(Integer licenseId) {
|
||||
return this.selectList(new LambdaQueryWrapper<PortMappingDO>()
|
||||
.eq(PortMappingDO::getLicenseId, licenseId)
|
||||
|
||||
-4
@@ -55,10 +55,6 @@ public class PortMappingDO {
|
||||
* 协议
|
||||
*/
|
||||
private String protocal;
|
||||
/**
|
||||
* 子域名
|
||||
*/
|
||||
private String subdomain;
|
||||
/**
|
||||
* 服务端端口
|
||||
*/
|
||||
|
||||
-1
@@ -32,7 +32,6 @@ public class HttpProxy implements EventListener<AppLoadEndEvent> {
|
||||
|
||||
@Override
|
||||
public void onEvent(AppLoadEndEvent appLoadEndEvent) throws Throwable {
|
||||
// StrUtil.isBlank(proxyConfig.getServer().getTcp().getDomainName()) ||
|
||||
if (null == proxyConfig.getServer().getTcp().getHttpProxyPort()) {
|
||||
log.info("no config domain name,nonsupport http proxy.");
|
||||
return;
|
||||
|
||||
+1
-2
@@ -38,7 +38,6 @@ public class HttpsProxy implements EventListener<AppLoadEndEvent> {
|
||||
private ProxyConfig proxyConfig;
|
||||
@Override
|
||||
public void onEvent(AppLoadEndEvent appLoadEndEvent) throws Throwable {
|
||||
// StrUtil.isBlank(proxyConfig.getServer().getTcp().getDomainName()) ||
|
||||
if (null == proxyConfig.getServer().getTcp().getHttpsProxyPort() ||
|
||||
StringUtils.isEmpty(proxyConfig.getServer().getTcp().getJksPath()) ||
|
||||
StringUtils.isEmpty(proxyConfig.getServer().getTcp().getKeyStorePassword())) {
|
||||
@@ -60,7 +59,7 @@ public class HttpsProxy implements EventListener<AppLoadEndEvent> {
|
||||
}
|
||||
ch.pipeline().addLast(createSslHandler());
|
||||
ch.pipeline().addFirst(new BytesMetricsHandler());
|
||||
ch.pipeline().addLast(new HttpVisitorSecurityChannelHandler()); // proxyConfig.getServer().getTcp().getDomainName()
|
||||
ch.pipeline().addLast(new HttpVisitorSecurityChannelHandler());
|
||||
ch.pipeline().addLast("flowLimiter",new VisitorFlowLimiterChannelHandler());
|
||||
ch.pipeline().addLast(new HttpVisitorChannelHandler());
|
||||
}
|
||||
|
||||
+11
-19
@@ -119,9 +119,6 @@ public class DomainMappingService implements LifecycleBean {
|
||||
return;
|
||||
}
|
||||
item.setUserName(user.getName());
|
||||
// if (StrUtil.isNotBlank(proxyConfig.getServer().getTcp().getDomainName()) && StrUtil.isNotBlank(item.getDomain())) {
|
||||
// item.setDomain(item.getDomain() + "." + proxyConfig.getServer().getTcp().getDomainName());
|
||||
// }
|
||||
if (NetworkProtocolEnum.HTTP.getDesc().equals(item.getProtocal())) {
|
||||
item.setProtocal("HTTP(S)");
|
||||
}
|
||||
@@ -142,23 +139,24 @@ public class DomainMappingService implements LifecycleBean {
|
||||
ParamCheckUtil.checkExpression(!licenseDO.getUserId().equals(1), ExceptionConstant.NO_PERMISSION_VISIT);
|
||||
}
|
||||
if (null != dmd.getId()) { // 编辑
|
||||
ParamCheckUtil.checkExpression(!domainMappingMapper.checkRepeatByDomain(dmd.getDomain(), new HashSet<>(){{add(dmd.getId());}}), ExceptionConstant.DONAME_CONNOT_REPEAT);
|
||||
|
||||
Date now = new Date();
|
||||
dmd.setEnable(EnableStatusEnum.ENABLE.getStatus());
|
||||
dmd.setUpdateTime(now);
|
||||
domainMappingMapper.updateById(dmd);
|
||||
// 更新VisitorChannel
|
||||
DomainMappingDO oldDmd = domainMappingMapper.findById(dmd.getId());
|
||||
ParamCheckUtil.checkNotNull(oldDmd, ExceptionConstant.PORT_MAPPING_NOT_EXIST);
|
||||
ProxyMapping oldProxy = new ProxyMapping(oldDmd.getLicenseId(),oldDmd.getId(),oldDmd.getTargetPath(), NetworkProtocolEnum.HTTP.getDesc());
|
||||
visitorChannelService.updateVisitorChannelByProxyMapping(oldProxy, new ProxyMapping(dmd.getLicenseId(),dmd.getId(),dmd.getTargetPath(), NetworkProtocolEnum.HTTP.getDesc()));
|
||||
} else { // 新增
|
||||
ParamCheckUtil.checkExpression(!domainMappingMapper.checkRepeatByDomain(dmd.getDomain(), null), ExceptionConstant.DONAME_CONNOT_REPEAT);
|
||||
|
||||
Date now = new Date();
|
||||
dmd.setEnable(EnableStatusEnum.ENABLE.getStatus());
|
||||
dmd.setCreateTime(now);
|
||||
dmd.setUpdateTime(now);
|
||||
domainMappingMapper.insert(dmd);
|
||||
// 新增
|
||||
visitorChannelService.addVisitorChannelByProxyMapping(new ProxyMapping(dmd.getLicenseId(),dmd.getId(),dmd.getTargetPath(), NetworkProtocolEnum.HTTP.getDesc()));
|
||||
}
|
||||
// 更新VisitorChannel
|
||||
visitorChannelService.addVisitorChannelByProxyMapping(new ProxyMapping(dmd.getLicenseId(),dmd.getId(),dmd.getTargetPath(), NetworkProtocolEnum.HTTP.getDesc()));
|
||||
// 更新域名映射
|
||||
ProxyUtil.domainMapingMap.put(dmd.getDomain(), new DomainMapping(dmd.getId(), dmd.getLicenseId(), dmd.getDomain(), dmd.getTargetPath()));
|
||||
|
||||
@@ -189,10 +187,10 @@ public class DomainMappingService implements LifecycleBean {
|
||||
}
|
||||
|
||||
public void delete(Integer id) {
|
||||
DomainMappingDO domainMappingDO = domainMappingMapper.findById(id);
|
||||
ParamCheckUtil.checkNotNull(domainMappingDO, ExceptionConstant.PORT_MAPPING_NOT_EXIST);
|
||||
DomainMappingDO domain = domainMappingMapper.findById(id);
|
||||
ParamCheckUtil.checkNotNull(domain, ExceptionConstant.PORT_MAPPING_NOT_EXIST);
|
||||
|
||||
LicenseDO licenseDO = licenseMapper.findById(domainMappingDO.getLicenseId());
|
||||
LicenseDO licenseDO = licenseMapper.findById(domain.getLicenseId());
|
||||
if (null != licenseDO && !SystemContextHolder.isAdmin()) {
|
||||
// 临时处理,如果当前用户不是管理员,则操作userId不能为1
|
||||
ParamCheckUtil.checkExpression(!licenseDO.getUserId().equals(1), ExceptionConstant.NO_PERMISSION_VISIT);
|
||||
@@ -200,13 +198,7 @@ public class DomainMappingService implements LifecycleBean {
|
||||
domainMappingMapper.deleteById(id);
|
||||
|
||||
// 更新VisitorChannel
|
||||
// visitorChannelService.removeVisitorChannelByPortMapping(domainMappingDO);
|
||||
|
||||
// 更新域名映射
|
||||
if (NetworkProtocolEnum.isHttp(domainMappingDO.getProtocal()) && StrUtil.isNotBlank(domainMappingDO.getDomain())) {
|
||||
ProxyUtil.removeSubdomainToServerPort(domainMappingDO.getDomain());
|
||||
}
|
||||
|
||||
visitorChannelService.removeVisitorChannelByProxyMapping(new ProxyMapping(domain.getLicenseId(),domain.getId(),domain.getTargetPath(), NetworkProtocolEnum.HTTP.getDesc()));
|
||||
}
|
||||
|
||||
public void domainBindSecurityGroup(Integer portMappingId, Integer groupId) {
|
||||
|
||||
+1
-39
@@ -131,9 +131,6 @@ public class PortMappingService implements LifecycleBean {
|
||||
return;
|
||||
}
|
||||
item.setUserName(user.getName());
|
||||
if (StrUtil.isNotBlank(proxyConfig.getServer().getTcp().getDomainName()) && StrUtil.isNotBlank(item.getSubdomain())) {
|
||||
item.setDomain(item.getSubdomain() + "." + proxyConfig.getServer().getTcp().getDomainName());
|
||||
}
|
||||
if (NetworkProtocolEnum.HTTP.getDesc().equals(item.getProtocal())) {
|
||||
item.setProtocal("HTTP(S)");
|
||||
}
|
||||
@@ -155,13 +152,11 @@ public class PortMappingService implements LifecycleBean {
|
||||
PortPoolDO portPoolDO = portPoolMapper.findByPort(req.getServerPort());
|
||||
ParamCheckUtil.checkNotNull(portPoolDO, ExceptionConstant.PORT_NOT_EXIST);
|
||||
ParamCheckUtil.checkExpression(null == portMappingMapper.findByPort(req.getServerPort(), null), ExceptionConstant.PORT_CANNOT_REPEAT_MAPPING, req.getServerPort());
|
||||
ParamCheckUtil.checkExpression(!portMappingMapper.checkRepeatBySubdomain(req.getSubdomain(), null), ExceptionConstant.PORT_MAPPING_SUBDONAME_CONNOT_REPEAT);
|
||||
|
||||
Date now = new Date();
|
||||
PortMappingDO portMappingDO = new 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());
|
||||
@@ -177,10 +172,6 @@ public class PortMappingService implements LifecycleBean {
|
||||
portMappingMapper.insert(portMappingDO);
|
||||
// 更新VisitorChannel
|
||||
visitorChannelService.addVisitorChannelByProxyMapping(ProxyMapping.build(portMappingDO));
|
||||
// 更新域名映射
|
||||
if (NetworkProtocolEnum.isHttp(portMappingDO.getProtocal()) && StrUtil.isNotBlank(proxyConfig.getServer().getTcp().getDomainName()) && StrUtil.isNotBlank(portMappingDO.getSubdomain())) {
|
||||
ProxyUtil.setSubdomainToServerPort(portMappingDO.getSubdomain(), portMappingDO.getServerPort());
|
||||
}
|
||||
|
||||
updateMappingPortToSecurityGroupMap(portMappingDO.getServerPort(), req.getSecurityGroupId());
|
||||
|
||||
@@ -204,7 +195,6 @@ public class PortMappingService implements LifecycleBean {
|
||||
PortPoolDO portPoolDO = portPoolMapper.findByPort(req.getServerPort());
|
||||
ParamCheckUtil.checkNotNull(portPoolDO, ExceptionConstant.PORT_NOT_EXIST);
|
||||
ParamCheckUtil.checkExpression(null == portMappingMapper.findByPort(req.getServerPort(), Sets.newHashSet(req.getId())), ExceptionConstant.PORT_CANNOT_REPEAT_MAPPING, req.getServerPort());
|
||||
ParamCheckUtil.checkExpression(!portMappingMapper.checkRepeatBySubdomain(req.getSubdomain(), Sets.newHashSet(req.getId())), ExceptionConstant.PORT_MAPPING_SUBDONAME_CONNOT_REPEAT);
|
||||
|
||||
// 查询原端口映射
|
||||
PortMappingDO oldPortMappingDO = portMappingMapper.findById(req.getId());
|
||||
@@ -214,7 +204,6 @@ public class PortMappingService implements LifecycleBean {
|
||||
portMappingMapper.update(null, new LambdaUpdateWrapper<PortMappingDO>()
|
||||
.eq(PortMappingDO::getId, req.getId())
|
||||
.set(PortMappingDO::getProtocal, req.getProtocal())
|
||||
.set(PortMappingDO::getSubdomain, req.getSubdomain())
|
||||
.set(PortMappingDO::getServerPort, req.getServerPort())
|
||||
.set(PortMappingDO::getClientIp, req.getClientIp())
|
||||
.set(PortMappingDO::getClientPort, req.getClientPort())
|
||||
@@ -229,15 +218,7 @@ public class PortMappingService implements LifecycleBean {
|
||||
|
||||
// 更新VisitorChannel
|
||||
PortMappingDO portMappingDO = portMappingMapper.findById(req.getId());
|
||||
visitorChannelService.updateVisitorChannelByPortMapping(oldPortMappingDO, portMappingDO);
|
||||
// 删除老的域名映射
|
||||
if (NetworkProtocolEnum.isHttp(oldPortMappingDO.getProtocal()) && StrUtil.isNotBlank(oldPortMappingDO.getSubdomain())) {
|
||||
ProxyUtil.removeSubdomainToServerPort(oldPortMappingDO.getSubdomain());
|
||||
}
|
||||
// 更新域名映射
|
||||
if (NetworkProtocolEnum.isHttp(portMappingDO.getProtocal()) && StrUtil.isNotBlank(proxyConfig.getServer().getTcp().getDomainName()) && StrUtil.isNotBlank(portMappingDO.getSubdomain())) {
|
||||
ProxyUtil.setSubdomainToServerPort(portMappingDO.getSubdomain(), portMappingDO.getServerPort());
|
||||
}
|
||||
visitorChannelService.updateVisitorChannelByProxyMapping(ProxyMapping.build(oldPortMappingDO), ProxyMapping.build(portMappingDO));
|
||||
|
||||
updateMappingPortToSecurityGroupMap(portMappingDO.getServerPort(), req.getSecurityGroupId());
|
||||
|
||||
@@ -318,9 +299,6 @@ public class PortMappingService implements LifecycleBean {
|
||||
// 更新VisitorChannel
|
||||
visitorChannelService.removeVisitorChannelByProxyMapping(ProxyMapping.build(portMappingDO));
|
||||
// 更新域名映射
|
||||
if (NetworkProtocolEnum.isHttp(portMappingDO.getProtocal()) && StrUtil.isNotBlank(portMappingDO.getSubdomain())) {
|
||||
ProxyUtil.removeSubdomainToServerPort(portMappingDO.getSubdomain());
|
||||
}
|
||||
|
||||
updateMappingPortToSecurityGroupMap(portMappingDO.getServerPort(), null);
|
||||
|
||||
@@ -393,22 +371,6 @@ public class PortMappingService implements LifecycleBean {
|
||||
refreshFlowLimitCache(item.getId(), item.getUpLimitRate(), item.getDownLimitRate());
|
||||
});
|
||||
|
||||
// 未配置域名,则不需要处理域名映射逻辑
|
||||
if (StrUtil.isBlank(proxyConfig.getServer().getTcp().getDomainName())) {
|
||||
return;
|
||||
}
|
||||
List<PortMappingDO> portMappingDOList = allMappingDOList.stream()
|
||||
.filter(item -> NetworkProtocolEnum.HTTP.getDesc().equals(item.getProtocal()) && item.getSubdomain() != null)
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtil.isEmpty(portMappingDOList)) {
|
||||
return;
|
||||
}
|
||||
portMappingDOList.forEach(item -> {
|
||||
if (StrUtil.isBlank(item.getSubdomain())) {
|
||||
return;
|
||||
}
|
||||
ProxyUtil.setSubdomainToServerPort(item.getSubdomain(), item.getServerPort());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+17
-20
@@ -131,35 +131,32 @@ public class VisitorChannelService {
|
||||
return;
|
||||
}
|
||||
EnableStatusEnum enableStatusEnum = EnableStatusEnum.of(enable);
|
||||
List<PortMappingDO> portMappingDOList = portMappingMapper.findListByLicenseId(licenseId);
|
||||
if (!CollectionUtil.isEmpty(portMappingDOList)) {
|
||||
for (PortMappingDO portMappingDO : portMappingDOList) {
|
||||
if (EnableStatusEnum.DISABLE == enableStatusEnum) {
|
||||
removeVisitorChannelByProxyMapping(ProxyMapping.build(portMappingDO));
|
||||
} else if (EnableStatusEnum.ENABLE == EnableStatusEnum.of(portMappingDO.getEnable())) {
|
||||
addVisitorChannelByProxyMapping(ProxyMapping.build(portMappingDO));
|
||||
}
|
||||
if (EnableStatusEnum.DISABLE == enableStatusEnum) { // 禁用删除,关闭所有链接及配置
|
||||
List<ProxyMapping> allProxyMappingList = licenseMapper.findAllProxyMappingListByLicenseId(licenseId);
|
||||
for (ProxyMapping proxy : allProxyMappingList) {
|
||||
removeVisitorChannelByProxyMapping(proxy);
|
||||
}
|
||||
} else { // if (EnableStatusEnum.ENABLE == enableStatusEnum) 如果实启用,则开启所有
|
||||
List<ProxyMapping> enableProxyMappingList = licenseMapper.findEnableProxyMappingListByLicenseId(licenseId);
|
||||
for (ProxyMapping eproxy : enableProxyMappingList) {
|
||||
addVisitorChannelByProxyMapping(eproxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* 触发时机:修改端口映射
|
||||
* @param oldPortMappingDO
|
||||
* @param newPortMappingDO
|
||||
* @param oldProxyMapping
|
||||
* @param newProxyMapping
|
||||
*/
|
||||
public void updateVisitorChannelByPortMapping(PortMappingDO oldPortMappingDO, PortMappingDO newPortMappingDO) {
|
||||
if (null == oldPortMappingDO || null == newPortMappingDO) {
|
||||
public void updateVisitorChannelByProxyMapping(ProxyMapping oldProxyMapping, ProxyMapping newProxyMapping) {
|
||||
if (null == oldProxyMapping || null == newProxyMapping) {
|
||||
return;
|
||||
}
|
||||
|
||||
removeVisitorChannelByProxyMapping(ProxyMapping.build(oldPortMappingDO));
|
||||
addVisitorChannelByProxyMapping(ProxyMapping.build(newPortMappingDO));
|
||||
|
||||
removeVisitorChannelByProxyMapping(oldProxyMapping);
|
||||
addVisitorChannelByProxyMapping(newProxyMapping);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增VisitorChannel
|
||||
* 触发时机:新增端口映射、启用端口映射
|
||||
@@ -183,8 +180,8 @@ public class VisitorChannelService {
|
||||
// 判断用户是否启用
|
||||
if (null != userDO && EnableStatusEnum.ENABLE == EnableStatusEnum.of(userDO.getEnable())) {
|
||||
PortPoolDO portPoolDO = portPoolMapper.findByPort(proxyMapping.getServerPort());
|
||||
// 判断端口池是否启用
|
||||
if (null != portPoolDO && EnableStatusEnum.ENABLE == EnableStatusEnum.of(portPoolDO.getEnable())) {
|
||||
// 端口池大于65535 为域名解析,小于65535为端口映射,端口映射要判断端口池是否启用
|
||||
if (proxyMapping.getServerPort() > 65535 || (null != portPoolDO && EnableStatusEnum.ENABLE == EnableStatusEnum.of(portPoolDO.getEnable()))) {
|
||||
// 未删除且未禁用,则开启代理
|
||||
ProxyUtil.addProxyInfo(proxyMapping.getLicenseId(), proxyMapping);
|
||||
ProxyUtil.addCmdChannel(proxyMapping.getLicenseId(), cmdChannel, Sets.newHashSet(proxyMapping.getServerPort()));
|
||||
|
||||
+1
-29
@@ -60,10 +60,7 @@ public class ProxyUtil {
|
||||
* 代理 - connect附加映射
|
||||
*/
|
||||
private static Map<String, ProxyAttachment> proxyConnectAttachmentMap = new HashMap<>();
|
||||
/**
|
||||
* 子域名 - 服务端端口映射
|
||||
*/
|
||||
private static Map<String, Integer> subdomainToServerPort = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
* 域名 解析 映射
|
||||
@@ -346,31 +343,6 @@ public class ProxyUtil {
|
||||
proxyConnectAttachmentMap.remove(visitorId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置子域名到服务端端口的映射
|
||||
* @param subdomain
|
||||
* @param serverPort
|
||||
*/
|
||||
public static void setSubdomainToServerPort(String subdomain, Integer serverPort) {
|
||||
subdomainToServerPort.put(subdomain, serverPort);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除子域名到服务端端口的映射
|
||||
* @param subdomain
|
||||
*/
|
||||
public static void removeSubdomainToServerPort(String subdomain) {
|
||||
subdomainToServerPort.remove(subdomain);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据子域名获取外网端口
|
||||
* @param subdomain
|
||||
* @return
|
||||
*/
|
||||
public static Integer getServerPortBySubdomain(String subdomain) {
|
||||
return subdomainToServerPort.get(subdomain);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭http响应channel
|
||||
|
||||
@@ -55,7 +55,7 @@ neutrino:
|
||||
boss-thread-count: 5
|
||||
work-thread-count: 20
|
||||
# http代理端口,默认80
|
||||
http-proxy-port: ${HTTP_PROXY_PORT:80}
|
||||
http-proxy-port: ${HTTP_PR0OXY_PORT:80}
|
||||
# https代理端口,默认443 (需要配置域名、证书)
|
||||
https-proxy-port: ${HTTPS_PROXY_PORT:443}
|
||||
# 如果不配置,则不支持域名映射
|
||||
|
||||
@@ -13,4 +13,14 @@
|
||||
LEFT JOIN license l on dm.license_id = l.`id`
|
||||
WHERE dm.enable = 1 AND l.is_online = 1
|
||||
</select>
|
||||
|
||||
<select id="findAllProxyMappingListByLicenseId" resultType="org.dromara.neutrinoproxy.server.proxy.domain.ProxyMapping">
|
||||
SELECT pm.server_port as serverPort,CONCAT(pm.client_ip, ':', pm.client_port) as lanInfo, pm.protocal as protocal
|
||||
FROM port_mapping pm
|
||||
LEFT JOIN port_pool pp on pm.server_port = pp.port
|
||||
UNION ALL
|
||||
SELECT dm.id as serverPort,dm.target_path as lanInfo, 'HTTP' as protocal
|
||||
FROM domain_mapping dm
|
||||
LEFT JOIN license l on dm.license_id = l.`id`
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
ALTER TABLE port_pool ADD group_id INTEGER NOT NULL DEFAULT 1;
|
||||
|
||||
#端口分组
|
||||
CREATE TABLE IF NOT EXISTS `port_group` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`possessor_type` INTEGER NOT NULL DEFAULT '0',
|
||||
`possessor_id` INTEGER NOT NULL DEFAULT '-1',
|
||||
`enable` INTEGER NOT NULL,
|
||||
`create_time` datetime(3) NOT NULL,
|
||||
`update_time` datetime(3) NOT NULL
|
||||
);
|
||||
@@ -1,3 +0,0 @@
|
||||
ALTER TABLE port_mapping ADD `protocal` varchar(10) NOT NULL DEFAULT 'TCP';
|
||||
ALTER TABLE port_mapping ADD `subdomain` varchar(50) DEFAULT NULL;
|
||||
ALTER TABLE port_mapping ADD `description` varchar(100);
|
||||
@@ -1,2 +0,0 @@
|
||||
ALTER TABLE port_mapping ADD `proxy_responses` INTEGER(20) NOT NULL DEFAULT 0;
|
||||
ALTER TABLE port_mapping ADD `proxy_timeout_ms` INTEGER(20) NOT NULL DEFAULT 0;
|
||||
@@ -1,38 +0,0 @@
|
||||
#安全组
|
||||
CREATE TABLE IF NOT EXISTS `security_group` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(20) NOT NULL,
|
||||
`description` VARCHAR(255),
|
||||
`user_id` INTEGER NOT NULL,
|
||||
`enable` INTEGER NOT NULL,
|
||||
`default_pass_type` INTEGER NOT NULL,
|
||||
`create_time` TIMESTAMP NOT NULL,
|
||||
`update_time` TIMESTAMP NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
#安全组规则
|
||||
CREATE TABLE IF NOT EXISTS `security_rule` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`group_id` INTEGER NOT NULL,
|
||||
`name` VARCHAR(20) NOT NULL,
|
||||
`description` VARCHAR(255) NOT NULL,
|
||||
`rule` text NOT NULL,
|
||||
`pass_type` INTEGER NOT NULL,
|
||||
`priority` INTEGER NOT NULL,
|
||||
`user_id` INTEGER NOT NULL,
|
||||
`enable` INTEGER NOT NULL,
|
||||
`create_time` TIMESTAMP NOT NULL,
|
||||
`update_time` TIMESTAMP NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS I_security_rule_group_id ON security_rule(group_id);
|
||||
|
||||
# port_mapping表增加字段
|
||||
ALTER TABLE `port_mapping` ADD COLUMN `security_group_id` INTEGER DEFAULT 0;
|
||||
ALTER TABLE `port_mapping` ADD COLUMN `up_limit_rate` varchar(20) DEFAULT NULL;
|
||||
ALTER TABLE `port_mapping` ADD COLUMN `down_limit_rate` varchar(20) DEFAULT NULL;
|
||||
|
||||
# license表增加字段
|
||||
ALTER TABLE `license` ADD COLUMN `up_limit_rate` varchar(20) DEFAULT NULL;
|
||||
ALTER TABLE `license` ADD COLUMN `down_limit_rate` varchar(20) DEFAULT NULL;
|
||||
@@ -102,7 +102,6 @@ CREATE TABLE IF NOT EXISTS `port_mapping` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`license_id` int NOT NULL COMMENT 'licenseID',
|
||||
`protocal` varchar(10) NOT NULL DEFAULT 'TCP' COMMENT '协议',
|
||||
`subdomain` varchar(50) DEFAULT NULL COMMENT '子域名(仅HTTP时有效)',
|
||||
`server_port` int NOT NULL COMMENT '服务端端口',
|
||||
`client_ip` varchar(20) NOT NULL COMMENT '客户端IP',
|
||||
`client_port` int NOT NULL COMMENT '客户端端口',
|
||||
|
||||
@@ -102,7 +102,6 @@ CREATE TABLE IF NOT EXISTS `port_mapping` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`license_id` int NOT NULL COMMENT 'licenseID',
|
||||
`protocal` varchar(10) NOT NULL DEFAULT 'TCP' COMMENT '协议',
|
||||
`subdomain` varchar(50) DEFAULT NULL COMMENT '子域名(仅HTTP时有效)',
|
||||
`server_port` int NOT NULL COMMENT '服务端端口',
|
||||
`client_ip` varchar(20) NOT NULL COMMENT '客户端IP',
|
||||
`client_port` int NOT NULL COMMENT '客户端端口',
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
ALTER TABLE port_pool ADD group_id INT NOT NULL DEFAULT 1 COMMENT "分组ID";
|
||||
|
||||
#端口分组
|
||||
CREATE TABLE IF NOT EXISTS `port_group` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`name` varchar(255) NOT NULL COMMENT '分组名称',
|
||||
`possessor_type` int NOT NULL DEFAULT '0' COMMENT '所有者类型 (0、全局共享 1、用户所有 2License所有) ',
|
||||
`possessor_id` int NOT NULL DEFAULT '-1' COMMENT '所有者id(当type为0时 固定为-1、当type为1时为用户id 、当type为2时为licenseid)',
|
||||
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
`update_time` datetime(3) NOT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COMMENT='端口分组';
|
||||
@@ -1,3 +0,0 @@
|
||||
ALTER TABLE port_mapping ADD `protocal` varchar(10) NOT NULL DEFAULT 'TCP' COMMENT '协议';
|
||||
ALTER TABLE port_mapping ADD `subdomain` varchar(50) DEFAULT NULL COMMENT '子域名(仅HTTP时有效)';
|
||||
ALTER TABLE port_mapping ADD `description` varchar(100) DEFAULT NULL COMMENT '描述';
|
||||
@@ -1,2 +0,0 @@
|
||||
ALTER TABLE port_mapping ADD `proxy_responses` int NOT NULL DEFAULT 0 COMMENT '代理响应数据包数量';
|
||||
ALTER TABLE port_mapping ADD `proxy_timeout_ms` int NOT NULL DEFAULT 0 COMMENT '代理超时毫秒数';
|
||||
@@ -1,8 +0,0 @@
|
||||
ALTER TABLE `flow_report_minute` MODIFY COLUMN `read_bytes` BIGINT NOT NULL COMMENT '读取流量';
|
||||
ALTER TABLE `flow_report_minute` MODIFY COLUMN `write_bytes` BIGINT NOT NULL COMMENT '写入流量';
|
||||
ALTER TABLE `flow_report_hour` MODIFY COLUMN `read_bytes` BIGINT NOT NULL COMMENT '读取流量';
|
||||
ALTER TABLE `flow_report_hour` MODIFY COLUMN `write_bytes` BIGINT NOT NULL COMMENT '写入流量';
|
||||
ALTER TABLE `flow_report_day` MODIFY COLUMN `read_bytes` BIGINT NOT NULL COMMENT '读取流量';
|
||||
ALTER TABLE `flow_report_day` MODIFY COLUMN `write_bytes` BIGINT NOT NULL COMMENT '写入流量';
|
||||
ALTER TABLE `flow_report_month` MODIFY COLUMN `read_bytes` BIGINT NOT NULL COMMENT '读取流量';
|
||||
ALTER TABLE `flow_report_month` MODIFY COLUMN `write_bytes` BIGINT NOT NULL COMMENT '写入流量';
|
||||
@@ -1,38 +0,0 @@
|
||||
#安全组
|
||||
CREATE TABLE IF NOT EXISTS `security_group` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`name` varchar(20) NOT NULL COMMENT '安全组名称',
|
||||
`description` varchar(255) COMMENT '安全组描述',
|
||||
`user_id` int NOT NULL COMMENT '用户ID',
|
||||
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
|
||||
`default_pass_type` int NOT NULL COMMENT '默认放行类型',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
`update_time` datetime(3) NOT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
#安全组规则
|
||||
CREATE TABLE IF NOT EXISTS `security_rule` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`group_id` int NOT NULL COMMENT '关联安全组',
|
||||
`name` varchar(20) NOT NULL COMMENT '规则名称',
|
||||
`description` varchar(255) NOT NULL COMMENT '规则描述',
|
||||
`rule` text NOT NULL COMMENT '规则内容',
|
||||
`pass_type`int NOT NULL COMMENT '放行类型',
|
||||
`priority` int(1) NOT NULL COMMENT '优先级',
|
||||
`user_id` int NOT NULL COMMENT '用户ID',
|
||||
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
`update_time` datetime(3) NOT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `I_security_rule_group_id_priority` (`group_id`, `priority`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
# port_mapping表增加字段
|
||||
ALTER TABLE `port_mapping` ADD COLUMN `security_group_id` int DEFAULT 0 COMMENT '安全组Id';
|
||||
ALTER TABLE `port_mapping` ADD COLUMN `up_limit_rate` varchar(20) DEFAULT NULL COMMENT '上传限速';
|
||||
ALTER TABLE `port_mapping` ADD COLUMN `down_limit_rate` varchar(20) DEFAULT NULL COMMENT '下载限速';
|
||||
|
||||
# license表增加字段
|
||||
ALTER TABLE `license` ADD COLUMN `up_limit_rate` varchar(20) DEFAULT NULL COMMENT '上传限速';
|
||||
ALTER TABLE `license` ADD COLUMN `down_limit_rate` varchar(20) DEFAULT NULL COMMENT '下载限速';
|
||||
Reference in New Issue
Block a user