mirror of
https://gitee.com/wujiawei1207537021/wu-lazy-cloud-network.git
synced 2025-06-16 18:35:05 +08:00
【fix】修复无法启动问题
This commit is contained in:
@ -34,6 +34,7 @@ public class ClientHandleUdpChannelTransferTypeAdvancedHandleDistribute extends
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
Channel channel = channelHandlerContext.channel();
|
||||
log.debug("接收到服务端需要内网穿透的数据:{}" , nettyProxyMsg);
|
||||
String clientId = nettyClientProperties.getClientId();
|
||||
byte[] visitorPort = nettyProxyMsg.getVisitorPort();
|
||||
@ -42,7 +43,7 @@ public class ClientHandleUdpChannelTransferTypeAdvancedHandleDistribute extends
|
||||
byte[] visitorId = nettyProxyMsg.getVisitorId();
|
||||
// 真实服务通道
|
||||
// Channel realChannel = NettyRealIdContext.getReal(new String(visitorId));
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
if (nextChannel == null) {
|
||||
log.error("无法获取访客:{} 真实服务", new String(visitorId));
|
||||
return;
|
||||
@ -50,7 +51,7 @@ public class ClientHandleUdpChannelTransferTypeAdvancedHandleDistribute extends
|
||||
|
||||
|
||||
// 把数据转到真实服务
|
||||
ByteBuf buf = channelHandlerContext.config().getAllocator().buffer(nettyProxyMsg.getData().length);
|
||||
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);
|
||||
buf.writeBytes(nettyProxyMsg.getData());
|
||||
|
||||
nextChannel.writeAndFlush(buf);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.ChannelContext;
|
||||
@ -25,10 +26,11 @@ public class ClientHandleUdpClientChannelActiveAdvanced extends AbstractHandleUd
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
Channel channel = channelHandlerContext.channel();
|
||||
// 缓存当前通道
|
||||
byte[] clientIdByte = nettyProxyMsg.getClientId();
|
||||
String clientId = new String(clientIdByte);
|
||||
ChannelContext.push(channelHandlerContext, clientId);
|
||||
ChannelAttributeKeyUtils.buildClientId(channelHandlerContext, clientId);
|
||||
ChannelContext.push(channel, clientId);
|
||||
ChannelAttributeKeyUtils.buildClientId(channel, clientId);
|
||||
}
|
||||
}
|
||||
|
@ -26,10 +26,11 @@ public class ClientHandleUdpDistributeClientPermeateClientTransferCloseTypeAdvan
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
Channel channel = channelHandlerContext.channel();
|
||||
// 关闭客户端真实通道、访客通道
|
||||
Channel realChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
|
||||
Channel realChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
realChannel.close();// 真实通道关闭
|
||||
channelHandlerContext.close(); // 数据传输通道关闭
|
||||
channel.close(); // 数据传输通道关闭
|
||||
|
||||
}
|
||||
|
||||
|
@ -26,9 +26,10 @@ public class ClientHandleUdpDistributeClientPermeateServerTransferCloseTypeAdvan
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
Channel channel = channelHandlerContext.channel();
|
||||
// 关闭本地通信通道
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
|
||||
channelHandlerContext.close();
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
channel.close();
|
||||
nextChannel.close();
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ public class ClientHandleUdpDistributeClientTransferClientPermeateChannelInitSuc
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
Channel channel = channelHandlerContext.channel();
|
||||
// 连接成功 开启自动读取写
|
||||
byte[] msgClientId = nettyProxyMsg.getClientId();
|
||||
byte[] msgClientTargetIp = nettyProxyMsg.getClientTargetIp();
|
||||
@ -37,7 +38,7 @@ public class ClientHandleUdpDistributeClientTransferClientPermeateChannelInitSuc
|
||||
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
|
||||
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
|
||||
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
nextChannel.config().setOption(ChannelOption.AUTO_READ, true);
|
||||
|
||||
}
|
||||
|
@ -33,10 +33,11 @@ public class ClientHandleUdpDistributeClientTransferServerPermeateChannelConnect
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
Channel channel = channelHandlerContext.channel();
|
||||
// 连接成功 开启自动读取写
|
||||
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
|
||||
String visitorId = new String(msgVisitorId);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
nextChannel.config().setOption(ChannelOption.AUTO_READ, true);
|
||||
|
||||
}
|
||||
|
@ -30,9 +30,10 @@ public class ClientHandleUdpDistributeServicePermeateClientTransferClientRespons
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
|
||||
Channel channel = channelHandlerContext.channel();
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
// 把数据转到真实服务
|
||||
ByteBuf buf = channelHandlerContext.config().getAllocator().buffer(nettyProxyMsg.getData().length);
|
||||
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);
|
||||
buf.writeBytes(nettyProxyMsg.getData());
|
||||
|
||||
nextChannel.writeAndFlush(buf);
|
||||
|
@ -19,11 +19,12 @@ public class ClientHandleUdpDistributeSingleClientRealAutoReadConnectTypeAdvance
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
Channel channel = channelHandlerContext.channel();
|
||||
// 获取访客ID
|
||||
byte[] visitorId = nettyProxyMsg.getVisitorId();
|
||||
// 获取访客对应的真实代理通道
|
||||
Channel realChannel = NettyRealIdContext.getReal(visitorId);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
if (nextChannel != null) {
|
||||
nextChannel.config().setOption(ChannelOption.AUTO_READ, true);
|
||||
}
|
||||
|
@ -26,11 +26,11 @@ public class ClientHandleDistributeHttpClientProxyClientTransferRequestAdvanced
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
|
||||
Channel channel = channelHandlerContext.channel();
|
||||
// 数据发送
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
if(ObjectUtils.isNotEmpty(nextChannel)){
|
||||
ByteBuf buf = channelHandlerContext.config().getAllocator().buffer(nettyProxyMsg.getData().length);
|
||||
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);
|
||||
buf.writeBytes(nettyProxyMsg.getData());
|
||||
nextChannel.writeAndFlush(buf);
|
||||
}else {
|
||||
|
@ -26,15 +26,17 @@ public class ClientHandleDistributeHttpClientProxyServerTransferTypeAdvanced ext
|
||||
@Override
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
|
||||
String visitorId = ChannelAttributeKeyUtils.getVisitorId(channelHandlerContext);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
|
||||
Channel channel = channelHandlerContext.channel();
|
||||
|
||||
String visitorId = ChannelAttributeKeyUtils.getVisitorId(channel);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
if (nextChannel == null) {
|
||||
log.error("无法获取访客:{} 真实服务", visitorId);
|
||||
return;
|
||||
}
|
||||
|
||||
// 把数据转到真实服务
|
||||
ByteBuf buf = channelHandlerContext.config().getAllocator().buffer(nettyProxyMsg.getData().length);
|
||||
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);
|
||||
buf.writeBytes(nettyProxyMsg.getData());
|
||||
|
||||
nextChannel.writeAndFlush(buf);
|
||||
|
@ -26,11 +26,11 @@ public class ClientHandleDistributeHttpServerProxyClientTransferRequestAdvanced
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
|
||||
Channel channel = channelHandlerContext.channel();
|
||||
// 数据发送
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
if (ObjectUtils.isNotEmpty(nextChannel)) {
|
||||
ByteBuf buf = channelHandlerContext.config().getAllocator().buffer(nettyProxyMsg.getData().length);
|
||||
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);
|
||||
buf.writeBytes(nettyProxyMsg.getData());
|
||||
nextChannel.writeAndFlush(buf);
|
||||
} else {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.advanced;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.NettyHttpClientProxyClient;
|
||||
@ -29,6 +30,7 @@ public class ClientHandleHttpClientProxyClientTypeAdvanced extends
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
Channel channel = channelHandlerContext.channel();
|
||||
String targetPortString = nettyProxyMsg.getTargetPortString();
|
||||
String targetIpString = nettyProxyMsg.getTargetIpString();
|
||||
byte[] data = nettyProxyMsg.getData();
|
||||
@ -46,6 +48,6 @@ public class ClientHandleHttpClientProxyClientTypeAdvanced extends
|
||||
nettyHttpClientProxyClient.setNettyClientProperties(nettyClientProperties);
|
||||
nettyHttpClientProxyClient.setData(data);
|
||||
|
||||
NettyHttpClientProxyClientProxySocket.buildTransferServer(nettyHttpClientProxyClient, channelHandlerContext);
|
||||
NettyHttpClientProxyClientProxySocket.buildTransferServer(nettyHttpClientProxyClient, channel);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.advanced;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.NettyHttpClientProxyServer;
|
||||
@ -29,6 +30,7 @@ public class ClientHandleHttpClientProxyServerTypeAdvanced extends
|
||||
@Override
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
|
||||
Channel channel = channelHandlerContext.channel();
|
||||
String targetPortString = nettyProxyMsg.getTargetPortString();
|
||||
String targetIpString = nettyProxyMsg.getTargetIpString();
|
||||
byte[] data = nettyProxyMsg.getData();
|
||||
@ -45,7 +47,7 @@ public class ClientHandleHttpClientProxyServerTypeAdvanced extends
|
||||
nettyHttpClientProxyServer.setNettyClientProperties(nettyClientProperties);
|
||||
nettyHttpClientProxyServer.setData(data);
|
||||
|
||||
NettyHttpClientProxyServerProxySocket.buildTransferServer(nettyHttpClientProxyServer, channelHandlerContext);
|
||||
NettyHttpClientProxyServerProxySocket.buildTransferServer(nettyHttpClientProxyServer, channel);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -24,10 +24,10 @@ public class ClientHandleHttpDistributeClientProxyClientTransferCLoseTypeAdvance
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
|
||||
Channel channel = channelHandlerContext.channel();
|
||||
// 关闭传输通道
|
||||
Channel realChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
|
||||
Channel realChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
realChannel.close();// 真实通道关闭
|
||||
channelHandlerContext.close(); // 数据传输通道关闭
|
||||
channel.close(); // 数据传输通道关闭
|
||||
}
|
||||
}
|
||||
|
@ -26,11 +26,11 @@ public class ClientHandleHttpDistributeClientProxyClientTransferResponseTypeAdva
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
|
||||
Channel channel = channelHandlerContext.channel();
|
||||
// 数据发送
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
if(ObjectUtils.isNotEmpty(nextChannel)){
|
||||
ByteBuf buf = channelHandlerContext.config().getAllocator().buffer(nettyProxyMsg.getData().length);
|
||||
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);
|
||||
buf.writeBytes(nettyProxyMsg.getData());
|
||||
nextChannel.writeAndFlush(buf);
|
||||
}else {
|
||||
|
Reference in New Issue
Block a user