2019-08-03 10:17:09 +00:00
|
|
|
package usermanager
|
2019-07-22 12:42:39 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
)
|
|
|
|
|
2019-08-03 10:17:09 +00:00
|
|
|
type StatusUpdate struct {
|
2019-07-22 12:42:39 +00:00
|
|
|
UID []byte
|
2019-08-03 10:17:09 +00:00
|
|
|
Active bool
|
|
|
|
NumSession int
|
2019-07-22 12:42:39 +00:00
|
|
|
|
2019-08-03 10:17:09 +00:00
|
|
|
UpUsage int64
|
|
|
|
DownUsage int64
|
|
|
|
Timestamp int64
|
2019-07-22 12:42:39 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
)
|
|
|
|
|
2019-07-22 12:42:39 +00:00
|
|
|
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
|
|
|
|
2019-07-22 12:42:39 +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)
|
2019-07-22 12:42:39 +00:00
|
|
|
}
|