[fix] 添加代理流量统计

This commit is contained in:
wujiawei 2025-06-07 00:27:02 +08:00
parent 556cb3fd1b
commit 0505d6d201
2 changed files with 46 additions and 32 deletions

View File

@ -2,22 +2,26 @@ package org.framework.lazy.cloud.network.heartbeat.server.netty.flow.proxy;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.flow.proxy.AbstractHandleChannelProxyFlowAdvanced; import org.framework.lazy.cloud.network.heartbeat.common.advanced.flow.proxy.AbstractHandleChannelProxyFlowAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.flow.ChannelFlow;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.flow.proxy.ChannelProxyFlow; 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.ChannelFlowEnum;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProtocolType;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelProxyType;
import org.framework.lazy.cloud.network.heartbeat.server.properties.ServerNodeProperties; import org.framework.lazy.cloud.network.heartbeat.server.properties.ServerNodeProperties;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.LazyProxyFlowApplication;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.LazyVisitorPortFlowApplication; import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.LazyVisitorPortFlowApplication;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.command.visitor.flow.LazyVisitorPortFlowStoryCommand; import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.command.lazy.proxy.flow.LazyProxyFlowStoryCommand;
/** /**
* 进口流量处理 * 进口流量处理
*/ */
public class ServerHandlerInProxyFlowHandler extends AbstractHandleChannelProxyFlowAdvanced { public class ServerHandlerInProxyFlowHandler extends AbstractHandleChannelProxyFlowAdvanced {
private final LazyVisitorPortFlowApplication lazyVisitorPortFlowApplication; private final LazyVisitorPortFlowApplication lazyVisitorPortFlowApplication;
private final LazyProxyFlowApplication lazyProxyFlowApplication;
private final ServerNodeProperties serverNodeProperties; private final ServerNodeProperties serverNodeProperties;
public ServerHandlerInProxyFlowHandler(LazyVisitorPortFlowApplication lazyVisitorPortFlowApplication, ServerNodeProperties serverNodeProperties) { public ServerHandlerInProxyFlowHandler(LazyVisitorPortFlowApplication lazyVisitorPortFlowApplication, LazyProxyFlowApplication lazyProxyFlowApplication, ServerNodeProperties serverNodeProperties) {
this.lazyVisitorPortFlowApplication = lazyVisitorPortFlowApplication; this.lazyVisitorPortFlowApplication = lazyVisitorPortFlowApplication;
this.lazyProxyFlowApplication = lazyProxyFlowApplication;
this.serverNodeProperties = serverNodeProperties; this.serverNodeProperties = serverNodeProperties;
} }
@ -45,15 +49,24 @@ public class ServerHandlerInProxyFlowHandler extends AbstractHandleChannelProxyF
@Override @Override
protected void doHandler(Channel channel, ChannelProxyFlow channelProxyFlow) { protected void doHandler(Channel channel, ChannelProxyFlow channelProxyFlow) {
String clientId = channelProxyFlow.clientId(); String clientId = channelProxyFlow.clientId();
String ip = channelProxyFlow.ip();
Integer port = channelProxyFlow.port(); Integer port = channelProxyFlow.port();
Integer flow = channelProxyFlow.flow(); Integer flow = channelProxyFlow.flow();
ChannelProtocolType channelProtocolType = channelProxyFlow.channelProtocolType();
ChannelProxyType channelProxyType = channelProxyFlow.channelProxyType();
// TODO
// 进口流量处理 // 进口流量处理
LazyVisitorPortFlowStoryCommand visitorPortFlow = new LazyVisitorPortFlowStoryCommand(); LazyProxyFlowStoryCommand lazyProxyFlowStoryCommand = new LazyProxyFlowStoryCommand();
visitorPortFlow.setInFlow(flow); lazyProxyFlowStoryCommand.setInFlow(flow);
visitorPortFlow.setClientId(clientId); lazyProxyFlowStoryCommand.setClientId(clientId);
visitorPortFlow.setVisitorPort(port); lazyProxyFlowStoryCommand.setIp(ip);
visitorPortFlow.setIsDeleted(false); lazyProxyFlowStoryCommand.setPort(port);
lazyVisitorPortFlowApplication.flowIncreaseStory(visitorPortFlow); lazyProxyFlowStoryCommand.setProtocolType(channelProtocolType);
lazyProxyFlowStoryCommand.setProxyType(channelProxyType);
lazyProxyFlowStoryCommand.setIsDeleted(false);
lazyProxyFlowApplication.flowIncreaseStory(lazyProxyFlowStoryCommand);
} }
} }

View File

@ -40,7 +40,8 @@
<!-- imageName用于设置生成的二进制文件名称 --> <!-- imageName用于设置生成的二进制文件名称 -->
<imageName>${project.artifactId}</imageName> <imageName>${project.artifactId}</imageName>
<!-- mainClass用于指定main方法类路径 --> <!-- mainClass用于指定main方法类路径 -->
<mainClass>org.framework.lazy.cloud.network.heartbeat.server.LazyCloudHeartbeatServerStart</mainClass> <mainClass>org.framework.lazy.cloud.network.heartbeat.server.LazyCloudHeartbeatServerStart
</mainClass>
<buildArgs> <buildArgs>
--no-fallback --no-fallback
</buildArgs> </buildArgs>