model

package
v0.0.0-...-46a5f05 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: BSD-2-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoRows         = errors.New("no such record")
	ErrCreateSession  = errors.New("session.add fail")
	ErrUpdateSession  = errors.New("session.update fail")
	ErrFinishSession  = errors.New("session.finish fail")
	ErrArchiveSession = errors.New("session.archive fail")
)

Functions

func Conns

func Conns(storage Storage, user string) (uint32, error)

func SessionAdd

func SessionAdd(storage Storage, sessionId, user, nasIp, assignedIp, clientIp string) error

func SessionLog

func SessionLog(storage Storage, sessionId string, user string, nasIp string) error

Copy session to log

func SessionRemove

func SessionRemove(storage Storage, sessionId, user, nasIp string) error

func SessionUpdate

func SessionUpdate(storage Storage, s Session) error

Types

type Session

type Session struct {
	BytesIn     uint32
	BytesOut    uint32
	PacketsIn   uint32
	PacketsOut  uint32
	SessionID   string
	SessionTime uint32
	User        string
	NasIP       string
}

type Storage

type Storage interface {
	GetUser(name string) (user User, err error)
	CountSessions(name string) (count int, err error)
	GetLimits(name string) (user UserLimits, err error)
	IsSessionExists(name string, sessID string, nasIP string) (exists bool, err error)
	CreateSession(name string, sessID string, nasIP string, assignedIP string, clientIP string) error
	UpdateSession(name string, sessID string, nasIP string, rx int, tx int, rxPackets int, txPackets int, duration int) error
	FinishSession(name string, sessID string, nasIP string) error
	ArchiveSession(name string, sessID string, nasIP string) error
}

type User

type User struct {
	Pass            string
	ActiveUntil     *string // Account active until YYYY-MM-DD
	BlockRemain     *int64  // Remaining bandwidth
	SimultaneousUse uint32  // Max conns allowed
	DedicatedIP     *string
	Ratelimit       *string
	DnsOne          *string
	DnsTwo          *string
	Ok              bool
}

func Auth

func Auth(storage Storage, user string) (User, error)

type UserLimits

type UserLimits struct {
	Exists bool
}

func Limits

func Limits(storage Storage, user string) (UserLimits, error)

Jump to

Keyboard shortcuts

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