2016-01-15 06:43:06 -05:00
|
|
|
// +build json
|
|
|
|
|
|
|
|
package outbound
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
2016-06-11 16:52:37 -04:00
|
|
|
"errors"
|
2016-01-15 06:43:06 -05:00
|
|
|
|
|
|
|
"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())
|
2016-01-15 06:43:06 -05:00
|
|
|
}
|
|
|
|
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
|
2016-01-15 06:43:06 -05:00
|
|
|
}
|
|
|
|
this.Receivers = rawOutbound.Receivers
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2016-06-10 16:26:39 -04:00
|
|
|
internal.RegisterOutboundConfig("vmess", func() interface{} { return new(Config) })
|
2016-01-15 06:43:06 -05:00
|
|
|
}
|