traffic

package
v0.17.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoltStore

type BoltStore struct {
	// contains filtered or unexported fields
}

func NewBoltStore

func NewBoltStore(path string) *BoltStore

func (*BoltStore) LoadTraffic

func (b *BoltStore) LoadTraffic() (map[string]UserTotals, error)

func (*BoltStore) ResetUserTraffic

func (b *BoltStore) ResetUserTraffic(username string) error

func (*BoltStore) SaveTraffic

func (b *BoltStore) SaveTraffic(totals map[string]UserTotals) error

type Session

type Session struct {
	// contains filtered or unexported fields
}

func (*Session) AddDownload

func (s *Session) AddDownload(n int64)

func (*Session) AddUpload

func (s *Session) AddUpload(n int64)

func (*Session) Close

func (s *Session) Close()

func (*Session) DownloadBytes

func (s *Session) DownloadBytes() uint64

func (*Session) UploadBytes

func (s *Session) UploadBytes() uint64

type Snapshot

type Snapshot struct {
	ID            string
	Username      string
	ClientIP      string
	UploadBytes   uint64
	DownloadBytes uint64
	UploadBPS     uint64
	DownloadBPS   uint64
	StartedAt     time.Time
}

type Store

type Store interface {
	LoadTraffic() (map[string]UserTotals, error)
	SaveTraffic(totals map[string]UserTotals) error
	ResetUserTraffic(username string) error
}

Store persists per-user traffic totals across restarts.

type Tracker

type Tracker struct {
	// contains filtered or unexported fields
}

func NewTracker

func NewTracker() *Tracker

func (*Tracker) LoadPersistedTotals

func (t *Tracker) LoadPersistedTotals(store Store) error

func (*Tracker) ResetUserStats

func (t *Tracker) ResetUserStats(username string)

func (*Tracker) Snapshot

func (t *Tracker) Snapshot() []Snapshot

func (*Tracker) Start

func (t *Tracker) Start(username, clientIP string) *Session

func (*Tracker) TotalsByUser

func (t *Tracker) TotalsByUser() map[string]UserTotals

type UserTotals

type UserTotals struct {
	UploadBytes   uint64
	DownloadBytes uint64
	UploadBPS     uint64
	DownloadBPS   uint64
	LastSeenAt    time.Time
	LastClientIP  string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL