mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-18 23:00:12 +00:00
massive refactoring against json config parsing
This commit is contained in:
1 parent
f87ab4713c
commit
e5fa96f814
51 files changed
+424
-586
No files matched your search
+19
-5
@@ -1,5 +1,9 @@
|
||||
package vmess
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
type UserLevel int
|
||||
|
||||
const (
|
||||
@@ -7,11 +11,21 @@ const (
|
||||
UserLevelUntrusted = UserLevel(0)
|
||||
)
|
||||
|
||||
type User interface {
|
||||
ID() *ID
|
||||
AlterIDs() []*ID
|
||||
Level() UserLevel
|
||||
AnyValidID() *ID
|
||||
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 {
|
||||
|
||||
Reference in new issue
Block a user