[fix] socks、http代理 添加流量计费

This commit is contained in:
wujiawei 2025-06-06 23:01:52 +08:00
parent 664bafdc86
commit 9cd85abe1d
23 changed files with 288 additions and 39 deletions

View File

@ -1,6 +1,8 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.flow.proxy;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelFlowEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyFlowTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyTypeEnum;
public interface ChannelProxyFlow {
@ -32,6 +34,18 @@ public interface ChannelProxyFlow {
*/
ChannelFlowEnum channelFlowEnum();
/**
* 代理流量类型
* @see ChannelProxyFlowTypeEnum
*/
ChannelProxyFlowTypeEnum channelProxyFlowTypeEnum();
/**
* 代理类型
* @see ChannelProxyTypeEnum
*/
ChannelProxyTypeEnum channelProxyTypeEnum();
/**
* 流量
*

View File

@ -0,0 +1,21 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.http.server;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.AbstractHandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ProxyMessageTypeEnums;
public abstract class AbstractHandleHttpReportClientProxyClientTransferRequestTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
/**
* 是否支持当前类型
*
* @param nettyProxyMsg 通道数据
* @return 布尔类型
*/
@Override
protected boolean doSupport(NettyProxyMsg nettyProxyMsg) {
return ProxyMessageTypeEnums.HTTP_REPORT_CLIENT_PROXY_CLIENT_TRANSFER_REQUEST_.getTypeByte() == nettyProxyMsg.getType();
}
}

View File

@ -84,6 +84,14 @@ public class ProxyMessageType {
*/
public static final byte HTTP_REPORT_CLIENT_PROXY_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL_ = HTTP_REPORT_CLIENT_PROXY_CLIENT_TRANSFER_CONNECTION_ + 1;
/**
* http 另一个客户端将返回数据通过传输通道返回
*
* @see ProxyMessageTypeEnums#HTTP_REPORT_CLIENT_PROXY_CLIENT_TRANSFER_REQUEST_
* @see AbstractHandleHttpReportClientProxyClientTransferRequestTypeAdvanced
*/
public static final byte HTTP_REPORT_CLIENT_PROXY_CLIENT_TRANSFER_REQUEST_ = HTTP_REPORT_CLIENT_PROXY_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL_ + 1;
/**
* http 另一个客户端将返回数据通过传输通道返回
@ -91,7 +99,7 @@ public class ProxyMessageType {
* @see ProxyMessageTypeEnums#HTTP_REPORT_CLIENT_PROXY_CLIENT_TRANSFER_RESPONSE_
* @see AbstractHandleHttpReportClientProxyClientTransferResponseTypeAdvanced
*/
public static final byte HTTP_REPORT_CLIENT_PROXY_CLIENT_TRANSFER_RESPONSE_ = HTTP_REPORT_CLIENT_PROXY_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL_ + 1;
public static final byte HTTP_REPORT_CLIENT_PROXY_CLIENT_TRANSFER_RESPONSE_ = HTTP_REPORT_CLIENT_PROXY_CLIENT_TRANSFER_REQUEST_ + 1;
/**
* 上报传输通道关闭

View File

@ -0,0 +1,17 @@
package org.framework.lazy.cloud.network.heartbeat.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 代理流量类型
*/
@Getter
@AllArgsConstructor
public enum ChannelProxyFlowTypeEnum {
// HTTP
HTTP,
// Socks
SOCKS
}

View File

@ -0,0 +1,19 @@
package org.framework.lazy.cloud.network.heartbeat.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 代理类型
*/
@Getter
@AllArgsConstructor
public enum ChannelProxyTypeEnum {
SERVER_PROXY_SERVER("服务端代理服务端"),
SERVER_PROXY_CLIENT("服务端远程客户端"),
CLIENT_PROXY_CLIENT("客户端远程客户端"),
CLIENT_PROXY_SEVER("客户端远程服务端");
private final String desc;
}

View File

@ -110,6 +110,14 @@ public enum ProxyMessageTypeEnums {
* @see AbstractHandleHttpDistributeClientProxyClientTransferRequestTypeAdvanced
*/
HTTP_DISTRIBUTE_CLIENT_PROXY_CLIENT_TRANSFER_REQUEST_(ProxyMessageType.HTTP_DISTRIBUTE_CLIENT_PROXY_CLIENT_TRANSFER_REQUEST_, "http 下发数据到另一个客户端"),
/**
* http 另一个客户端将返回数据通过传输通道 请求
*
* @see ProxyMessageTypeEnums#HTTP_REPORT_CLIENT_PROXY_CLIENT_TRANSFER_REQUEST_
* @see AbstractHandleHttpReportClientProxyClientTransferRequestTypeAdvanced
*/
HTTP_REPORT_CLIENT_PROXY_CLIENT_TRANSFER_REQUEST_(ProxyMessageType.HTTP_REPORT_CLIENT_PROXY_CLIENT_TRANSFER_REQUEST_, "http 另一个客户端将返回数据通过传输通道请求"),
/**
* http 另一个客户端将返回数据通过传输通道返回
*

View File

@ -18,6 +18,7 @@ public class ChannelAttributeKeyUtils {
private static final AttributeKey<String> ORIGINAL_IP = AttributeKey.newInstance("originalIp");
private static final AttributeKey<String> TARGET_IP = AttributeKey.newInstance("targetIp");
private static final AttributeKey<Integer> TARGET_PORT = AttributeKey.newInstance("targetPort");
private static final AttributeKey<String> TARGET_CLIENT_ID = AttributeKey.newInstance("targetClientId");
private static final AttributeKey<Integer> OUT_FLOW = AttributeKey.newInstance("outFlow");
private static final AttributeKey<Integer> IN_FLOW = AttributeKey.newInstance("inFlow");
@ -87,6 +88,36 @@ public class ChannelAttributeKeyUtils {
}
/**
* 为通道绑定 访客属性
*
* @param channel 通道
* @param targetClientId 客户端ID
*/
public static void buildTargetClientId(Channel channel, byte[] targetClientId) {
channel.attr(TARGET_CLIENT_ID).set(new String(targetClientId));
}
/**
* 为通道绑定 访客属性
*
* @param channel 通道
* @param targetClientId 客户端ID
*/
public static void buildTargetClientId(Channel channel, String targetClientId) {
channel.attr(TARGET_CLIENT_ID).set(targetClientId);
}
/**
* 获取 通道中访客ID
*
* @param channel 通道
*/
public static String getTargetClientId(Channel channel) {
return channel.attr(TARGET_CLIENT_ID).get();
}
/**
* 为通道绑定 出口流量
*

View File

@ -203,13 +203,13 @@ public class ServerAutoConfiguration {
@Configuration()
static class ServerHttpProxyConfiguration {
@Bean
public ServerHandleHttpReportClientProxyServerProxyTransferRequestTypeAdvanced serverHandleHttpReportClientProxyServerProxyTransferTypeAdvanced(ChannelProxyFlowAdapter channelProxyFlowAdapter) {
return new ServerHandleHttpReportClientProxyServerProxyTransferRequestTypeAdvanced(channelProxyFlowAdapter);
public ServerHandleHttpReportClientProxyServerTransferRequestTypeAdvanced serverHandleHttpReportClientProxyServerProxyTransferTypeAdvanced(ChannelProxyFlowAdapter channelProxyFlowAdapter) {
return new ServerHandleHttpReportClientProxyServerTransferRequestTypeAdvanced(channelProxyFlowAdapter);
}
@Bean
public ServerHandleHttpReportClientProxyServerProxyTransferResponseTypeAdvanced serverHandleHttpReportClientProxyServerProxyTransferResponseTypeAdvanced(ChannelProxyFlowAdapter channelProxyFlowAdapter) {
return new ServerHandleHttpReportClientProxyServerProxyTransferResponseTypeAdvanced(channelProxyFlowAdapter);
public ServerHandleHttpReportClientProxyServerTransferResponseTypeAdvanced serverHandleHttpReportClientProxyServerProxyTransferResponseTypeAdvanced(ChannelProxyFlowAdapter channelProxyFlowAdapter) {
return new ServerHandleHttpReportClientProxyServerTransferResponseTypeAdvanced(channelProxyFlowAdapter);
}
@ -219,8 +219,8 @@ public class ServerAutoConfiguration {
}
@Bean
public ServerHandleHttpReportClientProxyClientConnectTransferTypeAdvanced serverHandleHttpReportClientProxyClientConnectTransferTypeAdvanced(ChannelProxyFlowAdapter channelProxyFlowAdapter) {
return new ServerHandleHttpReportClientProxyClientConnectTransferTypeAdvanced(channelProxyFlowAdapter);
public ServerHandleHttpReportClientProxyClientTransferRequestTypeAdvanced serverHandleHttpReportClientProxyClientConnectTransferTypeAdvanced(ChannelProxyFlowAdapter channelProxyFlowAdapter) {
return new ServerHandleHttpReportClientProxyClientTransferRequestTypeAdvanced(channelProxyFlowAdapter);
}
@Bean
@ -242,8 +242,8 @@ public class ServerAutoConfiguration {
}
@Bean
public ServerHandleHttpReportServerProxyClientTransferChannelInitSuccessfulTypeAdvanced serverHandleHttpReportServerProxyClientTransferChannelInitSuccessfulTypeAdvanced(ChannelProxyFlowAdapter channelProxyFlowAdapter) {
return new ServerHandleHttpReportServerProxyClientTransferChannelInitSuccessfulTypeAdvanced(channelProxyFlowAdapter);
public ServerHandleHttpReportServerProxyClientTransferRequestTypeAdvanced serverHandleHttpReportServerProxyClientTransferChannelInitSuccessfulTypeAdvanced(ChannelProxyFlowAdapter channelProxyFlowAdapter) {
return new ServerHandleHttpReportServerProxyClientTransferRequestTypeAdvanced(channelProxyFlowAdapter);
}
@Bean

View File

@ -4,6 +4,8 @@ import lombok.Builder;
import lombok.Data;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.flow.proxy.ChannelProxyFlow;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelFlowEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyFlowTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyTypeEnum;
@Builder
@Data
@ -12,6 +14,8 @@ public class ServerChannelProxyFlow implements ChannelProxyFlow {
private String ip;
private Integer port;
private ChannelFlowEnum channelFlowEnum;
private ChannelProxyFlowTypeEnum channelProxyFlowTypeEnum;
private ChannelProxyTypeEnum channelProxyTypeEnum;
private Integer flow;
/**
@ -55,6 +59,26 @@ public class ServerChannelProxyFlow implements ChannelProxyFlow {
return channelFlowEnum;
}
/**
* 代理流量类型
*
* @see ChannelProxyFlowTypeEnum
*/
@Override
public ChannelProxyFlowTypeEnum channelProxyFlowTypeEnum() {
return channelProxyFlowTypeEnum;
}
/**
* 代理类型
*
* @see ChannelProxyTypeEnum
*/
@Override
public ChannelProxyTypeEnum channelProxyTypeEnum() {
return channelProxyTypeEnum;
}
/**
* 流量
*

View File

@ -5,7 +5,6 @@ import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.ChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.NettyByteBuf;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelFlowAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelProxyFlowAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.NettyTransferChannelContext;
@ -13,8 +12,9 @@ import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyC
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.http.server.AbstractHandleHttpReportClientProxyClientConnectionTransferTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelFlowEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyFlowTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.netty.flow.ServerChannelFlow;
import org.framework.lazy.cloud.network.heartbeat.server.netty.flow.proxy.ServerChannelProxyFlow;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
@ -28,12 +28,12 @@ import org.springframework.stereotype.Component;
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleHttpReportClientProxyClientConnectTransferTypeAdvanced
public class ServerHandleHttpReportClientProxyClientTransferRequestTypeAdvanced
extends AbstractHandleHttpReportClientProxyClientConnectionTransferTypeAdvanced<NettyProxyMsg> {
private final ChannelProxyFlowAdapter channelProxyFlowAdapter;
public ServerHandleHttpReportClientProxyClientConnectTransferTypeAdvanced(ChannelProxyFlowAdapter channelProxyFlowAdapter) {
public ServerHandleHttpReportClientProxyClientTransferRequestTypeAdvanced(ChannelProxyFlowAdapter channelProxyFlowAdapter) {
this.channelProxyFlowAdapter = channelProxyFlowAdapter;
}
@ -49,6 +49,7 @@ public class ServerHandleHttpReportClientProxyClientConnectTransferTypeAdvanced
Channel channel = nettyChannelContext.channel();
// 创建链接发送数据
String targetPortString = nettyProxyMsg.getTargetPortString();
Integer targetPort = Integer.parseInt(targetPortString);
String targetIpString = nettyProxyMsg.getTargetIpString();
byte[] data = nettyProxyMsg.getData();
byte[] visitorId = nettyProxyMsg.getVisitorId();
@ -56,6 +57,9 @@ public class ServerHandleHttpReportClientProxyClientConnectTransferTypeAdvanced
String msgVisitorId = new String(visitorId);
ChannelAttributeKeyUtils.buildClientId(channel, clientId);
ChannelAttributeKeyUtils.buildVisitorId(channel, msgVisitorId);
ChannelAttributeKeyUtils.buildTargetClientId(channel, clientId);
ChannelAttributeKeyUtils.buildTargetIp(channel, targetIpString);
ChannelAttributeKeyUtils.buildTargetPort(channel, targetPort);
NettyTransferChannelContext.pushVisitor(channel, msgVisitorId);
NettyByteBuf nettyByteBuf = new NettyByteBuf();
@ -67,7 +71,7 @@ public class ServerHandleHttpReportClientProxyClientConnectTransferTypeAdvanced
NettyProxyMsg clientConnectTagetNettyProxyMsg = new NettyProxyMsg();
clientConnectTagetNettyProxyMsg.setVisitorId(msgVisitorId);
clientConnectTagetNettyProxyMsg.setClientTargetIp(targetIpString);
clientConnectTagetNettyProxyMsg.setClientTargetPort(Integer.parseInt(targetPortString));
clientConnectTagetNettyProxyMsg.setClientTargetPort(targetPort);
clientConnectTagetNettyProxyMsg.setClientId(clientId);
clientConnectTagetNettyProxyMsg.setType(ProxyMessageType.HTTP_DISTRIBUTE_CLIENT_PROXY_CLIENT_TRANSFER_CONNECTION_SUCCESSFUL_);
if (loadBalance != null) {
@ -80,8 +84,11 @@ public class ServerHandleHttpReportClientProxyClientConnectTransferTypeAdvanced
ServerChannelProxyFlow serverChannelFlow = ServerChannelProxyFlow
.builder()
.channelFlowEnum(ChannelFlowEnum.IN_FLOW)
.port(Integer.parseInt(targetPortString))
.port(targetPort)
.ip(targetIpString)
.clientId(new String(clientId))
.channelProxyTypeEnum(ChannelProxyTypeEnum.CLIENT_PROXY_CLIENT)
.channelProxyFlowTypeEnum(ChannelProxyFlowTypeEnum.HTTP)
.flow(data.length)
.build();
channelProxyFlowAdapter.asyncHandler(channel, serverChannelFlow);

View File

@ -10,6 +10,8 @@ import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyP
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.http.server.AbstractHandleHttpReportClientProxyClientTransferResponseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelFlowEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyFlowTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.netty.flow.ServerChannelFlow;
import org.framework.lazy.cloud.network.heartbeat.server.netty.flow.proxy.ServerChannelProxyFlow;
@ -47,6 +49,9 @@ public class ServerHandleHttpReportClientProxyClientTransferResponseTypeAdvanced
// 将返回数据下发客户端
Channel transferNextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(channel);
String targetIp = ChannelAttributeKeyUtils.getTargetIp(transferNextChannel);
Integer targetPort = ChannelAttributeKeyUtils.getTargetPort(transferNextChannel);
String clientId = nettyProxyMsg.getClientIdString();
Integer visitorPort = nettyProxyMsg.getVisitorPortInt();
String visitorId = nettyProxyMsg.getVisitorIdString();
@ -61,8 +66,11 @@ public class ServerHandleHttpReportClientProxyClientTransferResponseTypeAdvanced
ServerChannelProxyFlow serverChannelFlow = ServerChannelProxyFlow
.builder()
.channelFlowEnum(ChannelFlowEnum.OUT_FLOW)
.port(visitorPort)
.port(targetPort)
.ip(targetIp)
.clientId(clientId)
.channelProxyTypeEnum(ChannelProxyTypeEnum.CLIENT_PROXY_CLIENT)
.channelProxyFlowTypeEnum(ChannelProxyFlowTypeEnum.HTTP)
.flow(responseProxyMsg.getData().length)
.build();
channelProxyFlowAdapter.asyncHandler(channel, serverChannelFlow);

View File

@ -10,6 +10,8 @@ import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelT
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.http.server.AbstractHandleHttpReportClientProxyServerTransferRequestTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelFlowEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyFlowTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.netty.flow.proxy.ServerChannelProxyFlow;
import org.framework.lazy.cloud.network.heartbeat.server.netty.proxy.http.NettyHttpClientProxyServerTransfer;
@ -30,12 +32,12 @@ import java.util.List;
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleHttpReportClientProxyServerProxyTransferRequestTypeAdvanced
public class ServerHandleHttpReportClientProxyServerTransferRequestTypeAdvanced
extends AbstractHandleHttpReportClientProxyServerTransferRequestTypeAdvanced<NettyProxyMsg> {
private final ChannelProxyFlowAdapter channelProxyFlowAdapter;
public ServerHandleHttpReportClientProxyServerProxyTransferRequestTypeAdvanced(ChannelProxyFlowAdapter channelProxyFlowAdapter) {
public ServerHandleHttpReportClientProxyServerTransferRequestTypeAdvanced(ChannelProxyFlowAdapter channelProxyFlowAdapter) {
this.channelProxyFlowAdapter = channelProxyFlowAdapter;
}
@ -50,6 +52,7 @@ public class ServerHandleHttpReportClientProxyServerProxyTransferRequestTypeAdva
Channel channel = nettyChannelContext.channel();
// 创建链接发送数据
String targetPortString = nettyProxyMsg.getTargetPortString();
int targetPort = Integer.parseInt(targetPortString);
String targetIpString = nettyProxyMsg.getTargetIpString();
String clientIdString = nettyProxyMsg.getClientIdString();
byte[] data = nettyProxyMsg.getData();
@ -57,6 +60,9 @@ public class ServerHandleHttpReportClientProxyServerProxyTransferRequestTypeAdva
ChannelAttributeKeyUtils.buildClientId(channel, clientIdString);
ChannelAttributeKeyUtils.buildTargetClientId(channel, clientIdString);
ChannelAttributeKeyUtils.buildTargetIp(channel, targetIpString);
ChannelAttributeKeyUtils.buildTargetPort(channel,targetPort);
List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList = new ArrayList<>(SpringContextHolder.getApplicationContext().getBeansOfType(HandleChannelTypeAdvanced.class).values());
NettyClientProperties nettyClientProperties = SpringContextHolder.getBean(NettyClientProperties.class);
@ -64,7 +70,7 @@ public class ServerHandleHttpReportClientProxyServerProxyTransferRequestTypeAdva
NettyHttpClientProxyServerTransfer nettyHttpClientProxyServerTransfer = new NettyHttpClientProxyServerTransfer();
nettyHttpClientProxyServerTransfer.setSsl(false);
nettyHttpClientProxyServerTransfer.setTargetIp(targetIpString);
nettyHttpClientProxyServerTransfer.setTargetPort(Integer.parseInt(targetPortString));
nettyHttpClientProxyServerTransfer.setTargetPort(targetPort);
nettyHttpClientProxyServerTransfer.setHandleChannelTypeAdvancedList(handleChannelTypeAdvancedList);
@ -79,8 +85,11 @@ public class ServerHandleHttpReportClientProxyServerProxyTransferRequestTypeAdva
ServerChannelProxyFlow serverChannelFlow = ServerChannelProxyFlow
.builder()
.channelFlowEnum(ChannelFlowEnum.IN_FLOW)
.port(Integer.parseInt(targetPortString))
.port(targetPort)
.ip(targetIpString)
.clientId(clientIdString)
.channelProxyTypeEnum(ChannelProxyTypeEnum.CLIENT_PROXY_SEVER)
.channelProxyFlowTypeEnum(ChannelProxyFlowTypeEnum.HTTP)
.flow(data.length)
.build();
channelProxyFlowAdapter.asyncHandler(channel, serverChannelFlow);

View File

@ -9,6 +9,8 @@ import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyP
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.http.server.AbstractHandleHttpReportClientProxyServerTransferResponseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelFlowEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyFlowTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.netty.flow.proxy.ServerChannelProxyFlow;
import org.springframework.beans.factory.config.BeanDefinition;
@ -23,12 +25,12 @@ import org.springframework.stereotype.Component;
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleHttpReportClientProxyServerProxyTransferResponseTypeAdvanced
public class ServerHandleHttpReportClientProxyServerTransferResponseTypeAdvanced
extends AbstractHandleHttpReportClientProxyServerTransferResponseTypeAdvanced<NettyProxyMsg> {
private final ChannelProxyFlowAdapter channelProxyFlowAdapter;
public ServerHandleHttpReportClientProxyServerProxyTransferResponseTypeAdvanced(ChannelProxyFlowAdapter channelProxyFlowAdapter) {
public ServerHandleHttpReportClientProxyServerTransferResponseTypeAdvanced(ChannelProxyFlowAdapter channelProxyFlowAdapter) {
this.channelProxyFlowAdapter = channelProxyFlowAdapter;
}
@ -45,6 +47,9 @@ public class ServerHandleHttpReportClientProxyServerProxyTransferResponseTypeAdv
byte[] data = nettyProxyMsg.getData();
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
String targetIp = ChannelAttributeKeyUtils.getTargetIp(nextChannel);
Integer targetPort = ChannelAttributeKeyUtils.getTargetPort(nextChannel);
// 将数据返回给客户端
NettyProxyMsg responseNettyProxyMsg = new NettyProxyMsg();
responseNettyProxyMsg.setType(ProxyMessageType.HTTP_DISTRIBUTE_CLIENT_PROXY_SERVER_TRANSFER_);
@ -59,8 +64,11 @@ public class ServerHandleHttpReportClientProxyServerProxyTransferResponseTypeAdv
ServerChannelProxyFlow serverChannelFlow = ServerChannelProxyFlow
.builder()
.channelFlowEnum(ChannelFlowEnum.OUT_FLOW)
.port(visitorPort)
.port(targetPort)
.ip(targetIp)
.clientId(clientId)
.channelProxyTypeEnum(ChannelProxyTypeEnum.CLIENT_PROXY_SEVER)
.channelProxyFlowTypeEnum(ChannelProxyFlowTypeEnum.HTTP)
.flow(data.length)
.build();
channelProxyFlowAdapter.asyncHandler(channel, serverChannelFlow);

View File

@ -11,6 +11,8 @@ import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyC
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.http.server.AbstractHandleHttpReportServerProxyClientTransferChannelInitSuccessfulTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelFlowEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyFlowTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.netty.flow.proxy.ServerChannelProxyFlow;
import org.springframework.beans.factory.config.BeanDefinition;
@ -21,12 +23,12 @@ import org.springframework.stereotype.Component;
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleHttpReportServerProxyClientTransferChannelInitSuccessfulTypeAdvanced
public class ServerHandleHttpReportServerProxyClientTransferRequestTypeAdvanced
extends AbstractHandleHttpReportServerProxyClientTransferChannelInitSuccessfulTypeAdvanced<NettyProxyMsg> {
private final ChannelProxyFlowAdapter channelProxyFlowAdapter;
public ServerHandleHttpReportServerProxyClientTransferChannelInitSuccessfulTypeAdvanced(ChannelProxyFlowAdapter channelProxyFlowAdapter) {
public ServerHandleHttpReportServerProxyClientTransferRequestTypeAdvanced(ChannelProxyFlowAdapter channelProxyFlowAdapter) {
this.channelProxyFlowAdapter = channelProxyFlowAdapter;
}
@ -43,11 +45,19 @@ public class ServerHandleHttpReportServerProxyClientTransferChannelInitSuccessfu
// 数据下发
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
byte[] msgClientTargetIp = nettyProxyMsg.getClientTargetIp();
byte[] msgClientTargetPort = nettyProxyMsg.getClientTargetPort();
String targetIpString = nettyProxyMsg.getTargetIpString();
String targetPortString = nettyProxyMsg.getTargetPortString();
Integer targetPort = Integer.parseInt(targetPortString);
byte[] clientId = nettyProxyMsg.getClientId();
ChannelAttributeKeyUtils.buildTargetClientId(channel, clientId);
ChannelAttributeKeyUtils.buildTargetIp(channel, targetIpString);
ChannelAttributeKeyUtils.buildTargetPort(channel, targetPort);
// next
Channel nextChannel = NettyTransferChannelContext.getVisitor(msgVisitorId);
ChannelAttributeKeyUtils.buildNextChannel(nextChannel, channel);
@ -62,8 +72,8 @@ public class ServerHandleHttpReportServerProxyClientTransferChannelInitSuccessfu
NettyProxyMsg clientConnectTagetNettyProxyMsg = new NettyProxyMsg();
clientConnectTagetNettyProxyMsg.setVisitorId(msgVisitorId);
clientConnectTagetNettyProxyMsg.setClientTargetIp(msgClientTargetIp);
clientConnectTagetNettyProxyMsg.setClientTargetPort(msgClientTargetPort);
clientConnectTagetNettyProxyMsg.setClientTargetIp(targetIpString);
clientConnectTagetNettyProxyMsg.setClientTargetPort(targetPort);
clientConnectTagetNettyProxyMsg.setClientId(clientId);
clientConnectTagetNettyProxyMsg.setData(nettyByteBufData.getData());
@ -75,8 +85,11 @@ public class ServerHandleHttpReportServerProxyClientTransferChannelInitSuccessfu
ServerChannelProxyFlow serverChannelFlow = ServerChannelProxyFlow
.builder()
.channelFlowEnum(ChannelFlowEnum.IN_FLOW)
.port(Integer.parseInt(new String(msgClientTargetPort)))
.port(targetPort)
.ip(targetIpString)
.clientId(new String(clientId))
.channelProxyTypeEnum(ChannelProxyTypeEnum.SERVER_PROXY_CLIENT)
.channelProxyFlowTypeEnum(ChannelProxyFlowTypeEnum.HTTP)
.flow(nettyByteBufData.getData().length)
.build();
channelProxyFlowAdapter.asyncHandler(channel, serverChannelFlow);

View File

@ -9,6 +9,8 @@ import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyP
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.http.server.AbstractHandleHttpReportServerProxyClientTransferResponseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelFlowEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyFlowTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.netty.flow.proxy.ServerChannelProxyFlow;
import org.springframework.beans.factory.config.BeanDefinition;
@ -43,6 +45,9 @@ public class ServerHandleHttpReportServerProxyClientTransferResponseTypeAdvanced
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
String clientId = ChannelAttributeKeyUtils.getClientId(nextChannel);
Integer visitorPort = ChannelAttributeKeyUtils.getVisitorPort(nextChannel);
String targetClientId = ChannelAttributeKeyUtils.getTargetClientId(nextChannel);
String targetIp = ChannelAttributeKeyUtils.getTargetIp(nextChannel);
Integer targetPort = ChannelAttributeKeyUtils.getTargetPort(nextChannel);
if(ObjectUtils.isNotEmpty(nextChannel)) {
log.info("目标客户端返回数据通过服务端下发到原始通道");
@ -54,8 +59,11 @@ public class ServerHandleHttpReportServerProxyClientTransferResponseTypeAdvanced
ServerChannelProxyFlow serverChannelFlow = ServerChannelProxyFlow
.builder()
.channelFlowEnum(ChannelFlowEnum.OUT_FLOW)
.port(visitorPort)
.clientId(clientId)
.port(targetPort)
.ip(targetIp)
.clientId(targetClientId)
.channelProxyTypeEnum(ChannelProxyTypeEnum.SERVER_PROXY_CLIENT)
.channelProxyFlowTypeEnum(ChannelProxyFlowTypeEnum.HTTP)
.flow(nettyProxyMsg.getData().length)
.build();
channelProxyFlowAdapter.asyncHandler(channel, serverChannelFlow);

View File

@ -9,6 +9,8 @@ import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyP
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.socks.server.AbstractHandleSocksReportClientProxyClientTransferRequestTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelFlowEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyFlowTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.netty.flow.proxy.ServerChannelProxyFlow;
import org.framework.lazy.cloud.network.heartbeat.server.netty.proxy.socks.handler.NettySocksClientProxyServerRealHandler;
@ -62,6 +64,8 @@ public class ServerHandleSocksReportClientProxyClientTransferRequestTypeAdvanced
.port(targetPort)
.ip(targetIp)
.clientId(clientId)
.channelProxyTypeEnum(ChannelProxyTypeEnum.CLIENT_PROXY_CLIENT)
.channelProxyFlowTypeEnum(ChannelProxyFlowTypeEnum.SOCKS)
.flow(nettyProxyMsg.getData().length)
.build();
channelProxyFlowAdapter.asyncHandler(transferChannel, serverChannelFlow);

View File

@ -9,6 +9,8 @@ import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyP
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.socks.server.AbstractHandleSocksReportClientProxyClientTransferResponseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelFlowEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyFlowTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.netty.flow.proxy.ServerChannelProxyFlow;
import org.framework.lazy.cloud.network.heartbeat.server.netty.proxy.socks.handler.NettySocksClientProxyServerRealHandler;
@ -61,6 +63,8 @@ public class ServerHandleSocksReportClientProxyClientTransferResponseTypeAdvance
.ip(targetIp)
.port(targetPort)
.clientId(clientId)
.channelProxyTypeEnum(ChannelProxyTypeEnum.CLIENT_PROXY_CLIENT)
.channelProxyFlowTypeEnum(ChannelProxyFlowTypeEnum.SOCKS)
.flow(nettyProxyMsg.getData().length)
.build();
channelProxyFlowAdapter.asyncHandler(nextChannel, serverChannelFlow);

View File

@ -9,6 +9,8 @@ import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyC
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.socks.server.AbstractHandleSocksReportClientProxyServerTransferRequestTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelFlowEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyFlowTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.netty.flow.proxy.ServerChannelProxyFlow;
import org.framework.lazy.cloud.network.heartbeat.server.netty.proxy.socks.handler.NettySocksClientProxyServerRealHandler;
@ -60,6 +62,8 @@ public class ServerHandleSocksReportClientProxyServerTransferRequestTypeAdvanced
.port(targetPort)
.ip(targetIp)
.clientId(clientId)
.channelProxyTypeEnum(ChannelProxyTypeEnum.CLIENT_PROXY_SEVER)
.channelProxyFlowTypeEnum(ChannelProxyFlowTypeEnum.SOCKS)
.flow(nettyProxyMsg.getData().length)
.build();
channelProxyFlowAdapter.asyncHandler(transferChannel, serverChannelFlow);

View File

@ -11,6 +11,8 @@ import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.http.ser
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.socks.server.AbstractHandleSocksReportClientProxyServerTransferResponseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelFlowEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyFlowTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.netty.flow.proxy.ServerChannelProxyFlow;
import org.framework.lazy.cloud.network.heartbeat.server.netty.proxy.socks.handler.NettySocksClientProxyServerRealHandler;
@ -63,6 +65,8 @@ public class ServerHandleSocksReportClientProxyServerTransferResponseTypeAdvance
.ip(targetIp)
.port(targetPort)
.clientId(clientId)
.channelProxyTypeEnum(ChannelProxyTypeEnum.CLIENT_PROXY_SEVER)
.channelProxyFlowTypeEnum(ChannelProxyFlowTypeEnum.SOCKS)
.flow(nettyProxyMsg.getData().length)
.build();
channelProxyFlowAdapter.asyncHandler(nextChannel, serverChannelFlow);

View File

@ -1,7 +1,6 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.proxy.socks.advanced;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.util.ReferenceCountUtil;
import lombok.extern.slf4j.Slf4j;
@ -9,14 +8,16 @@ import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelProxyFlo
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.AbstractHandleSocksReportServerProxyClientRequestTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.socks.server.AbstractHandleSocksReportServerProxyClientResponseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelFlowEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyFlowTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.netty.flow.proxy.ServerChannelProxyFlow;
import org.framework.lazy.cloud.network.heartbeat.server.netty.proxy.socks.handler.NettySocksClientProxyServerRealHandler;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
import org.wu.framework.core.utils.ObjectUtils;
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@ -41,6 +42,9 @@ public class ServerHandleSocksReportServerProxyClientRequestTypeAdvanced
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
String targetClientId = ChannelAttributeKeyUtils.getTargetClientId(channel);
String targetIp = ChannelAttributeKeyUtils.getTargetIp(channel);
Integer targetPort = ChannelAttributeKeyUtils.getTargetPort(channel);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
@ -52,6 +56,18 @@ public class ServerHandleSocksReportServerProxyClientRequestTypeAdvanced
nettyProxyMsgRequest.setData(nettyProxyMsg.getData());
nextChannel.writeAndFlush(nettyProxyMsgRequest);
// 记录进口数据
ServerChannelProxyFlow serverChannelFlow = ServerChannelProxyFlow
.builder()
.channelFlowEnum(ChannelFlowEnum.IN_FLOW)
.port(targetPort)
.ip(targetIp)
.clientId("SERVER")
.channelProxyTypeEnum(ChannelProxyTypeEnum.SERVER_PROXY_CLIENT)
.channelProxyFlowTypeEnum(ChannelProxyFlowTypeEnum.SOCKS)
.flow(nettyProxyMsg.getData().length)
.build();
channelProxyFlowAdapter.asyncHandler(channel, serverChannelFlow);
} else {
log.info("释放内存");
ReferenceCountUtil.release(nettyProxyMsg);

View File

@ -8,8 +8,11 @@ import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelProxyFlo
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.AbstractHandleSocksReportServerProxyClientResponseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelFlowEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyFlowTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyTypeEnum;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.netty.flow.proxy.ServerChannelProxyFlow;
import org.framework.lazy.cloud.network.heartbeat.server.netty.proxy.socks.handler.NettySocksClientProxyServerRealHandler;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
@ -40,11 +43,28 @@ public class ServerHandleSocksReportServerProxyClientResponseTypeAdvanced
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
String targetClientId = ChannelAttributeKeyUtils.getTargetClientId(nextChannel);
String targetIp = ChannelAttributeKeyUtils.getTargetIp(nextChannel);
Integer targetPort = ChannelAttributeKeyUtils.getTargetPort(nextChannel);
if(ObjectUtils.isNotEmpty(nextChannel)&&nextChannel.isActive()){
ByteBuf buf = nextChannel.config().getAllocator().buffer(nettyProxyMsg.getData().length);
buf.writeBytes(nettyProxyMsg.getData());
nextChannel.writeAndFlush(buf);
// 记录出口数据
ServerChannelProxyFlow serverChannelFlow = ServerChannelProxyFlow
.builder()
.channelFlowEnum(ChannelFlowEnum.OUT_FLOW)
.ip(targetIp)
.port(targetPort)
.clientId("SERVER")
.channelProxyTypeEnum(ChannelProxyTypeEnum.SERVER_PROXY_CLIENT)
.channelProxyFlowTypeEnum(ChannelProxyFlowTypeEnum.SOCKS)
.flow(nettyProxyMsg.getData().length)
.build();
channelProxyFlowAdapter.asyncHandler(nextChannel, serverChannelFlow);
}else {
log.error("服务端代理客户端socks本地通道已关闭");
}

View File

@ -47,8 +47,12 @@ public class ServerHandleSocksReportServerProxyClientTypeAdvanced
String msgVisitorId = new String(visitorId);
ChannelAttributeKeyUtils.buildVisitorId(visitorrChannel, msgVisitorId);
NettyTransferChannelContext.pushVisitor(visitorrChannel, msgVisitorId);
ChannelAttributeKeyUtils.buildTargetIp(visitorrChannel, host);
ChannelAttributeKeyUtils.buildTargetPort(visitorrChannel,port);
ChannelAttributeKeyUtils.buildTargetClientId(visitorrChannel,targetClientId);
ChannelAttributeKeyUtils.buildSocks5AddressType(visitorrChannel,socks5AddressTypeByte);
NettyTransferChannelContext.pushVisitor(visitorrChannel, msgVisitorId);
// 客户端连接客户端传输通道
Channel loadBalance = ChannelContext.getLoadBalance(targetClientId);

View File

@ -32,8 +32,6 @@ public class NettySocksServerProxyClientVisitorInboundHandler extends SimpleChan
@Override
public void channelRead0(ChannelHandlerContext ctx, NettyByteBuf nettyByteBuf) throws Exception {
log.info("【socks】转发服务端请求到客户端");
// 结果下发
Channel channel = ctx.channel();
byte[] bytes = nettyByteBuf.getData();
log.debug("bytes.length:{}",bytes.length);
log.debug("服务端代理客户端,socks本地接收请求数据:{}", new String(bytes));