mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-03 00:22:05 +00:00
re-org vmess content
This commit is contained in:
1 parent
0a4d9fb037
commit
af8412175e
24 files changed
+113
-108
No files matched your search
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user