mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-12-27 20:45:28 -05:00
massive refactoring against json config parsing
This commit is contained in:
26
proxy/vmess/inbound/config_json.go
Normal file
26
proxy/vmess/inbound/config_json.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// +build json
|
||||
|
||||
package inbound
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/v2ray/v2ray-core/proxy/internal/config"
|
||||
"github.com/v2ray/v2ray-core/proxy/vmess"
|
||||
)
|
||||
|
||||
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
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user