statistic

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const Name = "STATISTICS"

Variables

This section is empty.

Functions

func RegisterAuthenticatorCreator

func RegisterAuthenticatorCreator(name string, creator Creator)

Types

type Authenticator

type Authenticator interface {
	io.Closer
	AuthUser(hash string) (valid bool, user User)
	AddUser(hash string) error
	DelUser(hash string) error
	SetUserTraffic(hash string, sent, recv uint64) error
	SetUserSpeedLimit(hash string, send, recv int) error
	SetUserIPLimit(hash string, limit int) error
	SetUserQuota(hash string, quota int64) error
	ListUsers() []User
}

func NewAuthenticator

func NewAuthenticator(ctx context.Context, name string) (Authenticator, error)

type Creator

type Creator func(ctx context.Context) (Authenticator, error)

type IPRecorder

type IPRecorder interface {
	AddIP(string) bool
	DelIP(string) bool
	GetIP() int
}

type Metadata

type Metadata interface {
	GetHash() string
	GetTraffic() (sent, recv uint64)
	GetSpeedLimit() (sent, recv int)
	GetIPLimit() int
	GetQuota() int64
	// Done returns a channel that is closed when the user has been cut off
	// (e.g. quota exceeded, user removed by an operator). Tunnels are
	// expected to watch this channel after authentication and tear down the
	// underlying connection so that an in-flight relay does not keep
	// shovelling bytes after enforcement has fired (P0-3d).
	Done() <-chan struct{}
}

type Persistencer

type Persistencer interface {
	SaveUser(Metadata) error
	LoadUser(hash string) (Metadata, error)
	DeleteUser(hash string) error
	ListUser(func(hash string, u Metadata) bool) error
	UpdateUserTraffic(hash string, sent, recv uint64) error
}

type TrafficMeter

type TrafficMeter interface {
	io.Closer
	AddSentTraffic(sent int)
	AddRecvTraffic(recv int)
	ResetTraffic() (sent, recv uint64)
	GetSpeed() (sent, recv uint64)
}

type User

type User interface {
	Metadata
	TrafficMeter
	IPRecorder
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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