mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-11-17 22:13:08 -08:00
more fields in switch account command
This commit is contained in:
1 parent
65d5c07533
commit
6eff759b05
9 files changed
+140
-25
No files matched your search
@@ -9,18 +9,49 @@ import (
|
||||
"github.com/v2ray/v2ray-core/proxy/vmess"
|
||||
)
|
||||
|
||||
func (this *DetourConfig) UnmarshalJSON(data []byte) error {
|
||||
type JsonDetourConfig struct {
|
||||
ToTag string `json:"to"`
|
||||
}
|
||||
jsonConfig := new(JsonDetourConfig)
|
||||
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
||||
return err
|
||||
}
|
||||
this.ToTag = jsonConfig.ToTag
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *FeaturesConfig) UnmarshalJSON(data []byte) error {
|
||||
type JsonFeaturesConfig struct {
|
||||
Detour *DetourConfig `json:"detour"`
|
||||
}
|
||||
jsonConfig := new(JsonFeaturesConfig)
|
||||
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
||||
return err
|
||||
}
|
||||
this.Detour = jsonConfig.Detour
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
type JsonConfig struct {
|
||||
Users []*vmess.User `json:"clients"`
|
||||
Features *FeaturesConfig `json:"features"`
|
||||
}
|
||||
jsonConfig := new(JsonConfig)
|
||||
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
||||
return err
|
||||
}
|
||||
this.AllowedUsers = jsonConfig.Users
|
||||
this.Features = jsonConfig.Features
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
config.RegisterInboundConnectionConfig("vmess",
|
||||
func(data []byte) (interface{}, error) {
|
||||
type JsonConfig struct {
|
||||
Users []*vmess.User `json:"clients"`
|
||||
}
|
||||
jsonConfig := new(JsonConfig)
|
||||
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Config{
|
||||
AllowedUsers: jsonConfig.Users,
|
||||
}, nil
|
||||
config := new(Config)
|
||||
err := json.Unmarshal(data, config)
|
||||
return config, err
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user