memory

package
v0.0.0-...-5f46ec8 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const Name = "MEMORY"

Variables

This section is empty.

Functions

func NewAuthenticator

func NewAuthenticator(ctx context.Context) (statistic.Authenticator, error)

Types

type Authenticator

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

func (*Authenticator) AddUser

func (a *Authenticator) AddUser(hash string) error

func (*Authenticator) AuthUser

func (a *Authenticator) AuthUser(hash string) (bool, statistic.User)

func (*Authenticator) Close

func (a *Authenticator) Close() error

func (*Authenticator) DelUser

func (a *Authenticator) DelUser(hash string) error

func (*Authenticator) ListUsers

func (a *Authenticator) ListUsers() []statistic.User

func (*Authenticator) SetKeyShare

func (a *Authenticator) SetKeyShare(hash string, pwd string) error

func (*Authenticator) SetUserIPLimit

func (a *Authenticator) SetUserIPLimit(hash string, limit int) error

func (*Authenticator) SetUserSpeedLimit

func (a *Authenticator) SetUserSpeedLimit(hash string, send, recv int) error

func (*Authenticator) SetUserTraffic

func (a *Authenticator) SetUserTraffic(hash string, sent, recv uint64) error

type Config

type Config struct {
	Passwords    []string `json:"password" yaml:"password"`
	Sqlite       string   `json:"sqlite" yaml:"sqlite"`
	MaxIPPerUser int      `json:"MaxIPPerUser" yaml:"MaxIPPerUser"`
}

type User

type User struct {
	// WARNING: do not change the order of these fields.
	// 64-bit fields that use `sync/atomic` package functions
	// must be 64-bit aligned on 32-bit systems.
	// Reference: https://github.com/golang/go/issues/599
	// Solution: https://github.com/golang/go/issues/11891#issuecomment-433623786
	Sent uint64
	Recv uint64

	Hash string

	MaxIPNum int

	SendLimiter *rate.Limiter
	RecvLimiter *rate.Limiter
	// contains filtered or unexported fields
}

func (*User) AddIP

func (u *User) AddIP(ip string) bool

func (*User) AddRecvTraffic

func (u *User) AddRecvTraffic(recv int)

func (*User) AddSentTraffic

func (u *User) AddSentTraffic(sent int)

func (*User) Close

func (u *User) Close() error

func (*User) DelIP

func (u *User) DelIP(ip string) bool

func (*User) GetHash

func (u *User) GetHash() string

func (*User) GetIP

func (u *User) GetIP() int

func (*User) GetIPLimit

func (u *User) GetIPLimit() int

func (*User) GetKeyShare

func (u *User) GetKeyShare() string

func (*User) GetSpeed

func (u *User) GetSpeed() (uint64, uint64)

func (*User) GetSpeedLimit

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

func (*User) GetTraffic

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

func (*User) ResetTraffic

func (u *User) ResetTraffic() (uint64, uint64)

func (*User) SetSpeedLimit

func (u *User) SetSpeedLimit(send, recv int)

Jump to

Keyboard shortcuts

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