安全组相关代码优化.

This commit is contained in:
aoshiguchen
2023-12-10 22:43:59 +08:00
parent bb96caca64
commit d3c658fa4d
26 changed files with 308 additions and 136 deletions
+15 -10
View File
@@ -58,6 +58,14 @@ export function updateGroupEnableStatus(id, enable) {
}) })
} }
export function fetchRulePage(query) {
return request({
url: '/security/rule/page',
method: 'get',
params: query
})
}
export function fetchRuleList(query) { export function fetchRuleList(query) {
return request({ return request({
url: '/security/rule/list', url: '/security/rule/list',
@@ -89,16 +97,13 @@ export function deleteRule(query) {
}) })
} }
export function enableRule(ruleId) { export function updateRuleEnableStatus(id, enable) {
return request({ return request({
url: `/security/rule/enable?ruleId=${ruleId}`, url: '/security/rule/update/enable-status',
method: 'post' method: 'post',
}) data: {
} id: id,
enable: enable
export function disableRule(ruleId) { }
return request({
url: `/security/rule/disable?ruleId=${ruleId}`,
method: 'post'
}) })
} }
@@ -3,11 +3,15 @@
<div class="filter-container"> <div class="filter-container">
<el-input v-model="listQuery.name" style="width:145px;margin-right:10px" placeholder="请输入名称" /> <el-input v-model="listQuery.name" style="width:145px;margin-right:10px" placeholder="请输入名称" />
<el-input v-model="listQuery.description" style="width:145px;margin-right:10px" placeholder="请输入描述" /> <el-input v-model="listQuery.description" style="width:145px;margin-right:10px" placeholder="请输入描述" />
<el-select v-model="listQuery.defaultPassType" placeholder="请选择默认放行类型" clearable style="width:145px;margin-right:10px">
<el-option v-for="item in selectObj.passType" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
<el-select v-model="listQuery.enable" placeholder="请选择启用状态" clearable style="width:145px;margin-right:10px"> <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="item in selectObj.statusOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select> </el-select>
<el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">{{ <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">{{
$t('table.search') }}</el-button> $t('table.search') }}
</el-button>
<el-button class="filter-item" style="margin-left: 10px;" @click="handleCreate" type="primary" icon="el-icon-edit">{{$t('table.add')}}</el-button> <el-button class="filter-item" style="margin-left: 10px;" @click="handleCreate" type="primary" icon="el-icon-edit">{{$t('table.add')}}</el-button>
</div> </div>
@@ -31,18 +35,17 @@
</el-table-column> </el-table-column>
<el-table-column align="center" :label="$t('table.defaultPassType')"> <el-table-column align="center" :label="$t('table.defaultPassType')">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag type="success" v-if="scope.row.defaultPassType == 'allow'">允许</el-tag> <el-tag :type="scope.row.defaultPassType | statusFilter">{{ scope.row.defaultPassType | passTypeName }}</el-tag>
<el-tag type="info" v-if="scope.row.defaultPassType == 'deny'">拒绝</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" :label="$t('table.createTime')"> <el-table-column align="center" :label="$t('table.createTime')">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{scope.row.createTime}}</span> <span>{{ scope.row.createTime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" :label="$t('table.updateTime')"> <el-table-column align="center" :label="$t('table.updateTime')">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{scope.row.updateTime}}</span> <span>{{ scope.row.updateTime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column class-name="status-col" :label="$t('table.enableStatus')"> <el-table-column class-name="status-col" :label="$t('table.enableStatus')">
@@ -186,6 +189,7 @@
import {fetchGroupPage, createGroup, updateGroup, deleteGroup, updateGroupEnableStatus} from '@/api/securityGroup' import {fetchGroupPage, createGroup, updateGroup, deleteGroup, updateGroupEnableStatus} from '@/api/securityGroup'
import { fetchList as fetchPortMappingList, portMappingBindSecurityGroup, portMappingUnbindSecurityGroup} from '@/api/portMapping' import { fetchList as fetchPortMappingList, portMappingBindSecurityGroup, portMappingUnbindSecurityGroup} from '@/api/portMapping'
import waves from '@/directive/waves' // 水波纹指令 import waves from '@/directive/waves' // 水波纹指令
import { parseTime } from '@/utils'
import LinkPopover from '../../components/Link/linkPopover' import LinkPopover from '../../components/Link/linkPopover'
export default { export default {
@@ -206,6 +210,7 @@ import LinkPopover from '../../components/Link/linkPopover'
size: 10, size: 10,
name: undefined, name: undefined,
description: undefined, description: undefined,
defaultPassType: undefined,
enable: undefined enable: undefined
}, },
listLoading: true, listLoading: true,
@@ -217,7 +222,9 @@ import LinkPopover from '../../components/Link/linkPopover'
}, },
selectObj: { selectObj: {
statusOptions: [{ label: '启用', value: 1 }, { label: '禁用', value: 2 }], statusOptions: [{ label: '启用', value: 1 }, { label: '禁用', value: 2 }],
onlineOptions: [{ label: '在线', value: 1 }, { label: '离线', value: 2 }] onlineOptions: [{ label: '在线', value: 1 }, { label: '离线', value: 2 }],
passType: [{ label: '允许', value: 1 }, { label: '拒绝', value: 2 }]
}, },
dialogFormVisible: false, dialogFormVisible: false,
dialogStatus: '', dialogStatus: '',
@@ -255,6 +262,13 @@ import LinkPopover from '../../components/Link/linkPopover'
} }
}, },
filters: { filters: {
passTypeName(type) {
const statusMap = {
1: '允许',
2: '拒绝'
}
return statusMap[type]
},
statusName(status) { statusName(status) {
const statusMap = { const statusMap = {
1: '启用', 1: '启用',
@@ -355,8 +369,7 @@ import LinkPopover from '../../components/Link/linkPopover'
}, },
handleUpdate(row) { handleUpdate(row) {
this.temp = Object.assign({}, row) // copy obj this.temp = Object.assign({}, row) // copy obj
this.temp.defaultPassType = row.defaultPassType == 'allow' ? 1 : 0 // this.temp.timestamp = new Date(this.temp.timestamp)
this.temp.timestamp = new Date(this.temp.timestamp)
this.dialogStatus = 'update' this.dialogStatus = 'update'
this.dialogFormVisible = true this.dialogFormVisible = true
this.$nextTick(() => { this.$nextTick(() => {
@@ -396,7 +409,9 @@ import LinkPopover from '../../components/Link/linkPopover'
}) })
}, },
handleGoRulePage (row) { handleGoRulePage (row) {
this.$router.push(`/system/securityRule?groupId=${row.id}`) this.$router.push({ path: '/system/securityRule', query: { groupId: row.id }})
// this.$router.push(`/system/securityRule?groupId=${row.id}`)
}, },
handlePortMapping(row) { handlePortMapping(row) {
this.dialogBindPortMappingVisible = true this.dialogBindPortMappingVisible = true
@@ -6,7 +6,18 @@
<div style="text-align: center;font-size:14px; color: #606266">{{group.description}}</div> <div style="text-align: center;font-size:14px; color: #606266">{{group.description}}</div>
</div> </div>
<div class="filter-container" align="right"> <div class="filter-container">
<el-input v-model="listQuery.name" style="width:145px;margin-right:10px" placeholder="请输入名称" />
<el-input v-model="listQuery.description" style="width:145px;margin-right:10px" placeholder="请输入描述" />
<!-- <el-select v-model="listQuery.passType" placeholder="请选择默认放行类型" clearable style="width:145px;margin-right:10px">-->
<!-- <el-option v-for="item in selectObj.passType" :key="item.value" :label="item.label" :value="item.value" />-->
<!-- </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-select>
<el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">{{
$t('table.search') }}
</el-button>
<el-button class="filter-item" @click="handleCreate" type="primary" icon="el-icon-edit">{{$t('table.add')}}</el-button> <el-button class="filter-item" @click="handleCreate" type="primary" icon="el-icon-edit">{{$t('table.add')}}</el-button>
</div> </div>
@@ -35,8 +46,7 @@
</el-table-column> </el-table-column>
<el-table-column align="center" :label="$t('table.passType')"> <el-table-column align="center" :label="$t('table.passType')">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag type="success" v-if="scope.row.passType == 'allow'" effect="dark">允许</el-tag> <el-tag :type="scope.row.passType | statusFilter">{{ scope.row.passType | passTypeName }}</el-tag>
<el-tag type="info" v-if="scope.row.passType == 'deny'" effect="dark">拒绝</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<!-- <el-table-column align="center" :label="$t('table.priority')">--> <!-- <el-table-column align="center" :label="$t('table.priority')">-->
@@ -46,12 +56,12 @@
<!-- </el-table-column>--> <!-- </el-table-column>-->
<el-table-column align="center" :label="$t('table.createTime')"> <el-table-column align="center" :label="$t('table.createTime')">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{scope.row.createTime}}</span> <span>{{ scope.row.createTime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" :label="$t('table.updateTime')"> <el-table-column align="center" :label="$t('table.updateTime')">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{scope.row.updateTime}}</span> <span>{{ scope.row.updateTime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column class-name="status-col" :label="$t('table.enableStatus')" width="150"> <el-table-column class-name="status-col" :label="$t('table.enableStatus')" width="150">
@@ -62,13 +72,20 @@
<el-table-column align="center" :label="$t('table.actions')" width="250" class-name="small-padding fixed-width"> <el-table-column align="center" :label="$t('table.actions')" width="250" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-link type="primary" :underline="false" size="mini" @click="handleUpdate(scope.row)" style="font-size:12px">{{$t('table.edit')}}</el-link> <el-link type="primary" :underline="false" size="mini" @click="handleUpdate(scope.row)" style="font-size:12px">{{$t('table.edit')}}</el-link>
<el-link :underline="false" v-if="scope.row.enable =='1'" size="mini" type="warning" @click="handleDisableStatus(scope.row)" style="font-size:12px">{{$t('table.disable')}}</el-link> <el-link :underline="false" v-if="scope.row.enable =='1'" size="mini" type="warning" @click="handleModifyStatus(scope.row, 2)" style="font-size:12px">{{$t('table.disable')}}</el-link>
<el-link :underline="false" v-if="scope.row.enable =='2'" size="mini" type="success" @click="handleEnableStatus(scope.row)" style="font-size:12px">{{$t('table.enable')}}</el-link> <el-link :underline="false" v-if="scope.row.enable =='2'" size="mini" type="success" @click="handleModifyStatus(scope.row, 1)" style="font-size:12px">{{$t('table.enable')}}</el-link>
<LinkPopover @handleCommitClick="handleDelete(scope.row)"/> <LinkPopover @handleCommitClick="handleDelete(scope.row)"/>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div class="pagination-container">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
:current-pageInfo.sync="listQuery.current" :pageInfo-sizes="[10, 20, 30, 50]" :pageInfo-size="listQuery.size"
layout="total, sizes, prev, pager, next, jumper" :total="total">
</el-pagination>
</div>
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" top="4vh"> <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" top="4vh">
<el-form :rules="rules" ref="dataForm" :model="temp" label-position="right" label-width="100px" style='margin-left:50px;margin-right: 150px'> <el-form :rules="rules" ref="dataForm" :model="temp" label-position="right" label-width="100px" style='margin-left:50px;margin-right: 150px'>
<el-form-item :label="$t('table.name')" prop="name"> <el-form-item :label="$t('table.name')" prop="name">
@@ -131,7 +148,7 @@
</template> </template>
<script> <script>
import {fetchGroupDetail, fetchRuleList, createRule, updateRule, deleteRule, enableRule, disableRule} from '@/api/securityGroup' import {fetchGroupDetail, fetchRulePage, createRule, updateRule, deleteRule, updateRuleEnableStatus} from '@/api/securityGroup'
import waves from '@/directive/waves' // 水波纹指令 import waves from '@/directive/waves' // 水波纹指令
import { parseTime } from '@/utils' import { parseTime } from '@/utils'
import LinkPopover from '../../components/Link/linkPopover' import LinkPopover from '../../components/Link/linkPopover'
@@ -150,6 +167,16 @@ import LinkPopover from '../../components/Link/linkPopover'
group: {}, group: {},
tableKey: 0, tableKey: 0,
list: [], list: [],
total: null,
listQuery: {
current: 1,
size: 10,
groupId: undefined,
name: undefined,
description: undefined,
passType: undefined,
enable: undefined
},
listLoading: true, listLoading: true,
temp: { temp: {
id: undefined, id: undefined,
@@ -161,6 +188,12 @@ import LinkPopover from '../../components/Link/linkPopover'
passTypeTooltip: '', passTypeTooltip: '',
priority: 1 priority: 1
}, },
selectObj: {
statusOptions: [{ label: '启用', value: 1 }, { label: '禁用', value: 2 }],
onlineOptions: [{ label: '在线', value: 1 }, { label: '离线', value: 2 }],
passType: [{ label: '允许', value: 1 }, { label: '拒绝', value: 2 }]
},
dialogFormVisible: false, dialogFormVisible: false,
dialogStatus: '', dialogStatus: '',
textMap: { textMap: {
@@ -181,6 +214,13 @@ import LinkPopover from '../../components/Link/linkPopover'
} }
}, },
filters: { filters: {
passTypeName(type) {
const statusMap = {
1: '允许',
2: '拒绝'
}
return statusMap[type]
},
statusName(status) { statusName(status) {
const statusMap = { const statusMap = {
1: '启用', 1: '启用',
@@ -201,39 +241,29 @@ import LinkPopover from '../../components/Link/linkPopover'
}, },
created() { created() {
// eslint-disable-next-line no-sequences // eslint-disable-next-line no-sequences
const queryParam = this.$route.query if (this.$route.query.groupId) {
if (queryParam && typeof queryParam === 'object' && queryParam.groupId) { this.listQuery.groupId = this.$route.query.groupId
this.groupId = queryParam.groupId } else {
localStorage.setItem('groupId', this.groupId) this.$notify({
this.getGroupDetail() title: '错误',
this.getList() message: '没有获取到安全组信息',
return type: 'error',
duration: 3000
})
this.$router.push(`/system/securityGroup`)
return
} }
this.getGroupDetail()
const groupId = localStorage.getItem('groupId') this.getList()
if (groupId) {
this.groupId = parseInt(groupId)
this.getGroupDetail()
this.getList()
return
}
this.$notify({
title: '错误',
message: '没有获取到安全组信息',
type: 'error',
duration: 3000
})
this.$router.push(`/system/securityGroup`)
}, },
methods: { methods: {
getGroupDetail () { getGroupDetail () {
fetchGroupDetail({id: this.groupId}).then(response => { fetchGroupDetail({id: this.listQuery.groupId}).then(response => {
this.group = response.data.data this.group = response.data.data
}) })
}, },
getList() { getList() {
if (!this.groupId) { if (!this.listQuery.groupId) {
this.$notify({ this.$notify({
title: '错误', title: '错误',
message: '没有获取到安全组信息', message: '没有获取到安全组信息',
@@ -243,11 +273,24 @@ import LinkPopover from '../../components/Link/linkPopover'
return return
} }
this.listLoading = true this.listLoading = true
fetchRuleList({groupId: this.groupId}).then(response => { fetchRulePage(this.listQuery).then(response => {
this.list = response.data.data this.list = response.data.data.records
this.total = response.data.data.total
this.listLoading = false this.listLoading = false
}) })
}, },
handleFilter() {
this.listQuery.current = 1
this.getList()
},
handleSizeChange(val) {
this.listQuery.size = val
this.getList()
},
handleCurrentChange(val) {
this.listQuery.current = val
this.getList()
},
handleEnableStatus(row) { handleEnableStatus(row) {
enableRule(row.id).then(response => { enableRule(row.id).then(response => {
if (response.data.code === 0) { if (response.data.code === 0) {
@@ -270,10 +313,21 @@ import LinkPopover from '../../components/Link/linkPopover'
} }
}) })
}, },
handleModifyStatus(row, enable) {
updateRuleEnableStatus(row.id, enable).then(response => {
if (response.data.data.code === 0) {
this.$message({
message: '操作成功',
type: 'success'
})
}
this.getList()
})
},
resetTemp() { resetTemp() {
this.temp = { this.temp = {
id: undefined, id: undefined,
groupId: this.groupId, groupId: this.listQuery.groupId,
name: '', name: '',
description: '', description: '',
rule: '', rule: '',
@@ -293,7 +347,7 @@ import LinkPopover from '../../components/Link/linkPopover'
createData() { createData() {
this.$refs['dataForm'].validate((valid) => { this.$refs['dataForm'].validate((valid) => {
if (valid) { if (valid) {
this.temp.groupId = this.groupId this.temp.groupId = this.listQuery.groupId
createRule(this.temp).then(response => { createRule(this.temp).then(response => {
if (response.data.code === 0) { if (response.data.code === 0) {
this.dialogFormVisible = false this.dialogFormVisible = false
@@ -324,7 +378,7 @@ import LinkPopover from '../../components/Link/linkPopover'
this.$refs['dataForm'].validate((valid) => { this.$refs['dataForm'].validate((valid) => {
if (valid) { if (valid) {
const tempData = Object.assign({}, this.temp) const tempData = Object.assign({}, this.temp)
tempData.groupId = this.groupId tempData.groupId = this.listQuery.groupId
updateRule(tempData).then(response => { updateRule(tempData).then(response => {
if (response.data.code === 0) { if (response.data.code === 0) {
this.$notify({ this.$notify({
@@ -71,6 +71,8 @@ public enum ExceptionConstant {
// 安全组管理(17000) // 安全组管理(17000)
SECURITY_GROUP_NOT_EXIST(17000, "安全组不存在"), SECURITY_GROUP_NOT_EXIST(17000, "安全组不存在"),
SECURITY_RULE_NOT_EXIST(17001, "安全规则不存在"),
; ;
private int code; private int code;
@@ -11,6 +11,6 @@ public enum SecurityRulePassTypeEnum {
NONE(-1, "none") NONE(-1, "none")
; ;
private final Integer code; private final Integer type;
private final String desc; private final String desc;
} }
@@ -2,20 +2,14 @@ package org.dromara.neutrinoproxy.server.controller;
import org.dromara.neutrinoproxy.server.base.page.PageInfo; import org.dromara.neutrinoproxy.server.base.page.PageInfo;
import org.dromara.neutrinoproxy.server.base.page.PageQuery; import org.dromara.neutrinoproxy.server.base.page.PageQuery;
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
import org.dromara.neutrinoproxy.server.controller.req.system.*; import org.dromara.neutrinoproxy.server.controller.req.system.*;
import org.dromara.neutrinoproxy.server.controller.res.system.SecurityGroupDetailRes; import org.dromara.neutrinoproxy.server.controller.res.system.*;
import org.dromara.neutrinoproxy.server.controller.res.system.SecurityGroupListRes;
import org.dromara.neutrinoproxy.server.controller.res.system.SecurityGroupUpdateEnableStatueRes;
import org.dromara.neutrinoproxy.server.controller.res.system.SecurityRuleRes;
import org.dromara.neutrinoproxy.server.dal.entity.SecurityRuleDO;
import org.dromara.neutrinoproxy.server.service.PortMappingService; import org.dromara.neutrinoproxy.server.service.PortMappingService;
import org.dromara.neutrinoproxy.server.service.SecurityGroupService; import org.dromara.neutrinoproxy.server.service.SecurityGroupService;
import org.dromara.neutrinoproxy.server.util.ParamCheckUtil; import org.dromara.neutrinoproxy.server.util.ParamCheckUtil;
import org.noear.solon.annotation.*; import org.noear.solon.annotation.*;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Controller @Controller
@Mapping("/security") @Mapping("/security")
@@ -87,11 +81,18 @@ public class SecurityController {
return groupService.updateGroupEnableStatueReq(req); return groupService.updateGroupEnableStatueReq(req);
} }
@Get
@Mapping("/rule/page")
public PageInfo<SecurityRuleListRes> rulePage(PageQuery pageQuery, SecurityRuleListReq req) {
ParamCheckUtil.checkNotNull(pageQuery, "pageQuery");
return groupService.rulePage(pageQuery, req);
}
@Get @Get
@Mapping("/rule/list") @Mapping("/rule/list")
public List<SecurityRuleRes> getRuleListByGroupId(Integer groupId) { public List<SecurityRuleListRes> getRuleListByGroupId(SecurityRuleListReq req) {
List<SecurityRuleDO> ruleDOList = groupService.queryRuleListByGroupId(groupId); return groupService.ruleList(req);
return ruleDOList.stream().map(SecurityRuleDO::toRes).collect(Collectors.toList());
} }
@Post @Post
@@ -114,15 +115,13 @@ public class SecurityController {
@Post @Post
@Mapping("/rule/enable") @Mapping("/rule/update/enable-status")
public void enableRule(Integer ruleId) { public SecurityRuleUpdateEnableStatueRes updateRuleEnableStatueReq(SecurityRuleUpdateEnableStatueReq req) {
groupService.setRuleStatus(ruleId, EnableStatusEnum.ENABLE); ParamCheckUtil.checkNotNull(req, "req");
} ParamCheckUtil.checkNotNull(req.getId(), "id");
ParamCheckUtil.checkNotNull(req.getEnable(), "enable");
@Post return groupService.updateRuleEnableStatueReq(req);
@Mapping("/rule/disable")
public void disableRule(Integer ruleId) {
groupService.setRuleStatus(ruleId, EnableStatusEnum.DISABLE);
} }
} }
@@ -18,6 +18,6 @@ public class SecurityGroupCreateReq {
/** /**
* 通过类型 * 通过类型
*/ */
private SecurityRulePassTypeEnum defaultPassType; private Integer defaultPassType;
} }
@@ -17,6 +17,6 @@ public class SecurityGroupListReq {
/** /**
* 通过类型 * 通过类型
*/ */
private SecurityRulePassTypeEnum defaultPassType; private Integer defaultPassType;
private Integer enable; private Integer enable;
} }
@@ -47,7 +47,7 @@ public class SecurityRuleCreateReq {
* 放行类型,reject 或 allow * 放行类型,reject 或 allow
* {@link SecurityRulePassTypeEnum} * {@link SecurityRulePassTypeEnum}
*/ */
private SecurityRulePassTypeEnum passType; private Integer passType;
/** /**
* 优先级,数字越小,优先级越高 * 优先级,数字越小,优先级越高
@@ -0,0 +1,16 @@
package org.dromara.neutrinoproxy.server.controller.req.system;
import lombok.Data;
/**
* @author: aoshiguchen
* @date: 2023/12/10
*/
@Data
public class SecurityRuleListReq {
private String groupId;
private String name;
private String description;
private Integer passType;
private Integer enable;
}
@@ -0,0 +1,19 @@
package org.dromara.neutrinoproxy.server.controller.req.system;
import lombok.Data;
/**
* @author: aoshiguchen
* @date: 2023/12/10
*/
@Data
public class SecurityRuleUpdateEnableStatueReq {
/**
* id
*/
private Integer id;
/**
* 启用状态
*/
private Integer enable;
}
@@ -41,7 +41,7 @@ public class SecurityRuleUpdateReq {
* 放行类型,reject 或 allow * 放行类型,reject 或 allow
* {@link SecurityRulePassTypeEnum} * {@link SecurityRulePassTypeEnum}
*/ */
private SecurityRulePassTypeEnum passType; private Integer passType;
/** /**
* 优先级,数字越小,优先级越高 * 优先级,数字越小,优先级越高
@@ -31,7 +31,7 @@ public class SecurityGroupDetailRes {
* 默认放行类型 * 默认放行类型
* {@link SecurityRulePassTypeEnum} * {@link SecurityRulePassTypeEnum}
*/ */
private String defaultPassType; private Integer defaultPassType;
/** /**
* 创建时间 * 创建时间
@@ -5,6 +5,8 @@ import lombok.experimental.Accessors;
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum; import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum; import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum;
import java.util.Date;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class SecurityGroupListRes { public class SecurityGroupListRes {
@@ -31,16 +33,16 @@ public class SecurityGroupListRes {
* 默认放行类型 * 默认放行类型
* {@link SecurityRulePassTypeEnum} * {@link SecurityRulePassTypeEnum}
*/ */
private String defaultPassType; private Integer defaultPassType;
/** /**
* 创建时间 * 创建时间
*/ */
private String createTime; private Date createTime;
/** /**
* 更新时间 * 更新时间
*/ */
private String updateTime; private Date updateTime;
@@ -3,7 +3,6 @@ package org.dromara.neutrinoproxy.server.controller.res.system;
import lombok.Data; import lombok.Data;
import lombok.ToString; import lombok.ToString;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum; import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum;
import java.util.Date; import java.util.Date;
@@ -11,7 +10,7 @@ import java.util.Date;
@Data @Data
@ToString @ToString
@Accessors(chain = true) @Accessors(chain = true)
public class SecurityRuleRes { public class SecurityRuleListRes {
private Integer id; private Integer id;
@@ -44,7 +43,7 @@ public class SecurityRuleRes {
* 放行类型reject allow * 放行类型reject allow
* {@link SecurityRulePassTypeEnum} * {@link SecurityRulePassTypeEnum}
*/ */
private String passType; private Integer passType;
/** /**
* 优先级数字越小优先级越高 * 优先级数字越小优先级越高
@@ -59,10 +58,10 @@ public class SecurityRuleRes {
/** /**
* 创建时间 * 创建时间
*/ */
private String createTime; private Date createTime;
/** /**
* 更新时间 * 更新时间
*/ */
private String updateTime; private Date updateTime;
} }
@@ -0,0 +1,8 @@
package org.dromara.neutrinoproxy.server.controller.res.system;
/**
* @author: aoshiguchen
* @date: 2023/12/10
*/
public class SecurityRuleUpdateEnableStatueRes {
}
@@ -1,7 +1,25 @@
package org.dromara.neutrinoproxy.server.dal; package org.dromara.neutrinoproxy.server.dal;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.dromara.neutrinoproxy.server.controller.req.system.SecurityGroupListReq;
import org.dromara.neutrinoproxy.server.controller.req.system.SecurityRuleListReq;
import org.dromara.neutrinoproxy.server.dal.entity.SecurityGroupDO;
import org.dromara.neutrinoproxy.server.dal.entity.SecurityRuleDO; import org.dromara.neutrinoproxy.server.dal.entity.SecurityRuleDO;
import java.util.Date;
import java.util.List;
public interface SecurityRuleMapper extends BaseMapper<SecurityRuleDO> { public interface SecurityRuleMapper extends BaseMapper<SecurityRuleDO> {
List<SecurityRuleDO> selectByCondition(IPage<SecurityRuleDO> page, @Param("req") SecurityRuleListReq req);
default void updateEnableStatus(Integer id, Integer enable, Date updateTime) {
this.update(null, new LambdaUpdateWrapper<SecurityRuleDO>()
.eq(SecurityRuleDO::getId, id)
.set(SecurityRuleDO::getEnable, enable)
.set(SecurityRuleDO::getUpdateTime, updateTime)
);
}
} }
@@ -49,7 +49,7 @@ public class SecurityGroupDO {
* 默认放行类型 * 默认放行类型
* {@link SecurityRulePassTypeEnum} * {@link SecurityRulePassTypeEnum}
*/ */
private SecurityRulePassTypeEnum defaultPassType; private Integer defaultPassType;
/** /**
* 创建时间 * 创建时间
@@ -63,18 +63,12 @@ public class SecurityGroupDO {
public SecurityGroupListRes toListRes() { public SecurityGroupListRes toListRes() {
SecurityGroupListRes res = new SecurityGroupListRes(); SecurityGroupListRes res = new SecurityGroupListRes();
BeanUtil.copyProperties(this, res); BeanUtil.copyProperties(this, res);
res.setDefaultPassType(defaultPassType.getDesc())
.setCreateTime(DateUtil.format(this.getCreateTime(), DatePattern.NORM_DATETIME_FORMAT))
.setUpdateTime(DateUtil.format(this.getUpdateTime(), DatePattern.NORM_DATETIME_FORMAT));
return res; return res;
} }
public SecurityGroupDetailRes toDetailRes() { public SecurityGroupDetailRes toDetailRes() {
SecurityGroupDetailRes res = new SecurityGroupDetailRes(); SecurityGroupDetailRes res = new SecurityGroupDetailRes();
BeanUtil.copyProperties(this, res); BeanUtil.copyProperties(this, res);
res.setDefaultPassType(defaultPassType.getDesc())
.setCreateTime(DateUtil.format(this.getCreateTime(), DatePattern.NORM_DATETIME_FORMAT))
.setUpdateTime(DateUtil.format(this.getUpdateTime(), DatePattern.NORM_DATETIME_FORMAT));
return res; return res;
} }
} }
@@ -1,8 +1,6 @@
package org.dromara.neutrinoproxy.server.dal.entity; package org.dromara.neutrinoproxy.server.dal.entity;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.net.Ipv4Util; import cn.hutool.core.net.Ipv4Util;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
@@ -13,7 +11,7 @@ import lombok.ToString;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum; import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum; import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum;
import org.dromara.neutrinoproxy.server.controller.res.system.SecurityRuleRes; import org.dromara.neutrinoproxy.server.controller.res.system.SecurityRuleListRes;
import java.util.Date; import java.util.Date;
@@ -55,7 +53,7 @@ public class SecurityRuleDO {
* 放行类型,reject 或 allow * 放行类型,reject 或 allow
* {@link SecurityRulePassTypeEnum} * {@link SecurityRulePassTypeEnum}
*/ */
private SecurityRulePassTypeEnum passType; private Integer passType;
/** /**
* 优先级,数字越小,优先级越高 * 优先级,数字越小,优先级越高
@@ -113,7 +111,7 @@ public class SecurityRuleDO {
// 单个ip,ipv6在此步已处理,后面不需要额外判断ipv6的情况 // 单个ip,ipv6在此步已处理,后面不需要额外判断ipv6的情况
if (rule.matches("(\\d+\\.){3}\\d+") || isIpv6) { if (rule.matches("(\\d+\\.){3}\\d+") || isIpv6) {
if (rule.equalsIgnoreCase(ip)) { if (rule.equalsIgnoreCase(ip)) {
return passType == SecurityRulePassTypeEnum.ALLOW ? SecurityRulePassTypeEnum.ALLOW : SecurityRulePassTypeEnum.DENY; return SecurityRulePassTypeEnum.ALLOW.getType().equals(passType) ? SecurityRulePassTypeEnum.ALLOW : SecurityRulePassTypeEnum.DENY;
} }
} }
@@ -121,7 +119,7 @@ public class SecurityRuleDO {
if (rule.matches("(\\d+\\.){3}\\d+-(\\d+\\.){3}\\d+")) { if (rule.matches("(\\d+\\.){3}\\d+-(\\d+\\.){3}\\d+")) {
String[] ipRange = rule.split("-"); String[] ipRange = rule.split("-");
if (ipRange[0].compareTo(ip) <= 0 && ip.compareTo(ipRange[1]) <= 0) { if (ipRange[0].compareTo(ip) <= 0 && ip.compareTo(ipRange[1]) <= 0) {
return passType == SecurityRulePassTypeEnum.ALLOW ? SecurityRulePassTypeEnum.ALLOW : SecurityRulePassTypeEnum.DENY; return SecurityRulePassTypeEnum.ALLOW.getType().equals(passType) ? SecurityRulePassTypeEnum.ALLOW : SecurityRulePassTypeEnum.DENY;
} }
} }
@@ -131,12 +129,12 @@ public class SecurityRuleDO {
Long beginIp = Ipv4Util.getBeginIpLong(netIp[0], Integer.parseInt(netIp[1])); Long beginIp = Ipv4Util.getBeginIpLong(netIp[0], Integer.parseInt(netIp[1]));
Long endIp = Ipv4Util.getEndIpLong(netIp[0], Integer.parseInt(netIp[1])); Long endIp = Ipv4Util.getEndIpLong(netIp[0], Integer.parseInt(netIp[1]));
if (beginIp <= ipLong && ipLong <= endIp) { if (beginIp <= ipLong && ipLong <= endIp) {
return passType == SecurityRulePassTypeEnum.ALLOW ? SecurityRulePassTypeEnum.ALLOW : SecurityRulePassTypeEnum.DENY; return SecurityRulePassTypeEnum.ALLOW.getType().equals(passType) ? SecurityRulePassTypeEnum.ALLOW : SecurityRulePassTypeEnum.DENY;
} }
} }
if (rule.equalsIgnoreCase("ALL") || rule.equals("0.0.0.0") || rule.equals("0.0.0.0/0")) { if (rule.equalsIgnoreCase("ALL") || rule.equals("0.0.0.0") || rule.equals("0.0.0.0/0")) {
return passType == SecurityRulePassTypeEnum.ALLOW ? SecurityRulePassTypeEnum.ALLOW : SecurityRulePassTypeEnum.DENY; return SecurityRulePassTypeEnum.ALLOW.getType().equals(passType) ? SecurityRulePassTypeEnum.ALLOW : SecurityRulePassTypeEnum.DENY;
} }
} }
@@ -145,13 +143,9 @@ public class SecurityRuleDO {
return SecurityRulePassTypeEnum.NONE; return SecurityRulePassTypeEnum.NONE;
} }
public SecurityRuleRes toRes() { public SecurityRuleListRes toListRes() {
SecurityRuleRes res = new SecurityRuleRes(); SecurityRuleListRes res = new SecurityRuleListRes();
BeanUtil.copyProperties(this, res); BeanUtil.copyProperties(this, res);
res.setPassType(this.passType.getDesc())
.setCreateTime(DateUtil.format(this.getCreateTime(), DatePattern.NORM_DATETIME_FORMAT))
.setUpdateTime(DateUtil.format(this.getUpdateTime(), DatePattern.NORM_DATETIME_FORMAT))
;
return res; return res;
} }
@@ -4,6 +4,7 @@ import cn.hutool.cache.Cache;
import cn.hutool.cache.CacheUtil; import cn.hutool.cache.CacheUtil;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -17,9 +18,7 @@ import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
import org.dromara.neutrinoproxy.server.constant.ExceptionConstant; import org.dromara.neutrinoproxy.server.constant.ExceptionConstant;
import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum; import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum;
import org.dromara.neutrinoproxy.server.controller.req.system.*; import org.dromara.neutrinoproxy.server.controller.req.system.*;
import org.dromara.neutrinoproxy.server.controller.res.system.SecurityGroupDetailRes; import org.dromara.neutrinoproxy.server.controller.res.system.*;
import org.dromara.neutrinoproxy.server.controller.res.system.SecurityGroupListRes;
import org.dromara.neutrinoproxy.server.controller.res.system.SecurityGroupUpdateEnableStatueRes;
import org.dromara.neutrinoproxy.server.dal.SecurityGroupMapper; import org.dromara.neutrinoproxy.server.dal.SecurityGroupMapper;
import org.dromara.neutrinoproxy.server.dal.SecurityRuleMapper; import org.dromara.neutrinoproxy.server.dal.SecurityRuleMapper;
import org.dromara.neutrinoproxy.server.dal.entity.SecurityGroupDO; import org.dromara.neutrinoproxy.server.dal.entity.SecurityGroupDO;
@@ -70,17 +69,17 @@ public class SecurityGroupService {
public PageInfo<SecurityGroupListRes> groupPage(PageQuery pageQuery, SecurityGroupListReq req) { public PageInfo<SecurityGroupListRes> groupPage(PageQuery pageQuery, SecurityGroupListReq req) {
if (StringUtils.isNotEmpty(req.getName())) { if (StringUtils.isNotEmpty(req.getName())) {
//描述字段为模糊查询,在应用层处理,否则sqlite不支持 //在应用层处理,否则sqlite不支持
req.setName("%" + req.getName() + "%"); req.setName("%" + req.getName() + "%");
} }
if (StringUtils.isNotEmpty(req.getDescription())) { if (StringUtils.isNotEmpty(req.getDescription())) {
//描述字段为模糊查询,在应用层处理,否则sqlite不支持 //在应用层处理,否则sqlite不支持
req.setDescription("%" + req.getDescription() + "%"); req.setDescription("%" + req.getDescription() + "%");
} }
Page<SecurityGroupDO> page = new Page<>(pageQuery.getCurrent(), pageQuery.getSize()); Page<SecurityGroupDO> page = new Page<>(pageQuery.getCurrent(), pageQuery.getSize());
List<SecurityGroupDO> list = securityGroupMapper.selectByCondition(page, req); List<SecurityGroupDO> list = securityGroupMapper.selectByCondition(page, req);
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
PageInfo.of(null, page.getTotal(), pageQuery.getCurrent(), pageQuery.getSize()); return PageInfo.of(null, page.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
} }
List<SecurityGroupListRes> respList = list.stream().map(SecurityGroupDO::toListRes).collect(Collectors.toList()); List<SecurityGroupListRes> respList = list.stream().map(SecurityGroupDO::toListRes).collect(Collectors.toList());
return PageInfo.of(respList, page.getTotal(), pageQuery.getCurrent(), pageQuery.getSize()); return PageInfo.of(respList, page.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
@@ -145,11 +144,32 @@ public class SecurityGroupService {
return new SecurityGroupUpdateEnableStatueRes(); return new SecurityGroupUpdateEnableStatueRes();
} }
public List<SecurityRuleDO> queryRuleListByGroupId(Integer groupId) { public PageInfo<SecurityRuleListRes> rulePage(PageQuery pageQuery, SecurityRuleListReq req) {
return securityRuleMapper.selectList(Wrappers.lambdaQuery(SecurityRuleDO.class) if (StringUtils.isNotEmpty(req.getName())) {
.eq(SecurityRuleDO::getGroupId, groupId) //在应用层处理,否则sqlite不支持
.orderByAsc(SecurityRuleDO::getPriority) req.setName("%" + req.getName() + "%");
}
if (StringUtils.isNotEmpty(req.getDescription())) {
//在应用层处理,否则sqlite不支持
req.setDescription("%" + req.getDescription() + "%");
}
Page<SecurityRuleDO> page = new Page<>(pageQuery.getCurrent(), pageQuery.getSize());
List<SecurityRuleDO> list = securityRuleMapper.selectByCondition(page, req);
if (CollectionUtils.isEmpty(list)) {
return PageInfo.of(null, page.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
}
List<SecurityRuleListRes> respList = list.stream().map(SecurityRuleDO::toListRes).collect(Collectors.toList());
return PageInfo.of(respList, page.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
}
public List<SecurityRuleListRes> ruleList(SecurityRuleListReq req) {
List<SecurityRuleDO> list = securityRuleMapper.selectList(new LambdaQueryWrapper<SecurityRuleDO>()
.eq(null != req.getGroupId(), SecurityRuleDO::getGroupId, req.getGroupId())
); );
if (CollectionUtils.isEmpty(list)) {
return Collections.emptyList();
}
return list.stream().map(SecurityRuleDO::toListRes).collect(Collectors.toList());
} }
public void createRule(SecurityRuleCreateReq req) { public void createRule(SecurityRuleCreateReq req) {
@@ -175,12 +195,13 @@ public class SecurityGroupService {
clearCache(); clearCache();
} }
public void setRuleStatus(Integer ruleId, EnableStatusEnum statusEnum) { public SecurityRuleUpdateEnableStatueRes updateRuleEnableStatueReq(SecurityRuleUpdateEnableStatueReq req) {
SecurityRuleDO ruleDO = securityRuleMapper.selectById(ruleId); SecurityRuleDO ruleDO = securityRuleMapper.selectById(req.getId());
ruleDO.setEnable(statusEnum.getStatus()); ParamCheckUtil.checkNotNull(ruleDO, ExceptionConstant.SECURITY_RULE_NOT_EXIST);
ruleDO.setUpdateTime(new Date());
securityRuleMapper.updateById(ruleDO); securityRuleMapper.updateEnableStatus(req.getId(), req.getEnable(), new Date());
clearCache(); clearCache();
return new SecurityRuleUpdateEnableStatueRes();
} }
/** /**
@@ -235,7 +256,7 @@ public class SecurityGroupService {
// 当前IP没有匹配到任何一条规则,则使用安全组默认规则 // 当前IP没有匹配到任何一条规则,则使用安全组默认规则
if (allow == null) { if (allow == null) {
allow = groupDO.getDefaultPassType() == SecurityRulePassTypeEnum.ALLOW; allow = SecurityRulePassTypeEnum.ALLOW.getType().equals(groupDO.getDefaultPassType());
log.debug("[SecurityGroup] ip:{} groupId{} use security group default strategy:{}", ip, groupId, allow ? "allow" : "reject"); log.debug("[SecurityGroup] ip:{} groupId{} use security group default strategy:{}", ip, groupId, allow ? "allow" : "reject");
} }
@@ -0,0 +1,26 @@
<?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.SecurityRuleMapper">
<select id="selectByCondition" resultType="org.dromara.neutrinoproxy.server.dal.entity.SecurityRuleDO">
SELECT sr.* from security_rule sr
<where>
<if test="req.groupId != null">
AND sr.group_id = ${req.groupId}
</if>
<if test="req.name != null and req.name != '' ">
AND sr.name like #{req.name}
</if>
<if test="req.description != null and req.description != '' ">
AND sr.description like #{req.description}
</if>
<if test="req.passType != null">
AND sr.pass_type like #{req.passType}
</if>
<if test="req.enable != null">
AND sr.enable like #{req.enable}
</if>
</where>
order by sr.id DESC
</select>
</mapper>
@@ -53,7 +53,7 @@ CREATE TABLE IF NOT EXISTS `security_group` (
`description` VARCHAR(255), `description` VARCHAR(255),
`user_id` INTEGER NOT NULL, `user_id` INTEGER NOT NULL,
`enable` INTEGER NOT NULL, `enable` INTEGER NOT NULL,
`default_pass_type` VARCHAR(20) NOT NULL, `default_pass_type` INTEGER NOT NULL,
`create_time` TIMESTAMP NOT NULL, `create_time` TIMESTAMP NOT NULL,
`update_time` TIMESTAMP NOT NULL, `update_time` TIMESTAMP NOT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
@@ -66,7 +66,7 @@ CREATE TABLE IF NOT EXISTS `security_rule` (
`name` VARCHAR(20) NOT NULL, `name` VARCHAR(20) NOT NULL,
`description` VARCHAR(255) NOT NULL, `description` VARCHAR(255) NOT NULL,
`rule` text NOT NULL, `rule` text NOT NULL,
`pass_type` VARCHAR(20) NOT NULL, `pass_type` INTEGER NOT NULL,
`priority` INTEGER NOT NULL, `priority` INTEGER NOT NULL,
`user_id` INTEGER NOT NULL, `user_id` INTEGER NOT NULL,
`enable` INTEGER NOT NULL, `enable` INTEGER NOT NULL,
@@ -5,7 +5,7 @@ CREATE TABLE IF NOT EXISTS `security_group` (
`description` VARCHAR(255), `description` VARCHAR(255),
`user_id` INTEGER NOT NULL, `user_id` INTEGER NOT NULL,
`enable` INTEGER NOT NULL, `enable` INTEGER NOT NULL,
`default_pass_type` VARCHAR(20) NOT NULL, `default_pass_type` INTEGER NOT NULL,
`create_time` TIMESTAMP NOT NULL, `create_time` TIMESTAMP NOT NULL,
`update_time` TIMESTAMP NOT NULL, `update_time` TIMESTAMP NOT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
@@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS `security_rule` (
`name` VARCHAR(20) NOT NULL, `name` VARCHAR(20) NOT NULL,
`description` VARCHAR(255) NOT NULL, `description` VARCHAR(255) NOT NULL,
`rule` text NOT NULL, `rule` text NOT NULL,
`pass_type` VARCHAR(20) NOT NULL, `pass_type` INTEGER NOT NULL,
`priority` INTEGER NOT NULL, `priority` INTEGER NOT NULL,
`user_id` INTEGER NOT NULL, `user_id` INTEGER NOT NULL,
`enable` INTEGER NOT NULL, `enable` INTEGER NOT NULL,
@@ -57,7 +57,7 @@ CREATE TABLE IF NOT EXISTS `security_group` (
`description` varchar(255) COMMENT '安全组描述', `description` varchar(255) COMMENT '安全组描述',
`user_id` int NOT NULL COMMENT '用户ID', `user_id` int NOT NULL COMMENT '用户ID',
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)', `enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
`default_pass_type` varchar(20) NOT NULL COMMENT '默认放行类型', `default_pass_type` int NOT NULL COMMENT '默认放行类型',
`create_time` datetime(3) NOT NULL COMMENT '创建时间', `create_time` datetime(3) NOT NULL COMMENT '创建时间',
`update_time` datetime(3) NOT NULL COMMENT '更新时间', `update_time` datetime(3) NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
@@ -70,7 +70,7 @@ CREATE TABLE IF NOT EXISTS `security_rule` (
`name` varchar(20) NOT NULL COMMENT '规则名称', `name` varchar(20) NOT NULL COMMENT '规则名称',
`description` varchar(255) NOT NULL COMMENT '规则描述', `description` varchar(255) NOT NULL COMMENT '规则描述',
`rule` text NOT NULL COMMENT '规则内容', `rule` text NOT NULL COMMENT '规则内容',
`pass_type` varchar(20) NOT NULL COMMENT '放行类型', `pass_type` int NOT NULL COMMENT '放行类型',
`priority` int(1) NOT NULL COMMENT '优先级', `priority` int(1) NOT NULL COMMENT '优先级',
`user_id` int NOT NULL COMMENT '用户ID', `user_id` int NOT NULL COMMENT '用户ID',
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)', `enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
@@ -57,7 +57,7 @@ CREATE TABLE IF NOT EXISTS `security_group` (
`description` varchar(255) COMMENT '安全组描述', `description` varchar(255) COMMENT '安全组描述',
`user_id` int NOT NULL COMMENT '用户ID', `user_id` int NOT NULL COMMENT '用户ID',
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)', `enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
`default_pass_type` varchar(20) NOT NULL COMMENT '默认放行类型', `default_pass_type` int NOT NULL COMMENT '默认放行类型',
`create_time` datetime(3) NOT NULL COMMENT '创建时间', `create_time` datetime(3) NOT NULL COMMENT '创建时间',
`update_time` datetime(3) NOT NULL COMMENT '更新时间', `update_time` datetime(3) NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
@@ -70,7 +70,7 @@ CREATE TABLE IF NOT EXISTS `security_rule` (
`name` varchar(20) NOT NULL COMMENT '规则名称', `name` varchar(20) NOT NULL COMMENT '规则名称',
`description` varchar(255) NOT NULL COMMENT '规则描述', `description` varchar(255) NOT NULL COMMENT '规则描述',
`rule` text NOT NULL COMMENT '规则内容', `rule` text NOT NULL COMMENT '规则内容',
`pass_type` varchar(20) NOT NULL COMMENT '放行类型', `pass_type` int NOT NULL COMMENT '放行类型',
`priority` int(1) NOT NULL COMMENT '优先级', `priority` int(1) NOT NULL COMMENT '优先级',
`user_id` int NOT NULL COMMENT '用户ID', `user_id` int NOT NULL COMMENT '用户ID',
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)', `enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
@@ -5,7 +5,7 @@ CREATE TABLE IF NOT EXISTS `security_group` (
`description` varchar(255) COMMENT '安全组描述', `description` varchar(255) COMMENT '安全组描述',
`user_id` int NOT NULL COMMENT '用户ID', `user_id` int NOT NULL COMMENT '用户ID',
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)', `enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
`default_pass_type` varchar(20) NOT NULL COMMENT '默认放行类型', `default_pass_type` int NOT NULL COMMENT '默认放行类型',
`create_time` datetime(3) NOT NULL COMMENT '创建时间', `create_time` datetime(3) NOT NULL COMMENT '创建时间',
`update_time` datetime(3) NOT NULL COMMENT '更新时间', `update_time` datetime(3) NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
@@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS `security_rule` (
`name` varchar(20) NOT NULL COMMENT '规则名称', `name` varchar(20) NOT NULL COMMENT '规则名称',
`description` varchar(255) NOT NULL COMMENT '规则描述', `description` varchar(255) NOT NULL COMMENT '规则描述',
`rule` text NOT NULL COMMENT '规则内容', `rule` text NOT NULL COMMENT '规则内容',
`pass_type` varchar(20) NOT NULL COMMENT '放行类型', `pass_type`int NOT NULL COMMENT '放行类型',
`priority` int(1) NOT NULL COMMENT '优先级', `priority` int(1) NOT NULL COMMENT '优先级',
`user_id` int NOT NULL COMMENT '用户ID', `user_id` int NOT NULL COMMENT '用户ID',
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)', `enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',