mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
665 B
44 lines
665 B
package vmess
|
|
|
|
import (
|
|
"math/rand"
|
|
)
|
|
|
|
type UserLevel int
|
|
|
|
const (
|
|
UserLevelAdmin = UserLevel(999)
|
|
UserLevelUntrusted = UserLevel(0)
|
|
)
|
|
|
|
type User struct {
|
|
ID *ID
|
|
AlterIDs []*ID
|
|
Level UserLevel
|
|
}
|
|
|
|
func (this *User) AnyValidID() *ID {
|
|
if len(this.AlterIDs) == 0 {
|
|
return this.ID
|
|
}
|
|
if len(this.AlterIDs) == 1 {
|
|
return this.AlterIDs[0]
|
|
}
|
|
idx := rand.Intn(len(this.AlterIDs))
|
|
return this.AlterIDs[idx]
|
|
}
|
|
|
|
type UserSettings struct {
|
|
PayloadReadTimeout int
|
|
}
|
|
|
|
func GetUserSettings(level UserLevel) UserSettings {
|
|
settings := UserSettings{
|
|
PayloadReadTimeout: 120,
|
|
}
|
|
if level > 0 {
|
|
settings.PayloadReadTimeout = 0
|
|
}
|
|
return settings
|
|
}
|