sqlite

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: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Name = "sqlite"

Variables

This section is empty.

Functions

This section is empty.

Types

type Persistencer

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

func NewSqlitePersistencer

func NewSqlitePersistencer(path string) (*Persistencer, error)

func (*Persistencer) Close added in v1.2.0

func (p *Persistencer) Close() error

Close releases the underlying database handle. It is safe to call after Authenticator.Close.

func (*Persistencer) DeleteUser

func (p *Persistencer) DeleteUser(hash string) error

func (*Persistencer) ListUser

func (p *Persistencer) ListUser(f func(hash string, u statistic.Metadata) bool) error

func (*Persistencer) LoadUser

func (p *Persistencer) LoadUser(hash string) (statistic.Metadata, error)

func (*Persistencer) SaveUser

func (p *Persistencer) SaveUser(u statistic.Metadata) error

func (*Persistencer) UpdateUserTraffic

func (p *Persistencer) UpdateUserTraffic(hash string, sent, recv uint64) error

type User

type User struct {
	Hash string `gorm:"primary_key"`
	// uint64 = 8 byte binary
	Sent      []byte `gorm:"type:TEXT"`
	Recv      []byte `gorm:"type:TEXT"`
	MaxIPNum  int
	SendLimit int
	RecvLimit int
	Quota     int64
}

func (*User) Done added in v1.2.0

func (u *User) Done() <-chan struct{}

Done satisfies statistic.Metadata. The SQLite user record is a passive snapshot used only for persistence (SaveUser/LoadUser/ListUser); it has no live runtime to cancel, so the channel is never closed. The returned nil channel blocks forever in a select, which is the documented "no cutoff signal" behaviour.

func (*User) GetHash

func (u *User) GetHash() string

func (*User) GetIPLimit

func (u *User) GetIPLimit() int

func (*User) GetQuota added in v1.1.1

func (u *User) GetQuota() int64

func (*User) GetSpeedLimit

func (u *User) GetSpeedLimit() (sent, recv int)

func (*User) GetTraffic

func (u *User) GetTraffic() (sent, recv uint64)

Jump to

Keyboard shortcuts

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