2015-09-14 13:03:31 -04:00
|
|
|
package mocks
|
|
|
|
|
|
|
|
import (
|
2015-09-19 18:11:14 -04:00
|
|
|
"github.com/v2ray/v2ray-core/proxy/vmess/protocol/user"
|
2015-09-14 13:03:31 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type MockUserSet struct {
|
2015-09-19 18:11:14 -04:00
|
|
|
UserIds []user.ID
|
2015-09-14 13:03:31 -04:00
|
|
|
UserHashes map[string]int
|
2015-09-16 15:13:13 -04:00
|
|
|
Timestamps map[string]int64
|
2015-09-14 13:03:31 -04:00
|
|
|
}
|
|
|
|
|
2015-09-19 18:11:14 -04:00
|
|
|
func (us *MockUserSet) AddUser(user user.User) error {
|
2015-09-14 13:03:31 -04:00
|
|
|
us.UserIds = append(us.UserIds, user.Id)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-09-19 18:11:14 -04:00
|
|
|
func (us *MockUserSet) GetUser(userhash []byte) (*user.ID, int64, bool) {
|
2015-09-14 13:03:31 -04:00
|
|
|
idx, found := us.UserHashes[string(userhash)]
|
|
|
|
if found {
|
2015-09-16 15:13:13 -04:00
|
|
|
return &us.UserIds[idx], us.Timestamps[string(userhash)], true
|
2015-09-14 13:03:31 -04:00
|
|
|
}
|
2015-09-14 19:32:55 -04:00
|
|
|
return nil, 0, false
|
2015-09-14 13:03:31 -04:00
|
|
|
}
|