[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 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.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.standalone.application.LazyProxyFlowApplication;
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 {
private final LazyVisitorPortFlowApplication lazyVisitorPortFlowApplication;
private final LazyProxyFlowApplication lazyProxyFlowApplication;
private final ServerNodeProperties serverNodeProperties;
public ServerHandlerInProxyFlowHandler(LazyVisitorPortFlowApplication lazyVisitorPortFlowApplication, ServerNodeProperties serverNodeProperties) {
public ServerHandlerInProxyFlowHandler(LazyVisitorPortFlowApplication lazyVisitorPortFlowApplication, LazyProxyFlowApplication lazyProxyFlowApplication, ServerNodeProperties serverNodeProperties) {
this.lazyVisitorPortFlowApplication = lazyVisitorPortFlowApplication;
this.lazyProxyFlowApplication = lazyProxyFlowApplication;
this.serverNodeProperties = serverNodeProperties;
}
@ -45,15 +49,24 @@ public class ServerHandlerInProxyFlowHandler extends AbstractHandleChannelProxyF
@Override
protected void doHandler(Channel channel, ChannelProxyFlow channelProxyFlow) {
String clientId = channelProxyFlow.clientId();
String ip = channelProxyFlow.ip();
Integer port = channelProxyFlow.port();
Integer flow = channelProxyFlow.flow();
ChannelProtocolType channelProtocolType = channelProxyFlow.channelProtocolType();
ChannelProxyType channelProxyType = channelProxyFlow.channelProxyType();
// TODO
// 进口流量处理
LazyVisitorPortFlowStoryCommand visitorPortFlow = new LazyVisitorPortFlowStoryCommand();
visitorPortFlow.setInFlow(flow);
visitorPortFlow.setClientId(clientId);
visitorPortFlow.setVisitorPort(port);
visitorPortFlow.setIsDeleted(false);
lazyVisitorPortFlowApplication.flowIncreaseStory(visitorPortFlow);
LazyProxyFlowStoryCommand lazyProxyFlowStoryCommand = new LazyProxyFlowStoryCommand();
lazyProxyFlowStoryCommand.setInFlow(flow);
lazyProxyFlowStoryCommand.setClientId(clientId);
lazyProxyFlowStoryCommand.setIp(ip);
lazyProxyFlowStoryCommand.setPort(port);
lazyProxyFlowStoryCommand.setProtocolType(channelProtocolType);
lazyProxyFlowStoryCommand.setProxyType(channelProxyType);
lazyProxyFlowStoryCommand.setIsDeleted(false);
lazyProxyFlowApplication.flowIncreaseStory(lazyProxyFlowStoryCommand);
}
}

View File

@ -32,29 +32,30 @@
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.10.3</version>
<configuration>
<!-- imageName用于设置生成的二进制文件名称 -->
<imageName>${project.artifactId}</imageName>
<!-- mainClass用于指定main方法类路径 -->
<mainClass>org.framework.lazy.cloud.network.heartbeat.server.LazyCloudHeartbeatServerStart</mainClass>
<buildArgs>
--no-fallback
</buildArgs>
</configuration>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>compile-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.10.3</version>
<configuration>
<!-- imageName用于设置生成的二进制文件名称 -->
<imageName>${project.artifactId}</imageName>
<!-- mainClass用于指定main方法类路径 -->
<mainClass>org.framework.lazy.cloud.network.heartbeat.server.LazyCloudHeartbeatServerStart
</mainClass>
<buildArgs>
--no-fallback
</buildArgs>
</configuration>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>compile-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>