re-org vmess content

This commit is contained in:
Darien Raymond committed 2015-12-07 19:32:38 +00:00
1 parent 0a4d9fb037
commit af8412175e
24 files changed
+113 -108

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
package json
import (
"encoding/json"
"github.com/v2ray/v2ray-core/proxy/vmess"
)
// ConfigUser is an user account in VMess configuration.
type ConfigUser struct {
Id *vmess.ID
Email string
LevelValue vmess.UserLevel
}
func (u *ConfigUser) UnmarshalJSON(data []byte) error {
type rawUser struct {
IdString string `json:"id"`
EmailString string `json:"email"`
LevelInt int `json:"level"`
}
var rawUserValue rawUser
if err := json.Unmarshal(data, &rawUserValue); err != nil {
return err
}
id, err := vmess.NewID(rawUserValue.IdString)
if err != nil {
return err
}
u.Id = id
u.Email = rawUserValue.EmailString
u.LevelValue = vmess.UserLevel(rawUserValue.LevelInt)
return nil
}
func (u *ConfigUser) ID() *vmess.ID {
return u.Id
}
func (this *ConfigUser) Level() vmess.UserLevel {
return this.LevelValue
}