mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-18 23:00:12 +00:00
handle switch account command in vmess out
This commit is contained in:
1 parent
b0adb24003
commit
baaef1dad5
12 files changed
+251
-50
No files matched your search
+20
-2
@@ -4,10 +4,10 @@ import (
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
type UserLevel int
|
||||
type UserLevel byte
|
||||
|
||||
const (
|
||||
UserLevelAdmin = UserLevel(999)
|
||||
UserLevelAdmin = UserLevel(255)
|
||||
UserLevelUntrusted = UserLevel(0)
|
||||
)
|
||||
|
||||
@@ -17,6 +17,24 @@ type User struct {
|
||||
Level UserLevel
|
||||
}
|
||||
|
||||
func NewUser(id *ID, level UserLevel, alterIdCount uint16) *User {
|
||||
u := &User{
|
||||
ID: id,
|
||||
Level: level,
|
||||
}
|
||||
if alterIdCount > 0 {
|
||||
u.AlterIDs = make([]*ID, alterIdCount)
|
||||
prevId := id.UUID()
|
||||
for idx, _ := range u.AlterIDs {
|
||||
newid := prevId.Next()
|
||||
// TODO: check duplicate
|
||||
u.AlterIDs[idx] = NewID(newid)
|
||||
prevId = newid
|
||||
}
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
func (this *User) AnyValidID() *ID {
|
||||
if len(this.AlterIDs) == 0 {
|
||||
return this.ID
|
||||
|
||||
Reference in new issue
Block a user