2016-06-02 01:49:25 +02:00
|
|
|
// +build json
|
|
|
|
|
|
|
|
package transport
|
|
|
|
|
2016-06-11 19:51:02 +08:00
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
|
2016-06-14 22:54:08 +02:00
|
|
|
"github.com/v2ray/v2ray-core/transport/internet/kcp"
|
|
|
|
"github.com/v2ray/v2ray-core/transport/internet/tcp"
|
2016-06-11 19:51:02 +08:00
|
|
|
)
|
2016-06-02 01:49:25 +02:00
|
|
|
|
|
|
|
func (this *Config) UnmarshalJSON(data []byte) error {
|
2016-06-02 20:52:52 +02:00
|
|
|
type JsonConfig struct {
|
2016-06-14 22:54:08 +02:00
|
|
|
TCPConfig *tcp.Config `json:"tcpSettings"`
|
2016-06-17 16:57:48 +02:00
|
|
|
KCPConfig kcp.Config `json:"kcpSettings"`
|
|
|
|
}
|
|
|
|
jsonConfig := &JsonConfig{
|
|
|
|
KCPConfig: kcp.DefaultConfig(),
|
2016-06-11 02:05:29 +02:00
|
|
|
}
|
2016-06-02 20:52:52 +02:00
|
|
|
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
2016-06-02 01:49:25 +02:00
|
|
|
return err
|
|
|
|
}
|
2016-06-14 22:54:08 +02:00
|
|
|
this.tcpConfig = jsonConfig.TCPConfig
|
2016-06-17 16:57:48 +02:00
|
|
|
this.kcpConfig = jsonConfig.KCPConfig
|
2016-06-12 14:10:19 +08:00
|
|
|
|
2016-06-02 01:49:25 +02:00
|
|
|
return nil
|
|
|
|
}
|