mirror of
https://gitee.com/wujiawei1207537021/wu-lazy-cloud-network.git
synced 2025-06-04 20:37:56 +08:00
【fix】修改虚拟路由问题
This commit is contained in:
parent
fe3adeee03
commit
ad7fa61067
@ -58,15 +58,15 @@ public class NettyHttpProxySocketApplicationListener implements SocketApplicatio
|
|||||||
|
|
||||||
channelFuture.addListener((ChannelFutureListener) channelFuture -> {
|
channelFuture.addListener((ChannelFutureListener) channelFuture -> {
|
||||||
// 服务器已启动
|
// 服务器已启动
|
||||||
log.info("http 协议代理 服务器启动成功 【{}】",httpProtocolProxyPort);
|
log.info("Http 协议代理 服务器启动成功 【{}】",httpProtocolProxyPort);
|
||||||
});
|
});
|
||||||
channelFuture.channel().closeFuture().sync();
|
channelFuture.channel().closeFuture().sync();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("启动http 协议代理 失败", e);
|
log.error("启动Http 协议代理 失败", e);
|
||||||
} finally {
|
} finally {
|
||||||
destroy();
|
destroy();
|
||||||
// 服务器已关闭
|
// 服务器已关闭
|
||||||
log.warn("http 协议代理 服务关闭");
|
log.warn("Http 协议代理 服务关闭");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import io.netty.channel.*;
|
|||||||
import io.netty.channel.socket.nio.NioDatagramChannel;
|
import io.netty.channel.socket.nio.NioDatagramChannel;
|
||||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||||
import io.netty.handler.codec.http.FullHttpRequest;
|
import io.netty.handler.codec.http.FullHttpRequest;
|
||||||
|
import io.netty.handler.codec.socksx.v5.Socks5AddressType;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
|
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
||||||
@ -82,18 +83,23 @@ public class NettyHttpProxyHandler extends ChannelInboundHandlerAdapter {
|
|||||||
|
|
||||||
|
|
||||||
ProxyRoute route = RouteContext.getRoute(host, String.valueOf(port));
|
ProxyRoute route = RouteContext.getRoute(host, String.valueOf(port));
|
||||||
String targetIp = route.getTargetIp();
|
|
||||||
String targetPort = route.getTargetPort();
|
|
||||||
proxyMsg.setVisitorId(visitorId);
|
proxyMsg.setVisitorId(visitorId);
|
||||||
proxyMsg.setClientTargetIp(targetIp);
|
|
||||||
proxyMsg.setClientTargetPort(Integer.valueOf(targetPort));
|
|
||||||
proxyMsg.setData(bytes);
|
proxyMsg.setData(bytes);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(ObjectUtils.isEmpty(route)){
|
if(ObjectUtils.isEmpty(route)){
|
||||||
|
// 本地代理
|
||||||
proxyMsg.setType(ProxyMessageType.HTTP_LOCAL_PROXY);
|
proxyMsg.setType(ProxyMessageType.HTTP_LOCAL_PROXY);
|
||||||
|
proxyMsg.setClientTargetIp(host);
|
||||||
|
proxyMsg.setClientTargetPort(port);
|
||||||
}else {
|
}else {
|
||||||
|
// 远程代理
|
||||||
|
String targetIp = route.getTargetIp();
|
||||||
|
String targetPort = route.getTargetPort();
|
||||||
|
proxyMsg.setClientTargetIp(targetIp);
|
||||||
|
proxyMsg.setClientTargetPort(Integer.valueOf(targetPort));
|
||||||
if(RouteType.LOCAL.equals(route.getRouteType())){
|
if(RouteType.LOCAL.equals(route.getRouteType())){
|
||||||
proxyMsg.setType(ProxyMessageType.HTTP_LOCAL_PROXY);
|
proxyMsg.setType(ProxyMessageType.HTTP_LOCAL_PROXY);
|
||||||
}else if (RouteType.CLIENT_PROXY_CLIENT.equals(route.getRouteType())){
|
}else if (RouteType.CLIENT_PROXY_CLIENT.equals(route.getRouteType())){
|
||||||
|
@ -59,15 +59,20 @@ public class NettySocks5CommandRequestHandler extends SimpleChannelInboundHandle
|
|||||||
|
|
||||||
proxyMsg.setVisitorId(visitorId);
|
proxyMsg.setVisitorId(visitorId);
|
||||||
ProxyRoute route = RouteContext.getRoute(host, String.valueOf(port));
|
ProxyRoute route = RouteContext.getRoute(host, String.valueOf(port));
|
||||||
String targetIp = route.getTargetIp();
|
|
||||||
String targetPort = route.getTargetPort();
|
|
||||||
proxyMsg.setClientTargetIp(targetIp);
|
|
||||||
proxyMsg.setClientTargetPort(Integer.parseInt(targetPort));
|
|
||||||
|
|
||||||
|
|
||||||
if(ObjectUtils.isEmpty(route)){
|
if(ObjectUtils.isEmpty(route)){
|
||||||
|
// 未查询到路由信息、本地代理
|
||||||
proxyMsg.setType(ProxyMessageType.SOCKS_LOCAL_PROXY);
|
proxyMsg.setType(ProxyMessageType.SOCKS_LOCAL_PROXY);
|
||||||
|
proxyMsg.setClientTargetIp(host);
|
||||||
|
proxyMsg.setClientTargetPort(port);
|
||||||
}else {
|
}else {
|
||||||
|
// 其他路由代理
|
||||||
|
String targetIp = route.getTargetIp();
|
||||||
|
String targetPort = route.getTargetPort();
|
||||||
|
proxyMsg.setClientTargetIp(targetIp);
|
||||||
|
proxyMsg.setClientTargetPort(Integer.parseInt(targetPort));
|
||||||
if(RouteType.LOCAL.equals(route.getRouteType())){
|
if(RouteType.LOCAL.equals(route.getRouteType())){
|
||||||
proxyMsg.setType(ProxyMessageType.SOCKS_LOCAL_PROXY);
|
proxyMsg.setType(ProxyMessageType.SOCKS_LOCAL_PROXY);
|
||||||
}else if (RouteType.CLIENT_PROXY_CLIENT.equals(route.getRouteType())){
|
}else if (RouteType.CLIENT_PROXY_CLIENT.equals(route.getRouteType())){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user