【fix】修复无法启动问题

This commit is contained in:
wujiawei
2025-04-30 16:59:10 +08:00
parent a6c46c3cba
commit 9324b516fd
288 changed files with 788 additions and 723 deletions

View File

@ -5,7 +5,8 @@ import io.netty.buffer.ByteBuf;
import io.netty.channel.*;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.http.AbstractHttpClientProxyClientTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.decoder.TransferDecoder;
import org.framework.lazy.cloud.network.heartbeat.common.encoder.TransferEncoder;
@ -23,12 +24,12 @@ public class HttpClientProxyClientProxyTypeAdvanced extends AbstractHttpClientPr
/**
* 处理当前数据
*
* @param channelHandlerContext 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = channelHandlerContext.channel();
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
String targetPortString = nettyProxyMsg.getTargetPortString();
String targetIpString = nettyProxyMsg.getTargetIpString();
Bootstrap b = new Bootstrap();
@ -54,7 +55,7 @@ public class HttpClientProxyClientProxyTypeAdvanced extends AbstractHttpClientPr
buf.writeBytes(nettyProxyMsg.getData());
proxyChannel.writeAndFlush(buf);
} else {
channelHandlerContext.close();
channel.close();
}
});
}

View File

@ -5,7 +5,8 @@ import io.netty.buffer.ByteBuf;
import io.netty.channel.*;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.http.AbstractHttpLocalProxyTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.decoder.TransferDecoder;
import org.framework.lazy.cloud.network.heartbeat.common.encoder.TransferEncoder;
@ -23,15 +24,15 @@ public class HttpProtocolHandleChannelLocalProxyTypeAdvanced extends AbstractHtt
/**
* 处理当前数据
*
* @param channelHandlerContext 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
String targetPortString = nettyProxyMsg.getTargetPortString();
String targetIpString = nettyProxyMsg.getTargetIpString();
Bootstrap b = new Bootstrap();
Channel channel = channelHandlerContext.channel();
Channel channel = nettyChannelContext.channel();
b.group(channel.eventLoop())
.channel(NioSocketChannel.class)
.handler(new ChannelInitializer<SocketChannel>() {

View File

@ -9,7 +9,8 @@ import io.netty.handler.codec.socksx.v5.Socks5AddressType;
import io.netty.handler.codec.socksx.v5.Socks5CommandRequestDecoder;
import io.netty.handler.codec.socksx.v5.Socks5CommandStatus;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.socket.AbstractHandleSocketLocalProxyTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.factory.EventLoopGroupFactory;
import org.framework.lazy.cloud.network.heartbeat.protocol.handler.NettyClient2DestInboundHandler;
@ -26,11 +27,13 @@ public class NettySocketProtocolHandleSocketLocalProxyTypeAdvanced
/**
* 处理当前数据
*
* @param ctx 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(ChannelHandlerContext ctx, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
ChannelHandlerContext channelHandlerContext = nettyChannelContext.channelHandlerContext();
EventLoopGroup group = EventLoopGroupFactory.createClientWorkGroup();
String host = nettyProxyMsg.getTargetIpString();
Integer port = Integer.parseInt(nettyProxyMsg.getTargetPortString());
@ -43,7 +46,7 @@ public class NettySocketProtocolHandleSocketLocalProxyTypeAdvanced
.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast(new NettyDest2ClientInboundHandler(ctx));
ch.pipeline().addLast(new NettyDest2ClientInboundHandler(channelHandlerContext));
}
});
log.info("准备连接目标服务器ip={},port={}", host, port);
@ -52,15 +55,15 @@ public class NettySocketProtocolHandleSocketLocalProxyTypeAdvanced
if (future.isSuccess()) {
log.info("目标服务器连接成功");
//添加客户端转发请求到服务端的Handler
ctx.pipeline().addLast(new NettyClient2DestInboundHandler(future));
channel.pipeline().addLast(new NettyClient2DestInboundHandler(future));
DefaultSocks5CommandResponse commandResponse = new DefaultSocks5CommandResponse(Socks5CommandStatus.SUCCESS, socks5AddressType);
ctx.writeAndFlush(commandResponse);
ctx.pipeline().remove(NettySocks5CommandRequestHandler.class);
ctx.pipeline().remove(Socks5CommandRequestDecoder.class);
channel.writeAndFlush(commandResponse);
channel.pipeline().remove(NettySocks5CommandRequestHandler.class);
channel.pipeline().remove(Socks5CommandRequestDecoder.class);
} else {
log.error("连接目标服务器失败,address={},port={}", host, port);
DefaultSocks5CommandResponse commandResponse = new DefaultSocks5CommandResponse(Socks5CommandStatus.FAILURE, socks5AddressType);
ctx.writeAndFlush(commandResponse);
channel.writeAndFlush(commandResponse);
future.channel().close();
}

View File

@ -7,7 +7,7 @@ import io.netty.channel.socket.nio.NioDatagramChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.http.FullHttpRequest;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;

View File

@ -6,7 +6,7 @@ import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.socksx.v5.*;
import io.netty.util.ReferenceCountUtil;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;