1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-19 02:16:11 -04:00
v2fly/proxy/vmess/outbound/config_json.go
2016-06-27 08:53:35 +02:00

33 lines
740 B
Go

// +build json
package outbound
import (
"encoding/json"
"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 {
return errors.New("VMessOut: Failed to parse config: " + err.Error())
}
if len(rawOutbound.Receivers) == 0 {
log.Error("VMessOut: 0 VMess receiver configured.")
return internal.ErrBadConfiguration
}
this.Receivers = rawOutbound.Receivers
return nil
}
func init() {
internal.RegisterOutboundConfig("vmess", func() interface{} { return new(Config) })
}