1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-03 07:45:29 -05:00

allow dynamic type of user accounts

This commit is contained in:
v2ray
2016-05-28 13:44:11 +02:00
parent 87f664048b
commit 3f9cb1136a
18 changed files with 123 additions and 49 deletions

View File

@@ -1,9 +1,5 @@
package protocol
import (
"github.com/v2ray/v2ray-core/common/dice"
)
type UserLevel byte
const (
@@ -12,28 +8,19 @@ const (
)
type User struct {
ID *ID
AlterIDs []*ID
Level UserLevel
Email string
Account Account
Level UserLevel
Email string
}
func NewUser(primary *ID, secondary []*ID, level UserLevel, email string) *User {
func NewUser(account Account, level UserLevel, email string) *User {
return &User{
ID: primary,
AlterIDs: secondary,
Level: level,
Email: email,
Account: account,
Level: level,
Email: email,
}
}
func (this *User) AnyValidID() *ID {
if len(this.AlterIDs) == 0 {
return this.ID
}
return this.AlterIDs[dice.Roll(len(this.AlterIDs))]
}
type UserSettings struct {
PayloadReadTimeout int
}