1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-10-17 16:33:40 -04:00
v2fly/proxy/vmess/protocol/user/testing/mocks/mockuserset.go
2016-01-12 11:38:43 +01:00

26 lines
585 B
Go

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