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