Cloak/internal/server/usermanager/usermanager.go

39 lines
769 B
Go
Raw Normal View History

2019-08-03 10:17:09 +00:00
package usermanager
import (
"errors"
)
2019-08-03 10:17:09 +00:00
type StatusUpdate struct {
UID []byte
2019-08-03 10:17:09 +00:00
Active bool
NumSession int
2019-08-03 10:17:09 +00:00
UpUsage int64
DownUsage int64
Timestamp int64
}
2019-08-03 10:17:09 +00:00
type StatusResponse struct {
2019-07-24 14:25:09 +00:00
UID []byte
2019-08-03 10:17:09 +00:00
Action int
Message string
2019-07-24 14:25:09 +00:00
}
const (
TERMINATE = iota + 1
)
var ErrUserNotFound = errors.New("UID does not correspond to a user")
var ErrSessionsCapReached = errors.New("Sessions cap has reached")
2019-07-24 14:25:09 +00:00
var ErrNoUpCredit = errors.New("No upload credit left")
var ErrNoDownCredit = errors.New("No download credit left")
var ErrUserExpired = errors.New("User has expired")
type UserManager interface {
2019-08-03 10:17:09 +00:00
AuthenticateUser([]byte) (int64, int64, error)
AuthoriseNewSession([]byte, int) error
UploadStatus([]StatusUpdate) ([]StatusResponse, error)
}