1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-26 03:57:42 -05:00
v2fly/testing/mocks/mockuserset.go

25 lines
518 B
Go
Raw Normal View History

2015-09-14 13:03:31 -04:00
package mocks
import (
2015-10-16 06:03:22 -04:00
"github.com/v2ray/v2ray-core/proxy/vmess/config"
2015-09-14 13:03:31 -04:00
)
type MockUserSet struct {
2015-10-30 19:38:31 -04:00
Users []config.User
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-10-16 06:03:22 -04:00
func (us *MockUserSet) AddUser(user config.User) error {
2015-10-30 19:38:31 -04:00
us.Users = append(us.Users, user)
2015-09-14 13:03:31 -04:00
return nil
}
2015-10-30 19:38:31 -04:00
func (us *MockUserSet) GetUser(userhash []byte) (config.User, int64, bool) {
2015-09-14 13:03:31 -04:00
idx, found := us.UserHashes[string(userhash)]
if found {
2015-10-30 19:38:31 -04:00
return us.Users[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
}