mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-11-17 22:13:08 -08:00
auto user creation for dynamic port
This commit is contained in:
1 parent
b3f547dc90
commit
9f50692d15
9 files changed
+90
-21
No files matched your search
@@ -33,10 +33,28 @@ func (this *FeaturesConfig) UnmarshalJSON(data []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *DefaultConfig) UnmarshalJSON(data []byte) error {
|
||||
type JsonDefaultConfig struct {
|
||||
AlterIDs uint16 `json:"alterId"`
|
||||
Level byte `json:"level"`
|
||||
}
|
||||
jsonConfig := new(JsonDefaultConfig)
|
||||
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
||||
return err
|
||||
}
|
||||
this.AlterIDs = jsonConfig.AlterIDs
|
||||
if this.AlterIDs == 0 {
|
||||
this.AlterIDs = 32
|
||||
}
|
||||
this.Level = proto.UserLevel(jsonConfig.Level)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
type JsonConfig struct {
|
||||
Users []*proto.User `json:"clients"`
|
||||
Features *FeaturesConfig `json:"features"`
|
||||
Defaults *DefaultConfig `json:"default"`
|
||||
}
|
||||
jsonConfig := new(JsonConfig)
|
||||
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
||||
@@ -44,6 +62,13 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
this.AllowedUsers = jsonConfig.Users
|
||||
this.Features = jsonConfig.Features
|
||||
this.Defaults = jsonConfig.Defaults
|
||||
if this.Defaults == nil {
|
||||
this.Defaults = &DefaultConfig{
|
||||
Level: proto.UserLevel(0),
|
||||
AlterIDs: 32,
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user