mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-19 23:24:44 +08:00
34 lines
601 B
Go
34 lines
601 B
Go
package stats
|
|
|
|
import (
|
|
"sync/atomic"
|
|
"time"
|
|
)
|
|
|
|
type SessionStater interface {
|
|
Start() error
|
|
Stop() error
|
|
AddSession(key interface{}, session *Session)
|
|
GetSession(key interface{}) *Session
|
|
RemoveSession(key interface{})
|
|
}
|
|
|
|
type Session struct {
|
|
ProcessName string
|
|
Network string
|
|
DialerAddr string
|
|
ClientAddr string
|
|
TargetAddr string
|
|
UploadBytes int64
|
|
DownloadBytes int64
|
|
SessionStart time.Time
|
|
}
|
|
|
|
func (s *Session) AddUploadBytes(n int64) {
|
|
atomic.AddInt64(&s.UploadBytes, n)
|
|
}
|
|
|
|
func (s *Session) AddDownloadBytes(n int64) {
|
|
atomic.AddInt64(&s.DownloadBytes, n)
|
|
}
|