Documentation
¶
Index ¶
- Constants
- func NewAuthenticator(ctx context.Context) (statistic.Authenticator, error)
- type Authenticator
- func (a *Authenticator) AddUser(hash string) error
- func (a *Authenticator) AuthUser(hash string) (bool, statistic.User)
- func (a *Authenticator) Close() error
- func (a *Authenticator) DelUser(hash string) error
- func (a *Authenticator) ListUsers() []statistic.User
- func (a *Authenticator) SetUserIPLimit(hash string, limit int) error
- func (a *Authenticator) SetUserQuota(hash string, quota int64) error
- func (a *Authenticator) SetUserSpeedLimit(hash string, send, recv int) error
- func (a *Authenticator) SetUserTraffic(hash string, sent, recv uint64) error
- type Config
- type User
- func (u *User) AddIP(ip string) bool
- func (u *User) AddRecvTraffic(recv int)
- func (u *User) AddSentTraffic(sent int)
- func (u *User) Close() error
- func (u *User) DelIP(ip string) bool
- func (u *User) Done() <-chan struct{}
- func (u *User) GetHash() string
- func (u *User) GetIP() int
- func (u *User) GetIPLimit() int
- func (u *User) GetQuota() int64
- func (u *User) GetSpeed() (uint64, uint64)
- func (u *User) GetSpeedLimit() (send, recv int)
- func (u *User) GetTraffic() (uint64, uint64)
- func (u *User) ResetTraffic() (uint64, uint64)
- func (u *User) SetQuota(quota int64)
- func (u *User) SetSpeedLimit(send, recv int)
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) SetUserIPLimit ¶
func (a *Authenticator) SetUserIPLimit(hash string, limit int) error
func (*Authenticator) SetUserQuota ¶ added in v1.1.1
func (a *Authenticator) SetUserQuota(hash string, quota int64) 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 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
MaxConnNum int
SendLimiter *rate.Limiter
RecvLimiter *rate.Limiter
// contains filtered or unexported fields
}
func (*User) AddRecvTraffic ¶
func (*User) AddSentTraffic ¶
func (*User) Done ¶ added in v1.2.0
func (u *User) Done() <-chan struct{}
Done satisfies statistic.Metadata. Returns a channel that is closed when the user is cut off — either because their quota was exceeded or because they were removed by the operator (DelUser / Close). Authenticator shutdown does NOT fire this channel; tunnel teardown during shutdown is handled by the normal connection-close path. Callers (typically a tunnel.Conn wrapper) can react to cutoff by closing the underlying transport so in-flight reads observe a closed-conn error.
func (*User) GetIPLimit ¶
func (*User) GetSpeedLimit ¶
func (*User) GetTraffic ¶
func (*User) ResetTraffic ¶
func (*User) SetSpeedLimit ¶
Click to show internal directories.
Click to hide internal directories.