mirror of
https://gitee.com/wujiawei1207537021/wu-lazy-cloud-network.git
synced 2025-06-16 10:25:07 +08:00
【fix】修复服务端socks代理客户端时断时续问题
This commit is contained in:
@ -67,7 +67,7 @@ public class NettyTcpServerHandler extends SimpleChannelInboundHandler<NettyProx
|
||||
|
||||
if (ObjectUtils.isEmpty(visitorId)) {
|
||||
// 已经5秒没有接收到客户端:{}的信息了
|
||||
log.warn("I haven't received any information from client: {} with channel:{} for 5 seconds", clientId, channel.id().toString());
|
||||
log.warn("I haven't received any information from client: {} with channel:{} visitorId:{} for 5 seconds", clientId, channel.id().toString(),visitorId);
|
||||
// 关闭这个不活跃的channel client:{}
|
||||
log.warn("close this inactive channel client:{} with no visitor", clientId);
|
||||
// 给所有客户端发送 这个客户端离线了
|
||||
@ -116,7 +116,7 @@ public class NettyTcpServerHandler extends SimpleChannelInboundHandler<NettyProx
|
||||
String clientId = ChannelAttributeKeyUtils.getClientId(channel);
|
||||
String visitorId = ChannelAttributeKeyUtils.getVisitorId(channel);
|
||||
|
||||
if (!ObjectUtils.isEmpty(visitorId)) {
|
||||
if (ObjectUtils.isNotEmpty(visitorId)) {
|
||||
// 客户端:{},断开访客的连接:{}
|
||||
log.warn("client: {} channel:{}, disconnect with visitorId:{}", clientId, channel.id().toString(), visitorId);
|
||||
// 访客通道 关闭访客通道
|
||||
|
@ -40,12 +40,14 @@ public class ServerHandleSocksReportServerProxyClientConnectionSuccessTypeAdvanc
|
||||
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
|
||||
// 打开访客通道获取访问数据
|
||||
byte[] visitorId = nettyProxyMsg.getVisitorId();
|
||||
byte[] clientId = nettyProxyMsg.getClientId();
|
||||
Channel visitorChannel = NettyTransferChannelContext.getVisitor(visitorId);
|
||||
// 传输通道
|
||||
Channel transferChannel = nettyChannelContext.channel();
|
||||
ChannelAttributeKeyUtils.buildNextChannel(transferChannel,visitorChannel);
|
||||
ChannelAttributeKeyUtils.buildNextChannel(visitorChannel,transferChannel);
|
||||
|
||||
ChannelAttributeKeyUtils.buildVisitorId(transferChannel,visitorId);
|
||||
ChannelAttributeKeyUtils.buildClientId(transferChannel,clientId);
|
||||
|
||||
// 根据传输通道获取代理通道
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(transferChannel);
|
||||
|
@ -32,8 +32,10 @@ public class ServerHandleSocksReportServerProxyClientTransferCloseTypeAdvanced
|
||||
Channel channel = nettyChannelContext.channel();
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
channel.close();
|
||||
nextChannel.close();
|
||||
|
||||
if (nextChannel != null) {
|
||||
log.debug("关闭socks访客通道");
|
||||
nextChannel.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -60,13 +60,9 @@ public class ServerHandleSocksReportServerProxyClientTypeAdvanced
|
||||
otherClientConnectServer.setClientId(targetClientId);
|
||||
otherClientConnectServer.setType(ProxyMessageType.SOCKS_DISTRIBUTE_SERVER_PROXY_CLIENT_CONNECTION_INIT_);
|
||||
loadBalance.writeAndFlush(otherClientConnectServer);
|
||||
|
||||
}else {
|
||||
log.error("无法通过客户端ID获取当前客户端通道");
|
||||
log.error("服务端代理客户端遇到错误,无法通过客户端ID获取当前客户端通道");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user