mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-21 07:49:38 +08:00
33 lines
579 B
Go
33 lines
579 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
|
|
LocalAddr string
|
|
RemoteAddr 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)
|
|
}
|