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.
28 lines
600 B
28 lines
600 B
// +build json
|
|
|
|
package internet
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
v2net "github.com/v2ray/v2ray-core/common/net"
|
|
)
|
|
|
|
func (this *StreamSettings) UnmarshalJSON(data []byte) error {
|
|
type JSONConfig struct {
|
|
Network v2net.NetworkList `json:"network"`
|
|
}
|
|
this.Type = StreamConnectionTypeRawTCP
|
|
jsonConfig := new(JSONConfig)
|
|
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
|
return err
|
|
}
|
|
if jsonConfig.Network.HasNetwork(v2net.KCPNetwork) {
|
|
this.Type |= StreamConnectionTypeKCP
|
|
}
|
|
if jsonConfig.Network.HasNetwork(v2net.TCPNetwork) {
|
|
this.Type |= StreamConnectionTypeTCP
|
|
}
|
|
return nil
|
|
}
|