服务端连接验证逻辑调整,在没有端口映射时仍然保持与客户端的连接

This commit is contained in:
aoshiguchen
2022-08-30 16:10:43 +08:00
parent 80a7ca7844
commit 785f4d6183
@@ -103,28 +103,20 @@ public class ProxyMessageAuthHandler implements ProxyMessageHandler {
return;
}
List<PortMappingDO> portMappingList = portMappingService.findEnableListByLicenseId(licenseDO.getId());
// 没有端口映射仍然保持连接
if (CollectionUtil.isEmpty(portMappingList)) {
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.AUTH_FAILED, "当前license没有可用的端口映射!"));
return;
}
Channel cmdChannel = ProxyUtil.getCmdChannelByLicenseKey(licenseKey);
if (null != cmdChannel) {
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.AUTH_FAILED, "当前license已被另一节点使用!"));
ctx.channel().close();
return;
}
ProxyUtil.initProxyInfo(licenseKey, ProxyMapping.buildList(portMappingList));
Set<Integer> ports = ProxyUtil.getServerPortsByLicenseKey(licenseKey);
if (ports == null) {
ctx.channel().close();
return;
}
// Channel channel = ProxyChannelManager.getCmdChannel(licenseKey);
Channel channel = ProxyUtil.getCmdChannelByLicenseKey(licenseKey);
if (channel != null) {
ctx.channel().close();
return;
}
// ProxyChannelManager.addCmdChannel(ports, licenseKey, ctx.channel());
ProxyUtil.addCmdChannel(licenseKey, ctx.channel(), ports);
startUserPortServer(ports);