mirror of
https://gitee.com/wujiawei1207537021/wu-lazy-cloud-network.git
synced 2025-06-06 13:27:55 +08:00
【fix】修复客户端渗透客户端问题 通道关闭错误
This commit is contained in:
parent
3ec0ab3271
commit
06c45f4fef
@ -5,7 +5,6 @@ import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.ChannelContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
||||
@ -41,7 +40,6 @@ public class NettyClientPermeateServerTransferHandler extends SimpleChannelInbou
|
||||
String visitorId = ChannelAttributeKeyUtils.getVisitorId(ctx.channel());
|
||||
// 关闭访客
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(ctx.channel());
|
||||
ChannelContext.ClientChannel clientChannel = ChannelContext.get(clientId);
|
||||
if (nextChannel != null) {
|
||||
// 上报关闭服务端客户端真实通道
|
||||
NettyProxyMsg closeVisitorMsg = new NettyProxyMsg();
|
||||
|
@ -42,20 +42,14 @@ public class NettyClientPermeateServerVisitorHandler extends SimpleChannelInboun
|
||||
// 先不读取访客数据
|
||||
visitorChannel.config().setOption(ChannelOption.AUTO_READ, false);
|
||||
|
||||
|
||||
// 生成访客ID
|
||||
String visitorId = UUID.randomUUID().toString();
|
||||
// 绑定访客真实通道
|
||||
NettyRealIdContext.pushReal(visitorChannel, visitorId);
|
||||
// 当前通道绑定访客ID
|
||||
ChannelAttributeKeyUtils.buildVisitorId(visitorChannel, visitorId);
|
||||
|
||||
internalNetworkPermeateServerVisitor.setVisitorId(visitorId);
|
||||
// 判断是否有可用的通道 如果没有创建新的通道
|
||||
// Channel transferChannel = nettyChannelPool.availableChannel(visitorId);
|
||||
// 创建访客连接服务端通道
|
||||
NettyClientPermeateServerVisitorTransferSocket.buildTransferServer(internalNetworkPermeateServerVisitor);
|
||||
log.info("客户端渗透服务端访客端口连接成功了");
|
||||
NettyClientPermeateServerVisitorTransferSocket.buildTransferServer(internalNetworkPermeateServerVisitor,visitorChannel);
|
||||
log.debug("客户端渗透服务端访客端口连接成功了");
|
||||
super.channelActive(ctx);
|
||||
}
|
||||
|
||||
@ -116,9 +110,6 @@ public class NettyClientPermeateServerVisitorHandler extends SimpleChannelInboun
|
||||
myMsg.setVisitorId(visitorId);
|
||||
nextChannel.writeAndFlush(myMsg);
|
||||
}
|
||||
// 关闭 访客通信通道、访客真实通道
|
||||
NettyRealIdContext.clear(visitorId);
|
||||
NettyCommunicationIdContext.clear(visitorId);
|
||||
log.warn("【客户端渗透服务端】访客端口断开连接");
|
||||
super.channelInactive(ctx);
|
||||
}
|
||||
|
@ -10,9 +10,7 @@ import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientPrope
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.InternalNetworkPermeateServerVisitor;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.filter.NettyClientPermeateServerTransferFilter;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyCommunicationIdContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyRealIdContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
|
||||
@ -26,8 +24,8 @@ public class NettyClientPermeateServerVisitorTransferSocket {
|
||||
/**
|
||||
* 连接服务端通信通道
|
||||
*/
|
||||
public static void buildTransferServer(InternalNetworkPermeateServerVisitor internalNetworkPermeateServerVisitor) {
|
||||
newTransferConnect2Server(internalNetworkPermeateServerVisitor);
|
||||
public static void buildTransferServer(InternalNetworkPermeateServerVisitor internalNetworkPermeateServerVisitor, Channel visitorChannel) {
|
||||
newTransferConnect2Server(internalNetworkPermeateServerVisitor,visitorChannel);
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +34,7 @@ public class NettyClientPermeateServerVisitorTransferSocket {
|
||||
* <p>
|
||||
* internalNetworkPermeateServerVisitor
|
||||
*/
|
||||
protected static void newTransferConnect2Server(InternalNetworkPermeateServerVisitor internalNetworkPermeateServerVisitor) {
|
||||
protected static void newTransferConnect2Server(InternalNetworkPermeateServerVisitor internalNetworkPermeateServerVisitor, Channel visitorChannel) {
|
||||
|
||||
Bootstrap bootstrap = new Bootstrap();
|
||||
bootstrap.group(eventLoopGroup)
|
||||
@ -87,17 +85,13 @@ public class NettyClientPermeateServerVisitorTransferSocket {
|
||||
|
||||
myMsg.setVisitorId(visitorId);
|
||||
channel.writeAndFlush(myMsg);
|
||||
// 绑定客户端真实通信通道
|
||||
NettyCommunicationIdContext.pushVisitor(channel, visitorId);
|
||||
ChannelAttributeKeyUtils.buildVisitorId(channel, visitorId);
|
||||
ChannelAttributeKeyUtils.buildClientId(channel, clientId);
|
||||
// 传输通道打开后自动读取
|
||||
Channel visitor = NettyRealIdContext.getReal(visitorId);
|
||||
|
||||
ChannelAttributeKeyUtils.buildNextChannel(visitor, channel);
|
||||
ChannelAttributeKeyUtils.buildNextChannel(channel, visitor);
|
||||
|
||||
|
||||
ChannelAttributeKeyUtils.buildNextChannel(visitorChannel, channel);
|
||||
ChannelAttributeKeyUtils.buildNextChannel(channel, visitorChannel);
|
||||
} else {
|
||||
log.info("客户端渗透服务端通信通道中断....");
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ public class ServerHandleReportClientTransferClientPermeateChannelInitSuccessful
|
||||
Channel nextTransferChannel = NettyTransferChannelContext.getVisitor(msgVisitorId);
|
||||
ChannelAttributeKeyUtils.buildTransferNextChannel(nextTransferChannel,channel);
|
||||
ChannelAttributeKeyUtils.buildTransferNextChannel(channel,nextTransferChannel);
|
||||
NettyTransferChannelContext.clear(msgVisitorId);
|
||||
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(channel);
|
||||
|
||||
|
@ -27,29 +27,29 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.graalvm.buildtools</groupId>
|
||||
<artifactId>native-maven-plugin</artifactId>
|
||||
<version>0.9.23</version>
|
||||
<configuration>
|
||||
<!-- imageName用于设置生成的二进制文件名称 -->
|
||||
<imageName>${project.artifactId}</imageName>
|
||||
<!-- mainClass用于指定main方法类路径 -->
|
||||
<mainClass>org.framework.lazy.cloud.network.heartbeat.client.LazyCloudHeartbeatClientStart</mainClass>
|
||||
<buildArgs>
|
||||
--no-fallback
|
||||
</buildArgs>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-native</id>
|
||||
<goals>
|
||||
<goal>compile-no-fork</goal>
|
||||
</goals>
|
||||
<phase>package</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- <plugin>-->
|
||||
<!-- <groupId>org.graalvm.buildtools</groupId>-->
|
||||
<!-- <artifactId>native-maven-plugin</artifactId>-->
|
||||
<!-- <version>0.9.23</version>-->
|
||||
<!-- <configuration>-->
|
||||
<!-- <!– imageName用于设置生成的二进制文件名称 –>-->
|
||||
<!-- <imageName>${project.artifactId}</imageName>-->
|
||||
<!-- <!– mainClass用于指定main方法类路径 –>-->
|
||||
<!-- <mainClass>org.framework.lazy.cloud.network.heartbeat.client.LazyCloudHeartbeatClientStart</mainClass>-->
|
||||
<!-- <buildArgs>-->
|
||||
<!-- --no-fallback-->
|
||||
<!-- </buildArgs>-->
|
||||
<!-- </configuration>-->
|
||||
<!-- <executions>-->
|
||||
<!-- <execution>-->
|
||||
<!-- <id>build-native</id>-->
|
||||
<!-- <goals>-->
|
||||
<!-- <goal>compile-no-fork</goal>-->
|
||||
<!-- </goals>-->
|
||||
<!-- <phase>package</phase>-->
|
||||
<!-- </execution>-->
|
||||
<!-- </executions>-->
|
||||
<!-- </plugin>-->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
|
@ -32,29 +32,29 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.graalvm.buildtools</groupId>
|
||||
<artifactId>native-maven-plugin</artifactId>
|
||||
<version>0.9.23</version>
|
||||
<configuration>
|
||||
<!-- imageName用于设置生成的二进制文件名称 -->
|
||||
<imageName>${project.artifactId}</imageName>
|
||||
<!-- mainClass用于指定main方法类路径 -->
|
||||
<mainClass>org.framework.lazy.cloud.network.heartbeat.server.LazyCloudHeartbeatServerStart</mainClass>
|
||||
<buildArgs>
|
||||
--no-fallback
|
||||
</buildArgs>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-native</id>
|
||||
<goals>
|
||||
<goal>compile-no-fork</goal>
|
||||
</goals>
|
||||
<phase>package</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- <plugin>-->
|
||||
<!-- <groupId>org.graalvm.buildtools</groupId>-->
|
||||
<!-- <artifactId>native-maven-plugin</artifactId>-->
|
||||
<!-- <version>0.9.23</version>-->
|
||||
<!-- <configuration>-->
|
||||
<!-- <!– imageName用于设置生成的二进制文件名称 –>-->
|
||||
<!-- <imageName>${project.artifactId}</imageName>-->
|
||||
<!-- <!– mainClass用于指定main方法类路径 –>-->
|
||||
<!-- <mainClass>org.framework.lazy.cloud.network.heartbeat.server.LazyCloudHeartbeatServerStart</mainClass>-->
|
||||
<!-- <buildArgs>-->
|
||||
<!-- --no-fallback-->
|
||||
<!-- </buildArgs>-->
|
||||
<!-- </configuration>-->
|
||||
<!-- <executions>-->
|
||||
<!-- <execution>-->
|
||||
<!-- <id>build-native</id>-->
|
||||
<!-- <goals>-->
|
||||
<!-- <goal>compile-no-fork</goal>-->
|
||||
<!-- </goals>-->
|
||||
<!-- <phase>package</phase>-->
|
||||
<!-- </execution>-->
|
||||
<!-- </executions>-->
|
||||
<!-- </plugin>-->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
|
Loading…
x
Reference in New Issue
Block a user