mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-14 08:15:55 -05:00
26 lines
591 B
Go
26 lines
591 B
Go
package mocks
|
|
|
|
import (
|
|
"github.com/v2ray/v2ray-core/proxy/vmess"
|
|
"github.com/v2ray/v2ray-core/proxy/vmess/protocol"
|
|
)
|
|
|
|
type MockUserSet struct {
|
|
Users []*vmess.User
|
|
UserHashes map[string]int
|
|
Timestamps map[string]protocol.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, protocol.Timestamp, bool) {
|
|
idx, found := us.UserHashes[string(userhash)]
|
|
if found {
|
|
return us.Users[idx], us.Timestamps[string(userhash)], true
|
|
}
|
|
return nil, 0, false
|
|
}
|