handle switch account command in vmess out

This commit is contained in:
v2ray committed 2016-01-20 17:31:43 +01:00
1 parent b0adb24003
commit baaef1dad5
12 files changed
+251 -50

No files matched your search

+20 -2
View File
@@ -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