优化数据统计

This commit is contained in:
GoEdgeLab
2023-07-30 14:49:16 +08:00
parent e6e3485acd
commit de2b0959b5
8 changed files with 61 additions and 8 deletions

View File

@@ -7,6 +7,7 @@ import (
"github.com/TeaOSLab/EdgeNode/internal/firewalls"
"github.com/TeaOSLab/EdgeNode/internal/iplibrary"
"net"
"sync/atomic"
"time"
)
@@ -25,6 +26,8 @@ type BaseClientConn struct {
isClosed bool
rawIP string
totalSentBytes int64
}
func (this *BaseClientConn) IsClosed() bool {
@@ -160,3 +163,10 @@ func (this *BaseClientConn) SetFingerprint(fingerprint []byte) {
func (this *BaseClientConn) Fingerprint() []byte {
return this.fingerprint
}
// LastRequestBytes 读取上一次请求发送的字节数
func (this *BaseClientConn) LastRequestBytes() int64 {
var result = atomic.LoadInt64(&this.totalSentBytes)
atomic.StoreInt64(&this.totalSentBytes, 0)
return result
}