usermanager

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

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

Go to latest
Published: Sep 8, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TERMINATE = iota + 1
)

Variables

View Source
var ErrMangerIsVoid = errors.New("cannot perform operation with user manager as database path is not specified")
View Source
var ErrNoDownCredit = errors.New("No download credit left")
View Source
var ErrNoUpCredit = errors.New("No upload credit left")
View Source
var ErrSessionsCapReached = errors.New("Sessions cap has reached")
View Source
var ErrUserExpired = errors.New("User has expired")
View Source
var ErrUserNotFound = errors.New("UID does not correspond to a user")

Functions

func MakeLocalManager

func MakeLocalManager(dbPath string, worldState common.WorldState) (*localManager, error)

Types

type APIRouter

type APIRouter struct {
	*gmux.Router
	// contains filtered or unexported fields
}

func APIRouterOf

func APIRouterOf(manager UserManager) *APIRouter

type AuthorisationInfo

type AuthorisationInfo struct {
	NumExistingSessions int
}

type MaybeInt32

type MaybeInt32 *int32

func JustInt32

func JustInt32(v int32) MaybeInt32

type MaybeInt64

type MaybeInt64 *int64

func JustInt64

func JustInt64(v int64) MaybeInt64

type StatusResponse

type StatusResponse struct {
	UID     []byte
	Action  int
	Message string
}

type StatusUpdate

type StatusUpdate struct {
	UID        []byte
	Active     bool
	NumSession int

	UpUsage   int64
	DownUsage int64
	Timestamp int64
}

type UserInfo

type UserInfo struct {
	UID         []byte
	SessionsCap MaybeInt32
	UpRate      MaybeInt64
	DownRate    MaybeInt64
	UpCredit    MaybeInt64
	DownCredit  MaybeInt64
	ExpiryTime  MaybeInt64
}

type UserManager

type UserManager interface {
	AuthenticateUser([]byte) (int64, int64, error)
	AuthoriseNewSession([]byte, AuthorisationInfo) error
	UploadStatus([]StatusUpdate) ([]StatusResponse, error)
	ListAllUsers() ([]UserInfo, error)
	GetUserInfo(UID []byte) (UserInfo, error)
	WriteUserInfo(UserInfo) error
	DeleteUser(UID []byte) error
}

type Voidmanager

type Voidmanager struct{}

func (*Voidmanager) AuthenticateUser

func (v *Voidmanager) AuthenticateUser(bytes []byte) (int64, int64, error)

func (*Voidmanager) AuthoriseNewSession

func (v *Voidmanager) AuthoriseNewSession(bytes []byte, info AuthorisationInfo) error

func (*Voidmanager) DeleteUser

func (v *Voidmanager) DeleteUser(UID []byte) error

func (*Voidmanager) GetUserInfo

func (v *Voidmanager) GetUserInfo(UID []byte) (UserInfo, error)

func (*Voidmanager) ListAllUsers

func (v *Voidmanager) ListAllUsers() ([]UserInfo, error)

func (*Voidmanager) UploadStatus

func (v *Voidmanager) UploadStatus(updates []StatusUpdate) ([]StatusResponse, error)

func (*Voidmanager) WriteUserInfo

func (v *Voidmanager) WriteUserInfo(info UserInfo) error

Jump to

Keyboard shortcuts

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