[add] 删除namespace规则

This commit is contained in:
wujiawei
2025-06-16 00:34:06 +08:00
parent 2add2ddfa7
commit 513c8ba095
5 changed files with 7 additions and 9 deletions

View File

@@ -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 {

View File

@@ -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))));
}
}

View File

@@ -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;
/**

View File

@@ -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();
}

View File

@@ -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();
}