mirror of
https://gitee.com/wujiawei1207537021/wu-lazy-cloud-network.git
synced 2025-06-16 18:35:05 +08:00
【fix】 优化使用 EventLoopGroup bossGroup = EventLoopGroupFactory.createBossGroup();
EventLoopGroup workerGroup = EventLoopGroupFactory.createWorkerGroup();
This commit is contained in:
@ -55,10 +55,10 @@ public class ClientHandleTcpDistributeClientPermeateClientInitTypeAdvanced exten
|
||||
.builderClientTargetIp(clientTargetIp)
|
||||
.builderClientTargetPort(clientTargetPort)
|
||||
.builderVisitorPort(visitorPort)
|
||||
.builderNettyClientProperties(nettyClientProperties)
|
||||
// .builderChannelFlowAdapter(channelFlowAdapter)
|
||||
.builderNettyClientProperties(nettyClientProperties)
|
||||
//.builderChannelFlowAdapter(channelFlowAdapter)
|
||||
.builderToClientId(toClientId)
|
||||
.builderHandleChannelTypeAdvancedList(handleChannelTypeAdvancedList)
|
||||
.builderHandleChannelTypeAdvancedList(handleChannelTypeAdvancedList)
|
||||
|
||||
.build();
|
||||
try {
|
||||
|
@ -13,11 +13,13 @@ import org.framework.lazy.cloud.network.heartbeat.common.NettyClientVisitorConte
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyVisitorPortContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelFlowAdapter;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.factory.EventLoopGroupFactory;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.socket.PermeateVisitorSocket;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 内网穿透 客户端渗透客户端通道
|
||||
*
|
||||
@ -26,8 +28,6 @@ import java.util.List;
|
||||
*/
|
||||
@Slf4j
|
||||
public class NettyTcpClientPermeateClientVisitorSocket implements PermeateVisitorSocket {
|
||||
private final EventLoopGroup bossGroup = new NioEventLoopGroup();
|
||||
private final EventLoopGroup workerGroup = new NioEventLoopGroup();
|
||||
private final NettyTcpClientPermeateClientVisitorFilter nettyTcpClientPermeateClientVisitorFilter;
|
||||
@Getter
|
||||
private final String clientId;
|
||||
@ -50,6 +50,9 @@ public class NettyTcpClientPermeateClientVisitorSocket implements PermeateVisito
|
||||
Channel visitor = NettyVisitorPortContext.getVisitorChannel(visitorPort);
|
||||
if (visitor == null) {
|
||||
ServerBootstrap bootstrap = new ServerBootstrap();
|
||||
|
||||
EventLoopGroup bossGroup = EventLoopGroupFactory.createBossGroup();
|
||||
EventLoopGroup workerGroup = EventLoopGroupFactory.createWorkerGroup();
|
||||
bootstrap
|
||||
.group(bossGroup, workerGroup)
|
||||
.channel(NioServerSocketChannel.class)
|
||||
@ -94,12 +97,6 @@ public class NettyTcpClientPermeateClientVisitorSocket implements PermeateVisito
|
||||
}
|
||||
@Override
|
||||
public void close() {
|
||||
if (!bossGroup.isShutdown()) {
|
||||
bossGroup.shutdownGracefully();
|
||||
}
|
||||
if (!workerGroup.isShutdown()) {
|
||||
workerGroup.shutdownGracefully();
|
||||
}
|
||||
Channel visitor = NettyVisitorPortContext.getVisitorChannel(visitorPort);
|
||||
if (visitor != null) {
|
||||
|
||||
|
@ -12,6 +12,7 @@ import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter.NettyT
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyClientVisitorContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyVisitorPortContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.factory.EventLoopGroupFactory;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.socket.PermeateVisitorSocket;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
|
||||
@ -25,8 +26,7 @@ import java.util.List;
|
||||
*/
|
||||
@Slf4j
|
||||
public class NettyTcpClientPermeateServerVisitorSocket implements PermeateVisitorSocket {
|
||||
private final EventLoopGroup bossGroup = new NioEventLoopGroup();
|
||||
private final EventLoopGroup workerGroup = new NioEventLoopGroup();
|
||||
|
||||
private final NettyTcpClientPermeateServerVisitorFilter nettyTcpClientPermeateServerVisitorFilter;
|
||||
@Getter
|
||||
private final String clientId;
|
||||
@ -49,6 +49,8 @@ public class NettyTcpClientPermeateServerVisitorSocket implements PermeateVisito
|
||||
PermeateVisitorSocket visitor = NettyVisitorPortContext.getVisitorSocket(visitorPort);
|
||||
if (visitor == null) {
|
||||
ServerBootstrap bootstrap = new ServerBootstrap();
|
||||
EventLoopGroup bossGroup = EventLoopGroupFactory.createBossGroup();
|
||||
EventLoopGroup workerGroup = EventLoopGroupFactory.createWorkerGroup();
|
||||
bootstrap
|
||||
.group(bossGroup, workerGroup)
|
||||
.channel(NioServerSocketChannel.class)
|
||||
@ -91,12 +93,6 @@ public class NettyTcpClientPermeateServerVisitorSocket implements PermeateVisito
|
||||
}
|
||||
@Override
|
||||
public void close() {
|
||||
if (!bossGroup.isShutdown()) {
|
||||
bossGroup.shutdownGracefully();
|
||||
}
|
||||
if (!workerGroup.isShutdown()) {
|
||||
workerGroup.shutdownGracefully();
|
||||
}
|
||||
PermeateVisitorSocket permeateVisitorSocket = NettyVisitorPortContext.getVisitorSocket(visitorPort);
|
||||
if (permeateVisitorSocket != null) {
|
||||
log.warn("关闭客户端 :【{}】 访客户端口:【{}】", clientId, visitorPort);
|
||||
|
@ -13,6 +13,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.NettyClientVisitorConte
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyVisitorPortContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelFlowAdapter;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.factory.EventLoopGroupFactory;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.socket.PermeateVisitorSocket;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
|
||||
@ -26,8 +27,6 @@ import java.util.List;
|
||||
*/
|
||||
@Slf4j
|
||||
public class NettyUdpClientPermeateClientVisitorSocket implements PermeateVisitorSocket {
|
||||
private final EventLoopGroup bossGroup = new NioEventLoopGroup();
|
||||
private final EventLoopGroup workerGroup = new NioEventLoopGroup();
|
||||
private final NettyUdpClientPermeateClientVisitorFilter nettyUdpClientPermeateClientVisitorFilter;
|
||||
@Getter
|
||||
private final String clientId;
|
||||
@ -50,6 +49,8 @@ public class NettyUdpClientPermeateClientVisitorSocket implements PermeateVisito
|
||||
Channel visitor = NettyVisitorPortContext.getVisitorChannel(visitorPort);
|
||||
if (visitor == null) {
|
||||
ServerBootstrap bootstrap = new ServerBootstrap();
|
||||
EventLoopGroup bossGroup = EventLoopGroupFactory.createBossGroup();
|
||||
EventLoopGroup workerGroup = EventLoopGroupFactory.createWorkerGroup();
|
||||
bootstrap
|
||||
.group(bossGroup, workerGroup)
|
||||
.channel(NioServerSocketChannel.class)
|
||||
@ -94,12 +95,7 @@ public class NettyUdpClientPermeateClientVisitorSocket implements PermeateVisito
|
||||
}
|
||||
@Override
|
||||
public void close() {
|
||||
if (!bossGroup.isShutdown()) {
|
||||
bossGroup.shutdownGracefully();
|
||||
}
|
||||
if (!workerGroup.isShutdown()) {
|
||||
workerGroup.shutdownGracefully();
|
||||
}
|
||||
|
||||
Channel visitor = NettyVisitorPortContext.getVisitorChannel(visitorPort);
|
||||
if (visitor != null) {
|
||||
|
||||
|
@ -12,6 +12,7 @@ import org.framework.lazy.cloud.network.heartbeat.client.netty.udp.filter.NettyU
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyClientVisitorContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyVisitorPortContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.factory.EventLoopGroupFactory;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.socket.PermeateVisitorSocket;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
|
||||
@ -25,8 +26,7 @@ import java.util.List;
|
||||
*/
|
||||
@Slf4j
|
||||
public class NettyUdpClientPermeateServerVisitorSocket implements PermeateVisitorSocket {
|
||||
private final EventLoopGroup bossGroup = new NioEventLoopGroup();
|
||||
private final EventLoopGroup workerGroup = new NioEventLoopGroup();
|
||||
|
||||
private final NettyUdpClientPermeateServerVisitorFilter nettyUdpClientPermeateServerVisitorFilter;
|
||||
@Getter
|
||||
private final String clientId;
|
||||
@ -49,6 +49,8 @@ public class NettyUdpClientPermeateServerVisitorSocket implements PermeateVisito
|
||||
PermeateVisitorSocket visitor = NettyVisitorPortContext.getVisitorSocket(visitorPort);
|
||||
if (visitor == null) {
|
||||
ServerBootstrap bootstrap = new ServerBootstrap();
|
||||
EventLoopGroup bossGroup = EventLoopGroupFactory.createBossGroup();
|
||||
EventLoopGroup workerGroup = EventLoopGroupFactory.createWorkerGroup();
|
||||
bootstrap
|
||||
.group(bossGroup, workerGroup)
|
||||
.channel(NioServerSocketChannel.class)
|
||||
@ -91,12 +93,7 @@ public class NettyUdpClientPermeateServerVisitorSocket implements PermeateVisito
|
||||
}
|
||||
@Override
|
||||
public void close() {
|
||||
if (!bossGroup.isShutdown()) {
|
||||
bossGroup.shutdownGracefully();
|
||||
}
|
||||
if (!workerGroup.isShutdown()) {
|
||||
workerGroup.shutdownGracefully();
|
||||
}
|
||||
|
||||
PermeateVisitorSocket permeateVisitorSocket = NettyVisitorPortContext.getVisitorSocket(visitorPort);
|
||||
if (permeateVisitorSocket != null) {
|
||||
log.warn("关闭客户端 :【{}】 访客户端口:【{}】", clientId, visitorPort);
|
||||
|
@ -1,3 +1,3 @@
|
||||
org.framework.lazy.cloud.network.heartbeat.client.EnableClientAutoConfiguration
|
||||
org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties
|
||||
org.framework.lazy.cloud.network.heartbeat.client.config.ClientAutoConfiguration
|
||||
org.framework.lazy.cloud.network.heartbeat.client.config.ClientAutoConfiguration
|
Reference in New Issue
Block a user