From 1e2b3b34520218d910ca72754e3eaa4dd8d7ae09 Mon Sep 17 00:00:00 2001 From: aoshiguchen <1052045476@qq.com> Date: Wed, 12 Oct 2022 18:18:54 +0800 Subject: [PATCH 01/55] =?UTF-8?q?=E4=BC=98=E5=8C=96HttpRequestHandler?= =?UTF-8?q?=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../asgc/neutrino/core/web/HttpRequestHandler.java | 13 ++++++++----- .../base/rest/interceptor/BaseAuthInterceptor.java | 5 ----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/HttpRequestHandler.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/HttpRequestHandler.java index 65017509..2d2e0b6f 100644 --- a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/HttpRequestHandler.java +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/HttpRequestHandler.java @@ -40,9 +40,11 @@ import fun.asgc.neutrino.core.web.router.HttpRouteParam; import fun.asgc.neutrino.core.web.router.HttpRouteResult; import fun.asgc.neutrino.core.web.router.HttpRouterType; import io.netty.buffer.Unpooled; -import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.http.*; +import io.netty.handler.codec.http.FullHttpRequest; +import io.netty.handler.codec.http.HttpHeaderNames; +import io.netty.handler.codec.http.HttpHeaderValues; +import io.netty.handler.codec.http.HttpResponseStatus; import lombok.extern.slf4j.Slf4j; import java.lang.reflect.Field; @@ -117,9 +119,10 @@ public class HttpRequestHandler { httpResponseWrapper.writeAndFlush(); return; } else if(HttpRouterType.PAGE == httpRouteResult.getType()) { - if (!preHandle(httpRouteResult.getPageRoute(), null)) { - return; - } + // 静态页面无需前置拦截 +// if (!preHandle(httpRouteResult.getPageRoute(), null)) { +// return; +// } // 前端页面 String mimeType = MimeType.getMimeType(MimeType.parseSuffix(httpRouteResult.getPageLocation())); diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/interceptor/BaseAuthInterceptor.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/interceptor/BaseAuthInterceptor.java index 955c943b..40320809 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/interceptor/BaseAuthInterceptor.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/interceptor/BaseAuthInterceptor.java @@ -46,11 +46,6 @@ public class BaseAuthInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpRequestWrapper requestParser, HttpResponseWrapper responseWrapper, String route, Method targetMethod) throws Exception { - // TODO 临时解决静态页面被拦截的问题 - if (null == targetMethod) { - return true; - } - SystemContext systemContext = new SystemContext(); SystemContextHolder.set(systemContext); systemContext.setIp(HttpUtil.getIP(HttpContextHolder.getChannelHandlerContext(), requestParser)); From 8baf7f3a370526773418553d4596baae4f6ecbc6 Mon Sep 17 00:00:00 2001 From: aoshiguchen <1052045476@qq.com> Date: Wed, 12 Oct 2022 18:41:26 +0800 Subject: [PATCH 02/55] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=96=B0=E5=A2=9Elicen?= =?UTF-8?q?se=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fun/asgc/neutrino/proxy/server/service/LicenseService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/LicenseService.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/LicenseService.java index 0895ad95..a744706c 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/LicenseService.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/LicenseService.java @@ -103,7 +103,7 @@ public class LicenseService { */ public LicenseCreateRes create(LicenseCreateReq req) { LicenseDO licenseDO = licenseMapper.checkRepeat(req.getUserId(), req.getName()); - ParamCheckUtil.checkNotNull(licenseDO, ExceptionConstant.LICENSE_NAME_CANNOT_REPEAT); + ParamCheckUtil.checkExpression(null == licenseDO, ExceptionConstant.LICENSE_NAME_CANNOT_REPEAT); String key = UUID.randomUUID().toString().replaceAll("-", ""); Date now = new Date(); From 5a928d16605ed93f0d93da9b218a844c31ade151 Mon Sep 17 00:00:00 2001 From: aoshiguchen <1052045476@qq.com> Date: Wed, 12 Oct 2022 19:11:03 +0800 Subject: [PATCH 03/55] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3=E6=98=A0=E5=B0=84=E6=8A=A5=E9=94=99.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../asgc/neutrino/proxy/server/service/PortMappingService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/PortMappingService.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/PortMappingService.java index fd9843f3..0aa5e03e 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/PortMappingService.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/PortMappingService.java @@ -107,7 +107,7 @@ public class PortMappingService { } PortPoolDO portPoolDO = portPoolMapper.findByPort(req.getServerPort()); ParamCheckUtil.checkNotNull(portPoolDO, ExceptionConstant.PORT_NOT_EXIST); - ParamCheckUtil.checkNotNull(portMappingMapper.findByPort(req.getServerPort()), ExceptionConstant.PORT_CANNOT_REPEAT_MAPPING, req.getServerPort()); + ParamCheckUtil.checkExpression(null == portMappingMapper.findByPort(req.getServerPort()), ExceptionConstant.PORT_CANNOT_REPEAT_MAPPING, req.getServerPort()); Date now = new Date(); From 94fe6f8aef4dbba2eee396bf64750cec3849a563 Mon Sep 17 00:00:00 2001 From: aoshiguchen <1052045476@qq.com> Date: Wed, 12 Oct 2022 20:28:24 +0800 Subject: [PATCH 04/55] =?UTF-8?q?=E8=A7=A3=E5=86=B3license=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=88=A0=E9=99=A4=E5=90=8E=EF=BC=8C=E7=AB=AF=E5=8F=A3?= =?UTF-8?q?=E6=98=A0=E5=B0=84=E7=AE=A1=E7=90=86=E5=BC=82=E5=B8=B8=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/service/PortMappingService.java | 50 +++++++++++-------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/PortMappingService.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/PortMappingService.java index 0aa5e03e..ac06c7f0 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/PortMappingService.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/PortMappingService.java @@ -74,27 +74,34 @@ public class PortMappingService { public Page page(PageQuery pageQuery, PortMappingListReq req) { Page page = Page.create(pageQuery); portMappingMapper.page(page, req); - if (!CollectionUtil.isEmpty(page.getRecords())) { - Set licenseIds = page.getRecords().stream().map(PortMappingListRes::getLicenseId).collect(Collectors.toSet()); - List licenseList = licenseMapper.findByIds(licenseIds); - Set userIds = licenseList.stream().map(LicenseDO::getUserId).collect(Collectors.toSet()); - List userList = userMapper.findByIds(userIds); - Map licenseMap = licenseList.stream().collect(Collectors.toMap(LicenseDO::getId, Function.identity())); - Map userMap = userList.stream().collect(Collectors.toMap(UserDO::getId, Function.identity())); - page.getRecords().forEach(item -> { - LicenseDO license = licenseMap.get(item.getLicenseId()); - if (null == license) { - return; - } - item.setLicenseName(license.getName()); - item.setUserId(license.getUserId()); - UserDO user = userMap.get(license.getUserId()); - if (null == user) { - return; - } - item.setUserName(user.getName()); - }); + if (CollectionUtil.isEmpty(page.getRecords())) { + return page; } + Set licenseIds = page.getRecords().stream().map(PortMappingListRes::getLicenseId).collect(Collectors.toSet()); + if (CollectionUtil.isEmpty(licenseIds)) { + return page; + } + List licenseList = licenseMapper.findByIds(licenseIds); + if (CollectionUtil.isEmpty(licenseList)) { + return page; + } + Set userIds = licenseList.stream().map(LicenseDO::getUserId).collect(Collectors.toSet()); + List userList = userMapper.findByIds(userIds); + Map licenseMap = licenseList.stream().collect(Collectors.toMap(LicenseDO::getId, Function.identity())); + Map userMap = userList.stream().collect(Collectors.toMap(UserDO::getId, Function.identity())); + page.getRecords().forEach(item -> { + LicenseDO license = licenseMap.get(item.getLicenseId()); + if (null == license) { + return; + } + item.setLicenseName(license.getName()); + item.setUserId(license.getUserId()); + UserDO user = userMap.get(license.getUserId()); + if (null == user) { + return; + } + item.setUserName(user.getName()); + }); return page; } @@ -196,8 +203,7 @@ public class PortMappingService { ParamCheckUtil.checkNotNull(portMappingDO, ExceptionConstant.PORT_MAPPING_NOT_EXIST); LicenseDO licenseDO = licenseMapper.findById(portMappingDO.getLicenseId()); - ParamCheckUtil.checkNotNull(licenseDO, ExceptionConstant.LICENSE_NOT_EXIST); - if (!SystemContextHolder.isAdmin()) { + if (null != licenseDO && !SystemContextHolder.isAdmin()) { // 临时处理,如果当前用户不是管理员,则操作userId不能为1 ParamCheckUtil.checkExpression(!licenseDO.getUserId().equals(1), ExceptionConstant.NO_PERMISSION_VISIT); } From 7fa4d6d8fa1c67f183a8691fb4275ffe5402b4e7 Mon Sep 17 00:00:00 2001 From: aoshiguchen <1052045476@qq.com> Date: Thu, 13 Oct 2022 23:14:34 +0800 Subject: [PATCH 05/55] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=AB=AF=E5=8F=A3?= =?UTF-8?q?=E6=98=A0=E5=B0=84=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../asgc/neutrino/proxy/server/service/PortMappingService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/PortMappingService.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/PortMappingService.java index ac06c7f0..fea4edce 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/PortMappingService.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/PortMappingService.java @@ -140,7 +140,7 @@ public class PortMappingService { } PortPoolDO portPoolDO = portPoolMapper.findByPort(req.getServerPort()); ParamCheckUtil.checkNotNull(portPoolDO, ExceptionConstant.PORT_NOT_EXIST); - ParamCheckUtil.checkNotNull(portMappingMapper.findByPort(req.getServerPort(), Sets.newHashSet(req.getId())), ExceptionConstant.PORT_CANNOT_REPEAT_MAPPING, req.getServerPort()); + ParamCheckUtil.checkExpression(null == portMappingMapper.findByPort(req.getServerPort(), Sets.newHashSet(req.getId())), ExceptionConstant.PORT_CANNOT_REPEAT_MAPPING, req.getServerPort()); PortMappingDO portMappingDO = new PortMappingDO(); portMappingDO.setId(req.getId()); From 47be82ba95601eed44901a54cf6df854e7a92638 Mon Sep 17 00:00:00 2001 From: aoshiguchen <1052045476@qq.com> Date: Fri, 14 Oct 2022 17:42:34 +0800 Subject: [PATCH 06/55] =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=97=A0=E6=95=88=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../proxy/server/proxy/handler/ProxyMessageAuthHandler.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/proxy/handler/ProxyMessageAuthHandler.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/proxy/handler/ProxyMessageAuthHandler.java index f1afecfb..ed8ec681 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/proxy/handler/ProxyMessageAuthHandler.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/proxy/handler/ProxyMessageAuthHandler.java @@ -86,30 +86,25 @@ public class ProxyMessageAuthHandler implements ProxyMessageHandler { String licenseKey = proxyMessage.getInfo(); if (StringUtil.isEmpty(licenseKey)) { ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "license不能为空!", licenseKey)); -// ctx.channel().close(); return; } LicenseDO licenseDO = licenseService.findByKey(licenseKey); if (null == licenseDO) { ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "license不存在!", licenseKey)); -// ctx.channel().close(); return; } if (EnableStatusEnum.DISABLE.getStatus().equals(licenseDO.getEnable())) { ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "当前license已被禁用!", licenseKey)); -// ctx.channel().close(); return; } UserDO userDO = userService.findById(licenseDO.getId()); if (null == userDO || EnableStatusEnum.DISABLE.getStatus().equals(userDO.getEnable())) { ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "当前license无效!", licenseKey)); -// ctx.channel().close(); return; } Channel cmdChannel = ProxyUtil.getCmdChannelByLicenseId(licenseDO.getId()); if (null != cmdChannel) { ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "当前license已被另一节点使用!", licenseKey)); -// ctx.channel().close(); return; } // 发送认证成功消息 From 033196d955032b3fec8428ae6da05d9777c1571f Mon Sep 17 00:00:00 2001 From: aoshiguchen <1052045476@qq.com> Date: Fri, 14 Oct 2022 22:04:08 +0800 Subject: [PATCH 07/55] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E7=9A=84=E5=88=86=E9=A1=B5=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- neutrino-proxy-admin/src/views/proxy/license.vue | 2 +- neutrino-proxy-admin/src/views/proxy/portMapping.vue | 2 +- neutrino-proxy-admin/src/views/system/jobLog.vue | 2 +- neutrino-proxy-admin/src/views/system/jobManager.vue | 2 +- neutrino-proxy-admin/src/views/system/portPool.vue | 2 +- neutrino-proxy-admin/src/views/system/user.vue | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/neutrino-proxy-admin/src/views/proxy/license.vue b/neutrino-proxy-admin/src/views/proxy/license.vue index a116799f..64c0bb39 100644 --- a/neutrino-proxy-admin/src/views/proxy/license.vue +++ b/neutrino-proxy-admin/src/views/proxy/license.vue @@ -133,7 +133,7 @@ listLoading: true, listQuery: { currentPage: 1, - pageSize: 20, + pageSize: 10, importance: undefined, title: undefined, type: undefined diff --git a/neutrino-proxy-admin/src/views/proxy/portMapping.vue b/neutrino-proxy-admin/src/views/proxy/portMapping.vue index 3730df9a..ad46866a 100644 --- a/neutrino-proxy-admin/src/views/proxy/portMapping.vue +++ b/neutrino-proxy-admin/src/views/proxy/portMapping.vue @@ -172,7 +172,7 @@ listLoading: true, listQuery: { currentPage: 1, - pageSize: 20, + pageSize: 10, importance: undefined, title: undefined, type: undefined diff --git a/neutrino-proxy-admin/src/views/system/jobLog.vue b/neutrino-proxy-admin/src/views/system/jobLog.vue index 94340f77..ffffebd4 100644 --- a/neutrino-proxy-admin/src/views/system/jobLog.vue +++ b/neutrino-proxy-admin/src/views/system/jobLog.vue @@ -71,7 +71,7 @@ export default { listLoading: false, listQuery: { currentPage: 1, - pageSize: 20, + pageSize: 10, jobId: undefined }, jobList: [] diff --git a/neutrino-proxy-admin/src/views/system/jobManager.vue b/neutrino-proxy-admin/src/views/system/jobManager.vue index 1521f03d..8b62a349 100644 --- a/neutrino-proxy-admin/src/views/system/jobManager.vue +++ b/neutrino-proxy-admin/src/views/system/jobManager.vue @@ -115,7 +115,7 @@ listLoading: true, listQuery: { currentPage: 1, - pageSize: 20, + pageSize: 10, importance: undefined, title: undefined, type: undefined diff --git a/neutrino-proxy-admin/src/views/system/portPool.vue b/neutrino-proxy-admin/src/views/system/portPool.vue index 2bb4fcbe..134f4512 100644 --- a/neutrino-proxy-admin/src/views/system/portPool.vue +++ b/neutrino-proxy-admin/src/views/system/portPool.vue @@ -108,7 +108,7 @@ listLoading: true, listQuery: { currentPage: 1, - pageSize: 20, + pageSize: 10, importance: undefined, title: undefined, type: undefined diff --git a/neutrino-proxy-admin/src/views/system/user.vue b/neutrino-proxy-admin/src/views/system/user.vue index 9a030fc5..9b20d580 100644 --- a/neutrino-proxy-admin/src/views/system/user.vue +++ b/neutrino-proxy-admin/src/views/system/user.vue @@ -119,7 +119,7 @@ listLoading: true, listQuery: { currentPage: 1, - pageSize: 20, + pageSize: 10, importance: undefined, title: undefined, type: undefined From d00346a3768738507b0d296ac6c38903666beade Mon Sep 17 00:00:00 2001 From: aoshiguchen <1052045476@qq.com> Date: Fri, 14 Oct 2022 22:16:05 +0800 Subject: [PATCH 08/55] =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E5=88=97=E5=AE=BD?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- neutrino-proxy-admin/src/views/system/jobManager.vue | 2 +- neutrino-proxy-admin/src/views/system/portPool.vue | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/neutrino-proxy-admin/src/views/system/jobManager.vue b/neutrino-proxy-admin/src/views/system/jobManager.vue index 8b62a349..a76755ec 100644 --- a/neutrino-proxy-admin/src/views/system/jobManager.vue +++ b/neutrino-proxy-admin/src/views/system/jobManager.vue @@ -41,7 +41,7 @@ 查看 - + - + - + - + - +