[fix] 优化绑定下一个通道问题

This commit is contained in:
wujiawei
2025-06-17 13:50:37 +08:00
parent 7c640816aa
commit 21136284c7

View File

@@ -128,6 +128,14 @@ public class NettySocksServerProxyClientRealSocket {
Channel transferChannel = futureListener.channel();
if (futureListener.isSuccess()) {
log.info("服务端代理客户端socks客户端连接服务端传输通道成功");
// 绑定下一个通道
ChannelAttributeKeyUtils.buildNextChannel(transferChannel, realChannel);
ChannelAttributeKeyUtils.buildNextChannel(realChannel, transferChannel);
// 绑定客户端真实通信通道
ChannelAttributeKeyUtils.buildVisitorId(transferChannel, visitorId);
ChannelAttributeKeyUtils.buildClientId(transferChannel, clientId);
// 开始读取数据
realChannel.config().setOption(ChannelOption.AUTO_READ, true);
// 通知服务端访客连接成功
NettyProxyMsg nettyProxyMsg = new NettyProxyMsg();
@@ -137,15 +145,6 @@ public class NettySocksServerProxyClientRealSocket {
nettyProxyMsg.setTargetPort(targetPort);
nettyProxyMsg.setType(ProxyMessageType.SOCKS_REPORT_SERVER_PROXY_CLIENT_CONNECTION_SUCCESS_);
transferChannel.writeAndFlush(nettyProxyMsg);
ChannelAttributeKeyUtils.buildNextChannel(transferChannel, realChannel);
ChannelAttributeKeyUtils.buildNextChannel(realChannel, transferChannel);
// 绑定客户端真实通信通道
ChannelAttributeKeyUtils.buildVisitorId(transferChannel, visitorId);
ChannelAttributeKeyUtils.buildClientId(transferChannel, clientId);
} else {
log.info("无法连接到服务端....");
eventLoopGroup.schedule(() -> {