1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-03 07:56:42 -05:00
v2fly/proxy/vmess/outbound/config_json.go

33 lines
740 B
Go
Raw Normal View History

// +build json
package outbound
import (
"encoding/json"
2016-06-11 16:52:37 -04:00
"errors"
"github.com/v2ray/v2ray-core/common/log"
"github.com/v2ray/v2ray-core/proxy/internal"
)
func (this *Config) UnmarshalJSON(data []byte) error {
type RawOutbound struct {
Receivers []*Receiver `json:"vnext"`
}
rawOutbound := &RawOutbound{}
err := json.Unmarshal(data, rawOutbound)
if err != nil {
2016-06-11 16:52:37 -04:00
return errors.New("VMessOut: Failed to parse config: " + err.Error())
}
if len(rawOutbound.Receivers) == 0 {
2016-06-11 16:52:37 -04:00
log.Error("VMessOut: 0 VMess receiver configured.")
2016-06-27 02:53:35 -04:00
return internal.ErrBadConfiguration
}
this.Receivers = rawOutbound.Receivers
return nil
}
func init() {
2016-06-10 16:26:39 -04:00
internal.RegisterOutboundConfig("vmess", func() interface{} { return new(Config) })
}