mirror of
https://gitee.com/wujiawei1207537021/wu-lazy-cloud-network.git
synced 2026-02-04 23:15:52 +08:00
[add] 删除namespace规则
This commit is contained in:
@@ -56,7 +56,7 @@ public class NettyTcpClientHandler extends SimpleChannelInboundHandler<NettyProx
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
// 建立连接时
|
||||
log.info("When establishing a connection:{}" , new Date());
|
||||
log.info("When establishing a connection:{}", new Date());
|
||||
ctx.fireChannelActive();
|
||||
String clientId = nettyTcpClientSocket.getClientId();
|
||||
// 处理客户端连接成功
|
||||
@@ -65,8 +65,6 @@ public class NettyTcpClientHandler extends SimpleChannelInboundHandler<NettyProx
|
||||
nettyMsg.setType(TcpMessageType.TCP_CLIENT_CHANNEL_ACTIVE);
|
||||
nettyMsg.setClientId(clientId);
|
||||
channelTypeAdapter.handler(ctx, nettyMsg);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +73,7 @@ public class NettyTcpClientHandler extends SimpleChannelInboundHandler<NettyProx
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
//服务端主动关闭当前客户端连接时
|
||||
log.info("When the server actively closes the current client connection:{}" , new Date());
|
||||
log.info("When the server actively closes the current client connection:{}", new Date());
|
||||
EventLoop eventLoop = ctx.channel().eventLoop();
|
||||
eventLoop.schedule(() -> {
|
||||
try {
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ChannelContext {
|
||||
// 如果服务端已经存在 移除
|
||||
if (cacheClientChannelConcurrentHashMap.containsKey(clientId)) {
|
||||
List<Channel> existChannelList = new ArrayList<>();
|
||||
List<Channel> oldChannels = cacheClientChannelConcurrentHashMap.getOrDefault(clientId, new ArrayList<>());
|
||||
List<Channel> oldChannels = cacheClientChannelConcurrentHashMap.get(clientId);
|
||||
for (Channel existChannel : oldChannels) {
|
||||
if (existChannel != null) {
|
||||
if (existChannel.isActive()) {
|
||||
@@ -48,7 +48,7 @@ public class ChannelContext {
|
||||
existChannelList.add(channel);
|
||||
cacheClientChannelConcurrentHashMap.put(clientId, existChannelList);
|
||||
} else {
|
||||
cacheClientChannelConcurrentHashMap.put(clientId, Collections.synchronizedList(new ArrayList<>(List.of(channel))));
|
||||
cacheClientChannelConcurrentHashMap.putIfAbsent(clientId, Collections.synchronizedList(new ArrayList<>(List.of(channel))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.nio.charset.StandardCharsets;
|
||||
@Getter
|
||||
public class NettyProxyMsg {
|
||||
// body 长度 type 1 isSsl 1 appKey 4 appSecret 4 clientId 4 originalIp 4 targetIp 4 targetPort 4 visitorPort 4 visitorId 4 data 4
|
||||
public static final int bodyLength = 1 + 1 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4;
|
||||
public static final int bodyLength = 1 + 1 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,7 +36,6 @@ public class NettyTcpServerHandler extends SimpleChannelInboundHandler<NettyProx
|
||||
}
|
||||
|
||||
/**
|
||||
* Is called for each message of type {@link I}.
|
||||
*
|
||||
* @param ctx the {@link ChannelHandlerContext} which this {@link SimpleChannelInboundHandler}
|
||||
* belongs to
|
||||
@@ -144,6 +143,7 @@ public class NettyTcpServerHandler extends SimpleChannelInboundHandler<NettyProx
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
// super.exceptionCaught(ctx, cause);
|
||||
Channel channel = ctx.channel();
|
||||
log.error(cause.getMessage());
|
||||
//……
|
||||
if (channel.isActive()) ctx.close();
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<NettyProx
|
||||
}
|
||||
|
||||
/**
|
||||
* Is called for each message of type {@link I}.
|
||||
*
|
||||
* @param ctx the {@link ChannelHandlerContext} which this {@link SimpleChannelInboundHandler}
|
||||
* belongs to
|
||||
@@ -144,6 +143,7 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<NettyProx
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
// super.exceptionCaught(ctx, cause);
|
||||
Channel channel = ctx.channel();
|
||||
log.error(cause.getMessage());
|
||||
//……
|
||||
if (channel.isActive()) ctx.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user