Documentation
¶
Overview ¶
Package users implements the server-side user whitelist: identification by handshake user hash, payload bandwidth limiting and wire traffic quota.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry resolves handshake user hashes to users. A nil Registry means "no whitelist".
func NewRegistry ¶
func NewRegistry(cfgs []config.UserConfig) (*Registry, error)
func (*Registry) Lookup ¶
Lookup returns the user for a hex handshake hash, or nil when it is not whitelisted.
func (*Registry) TrackUsage ¶
TrackUsage restores this month's usage from path, saves it every minute and once more on stop, and resets every user when a new month begins. An empty path keeps usage in memory.
type Stat ¶
type Stat struct {
Name string
Blocked bool
Exceeded bool
Conns int // open connections
Up, Down uint64 // wire bytes from and to the client since start
Used uint64 // wire bytes this month, counted against Limit
Limit uint64 // bytes, 0 = unlimited
}
Stat is a point-in-time view of one user, for monitoring.
type User ¶
func (*User) WrapPayload ¶
WrapPayload throttles decoded payload to the user's bandwidth limits. It returns conn unchanged when the user has no limit.
type WireConn ¶
WireConn counts wire bytes. Bytes seen before Bind (the handshake) are charged on Bind.