mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
989 B
36 lines
989 B
// +build json
|
|
|
|
package outbound
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/v2ray/v2ray-core/common/log"
|
|
v2net "github.com/v2ray/v2ray-core/common/net"
|
|
proto "github.com/v2ray/v2ray-core/common/protocol"
|
|
"github.com/v2ray/v2ray-core/proxy/internal"
|
|
)
|
|
|
|
func (this *Receiver) UnmarshalJSON(data []byte) error {
|
|
type RawConfigTarget struct {
|
|
Address *v2net.AddressJson `json:"address"`
|
|
Port v2net.Port `json:"port"`
|
|
Users []*proto.User `json:"users"`
|
|
}
|
|
var rawConfig RawConfigTarget
|
|
if err := json.Unmarshal(data, &rawConfig); err != nil {
|
|
return err
|
|
}
|
|
if len(rawConfig.Users) == 0 {
|
|
log.Error("VMess: 0 user configured for VMess outbound.")
|
|
return internal.ErrorBadConfiguration
|
|
}
|
|
this.Accounts = rawConfig.Users
|
|
if rawConfig.Address == nil {
|
|
log.Error("VMess: Address is not set in VMess outbound config.")
|
|
return internal.ErrorBadConfiguration
|
|
}
|
|
this.Destination = v2net.TCPDestination(rawConfig.Address.Address, rawConfig.Port)
|
|
return nil
|
|
}
|