1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-19 10:56:06 -05:00
v2fly/transport/config_json.go
2016-08-13 21:39:34 +08:00

30 lines
712 B
Go

// +build json
package transport
import (
"encoding/json"
"github.com/v2ray/v2ray-core/transport/internet/kcp"
"github.com/v2ray/v2ray-core/transport/internet/tcp"
"github.com/v2ray/v2ray-core/transport/internet/ws"
)
func (this *Config) UnmarshalJSON(data []byte) error {
type JsonConfig struct {
TCPConfig *tcp.Config `json:"tcpSettings"`
KCPConfig kcp.Config `json:"kcpSettings"`
WSConfig *ws.Config `json:"wsSettings"`
}
jsonConfig := &JsonConfig{
KCPConfig: kcp.DefaultConfig(),
}
if err := json.Unmarshal(data, jsonConfig); err != nil {
return err
}
this.tcpConfig = jsonConfig.TCPConfig
this.kcpConfig = jsonConfig.KCPConfig
this.wsConfig = jsonConfig.WSConfig
return nil
}