1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-04 17:26:33 -05:00
v2fly/testing/mocks/mockuserset.go
2015-10-16 10:03:22 +00:00

25 lines
529 B
Go

package mocks
import (
"github.com/v2ray/v2ray-core/proxy/vmess/config"
)
type MockUserSet struct {
UserIds []*config.ID
UserHashes map[string]int
Timestamps map[string]int64
}
func (us *MockUserSet) AddUser(user config.User) error {
us.UserIds = append(us.UserIds, user.ID())
return nil
}
func (us *MockUserSet) GetUser(userhash []byte) (*config.ID, int64, bool) {
idx, found := us.UserHashes[string(userhash)]
if found {
return us.UserIds[idx], us.Timestamps[string(userhash)], true
}
return nil, 0, false
}