【fix】客户端代理客户端

This commit is contained in:
wujiawei
2025-05-05 23:12:04 +08:00
parent 5eba201979
commit 578429777a
6 changed files with 44 additions and 30 deletions

View File

@ -14,7 +14,6 @@ import org.framework.lazy.cloud.network.heartbeat.common.NettyTransferChannelCon
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.socks.server.AbstractHandleSocksReportClientProxyClientConnectionTransferTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.socks.server.AbstractHandleSocksReportClientProxyServerConnectionTransferTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.decoder.TransferDecoder;
import org.framework.lazy.cloud.network.heartbeat.common.factory.EventLoopGroupFactory;
@ -49,19 +48,23 @@ public class ServerHandleSocksReportClientProxyClientConnectTransferTypeAdvanced
Integer port = Integer.parseInt(nettyProxyMsg.getTargetPortString());
byte[] data = nettyProxyMsg.getData();
byte[] visitorId = nettyProxyMsg.getVisitorId();
byte[] clientId = nettyProxyMsg.getClientId();
byte[] targetClientId = nettyProxyMsg.getClientId();
String msgVisitorId = new String(visitorId);
ChannelAttributeKeyUtils.buildClientId(transferChannel, clientId);
ChannelAttributeKeyUtils.buildClientId(transferChannel, targetClientId);
ChannelAttributeKeyUtils.buildVisitorId(transferChannel, msgVisitorId);
NettyTransferChannelContext.pushVisitor(transferChannel, msgVisitorId);
// 客户端连接客户端传输通道
Channel loadBalance = ChannelContext.getLoadBalance(clientId);
Channel loadBalance = ChannelContext.getLoadBalance(targetClientId);
if(ObjectUtils.isNotEmpty(loadBalance)) {
// 下发创建新链接指令
NettyProxyMsg otherClientConnectServer = new NettyProxyMsg();
otherClientConnectServer.setData(data);
otherClientConnectServer.setClientTargetIp(host);
otherClientConnectServer.setClientTargetPort(port);
otherClientConnectServer.setVisitorId(visitorId);
otherClientConnectServer.setClientId(targetClientId);
otherClientConnectServer.setType(ProxyMessageType.SOCKS_DISTRIBUTE_CLIENT_PROXY_CLIENT_OTHER_TRANSFER_CONNECTION_);
loadBalance.writeAndFlush(otherClientConnectServer);