mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-10 12:16:24 -05:00
e445d21f4b
* Add trojan protocol support Co-authored-by: Eken Chan <ekenchan@msn.com> Co-authored-by: Loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com> Co-authored-by: GitHub Action <action@github.com>
29 lines
530 B
Go
29 lines
530 B
Go
package trojan
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"v2ray.com/core/common/protocol"
|
|
)
|
|
|
|
// Validator stores valid trojan users
|
|
type Validator struct {
|
|
users sync.Map
|
|
}
|
|
|
|
// Add a trojan user
|
|
func (v *Validator) Add(u *protocol.MemoryUser) error {
|
|
user := u.Account.(*MemoryAccount)
|
|
v.users.Store(hexString(user.Key), u)
|
|
return nil
|
|
}
|
|
|
|
// Get user with hashed key, nil if user doesn't exist.
|
|
func (v *Validator) Get(hash string) *protocol.MemoryUser {
|
|
u, _ := v.users.Load(hash)
|
|
if u != nil {
|
|
return u.(*protocol.MemoryUser)
|
|
}
|
|
return nil
|
|
}
|