massive refactoring against json config parsing

This commit is contained in:
v2ray committed 2016-01-15 12:43:06 +01:00
1 parent f87ab4713c
commit e5fa96f814
51 files changed
+424 -586

No files matched your search

+19 -5
View File
@@ -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 {