v2ray-core/transport/config_json.go

20 lines
386 B
Go
Raw Normal View History

2016-06-02 01:49:25 +02:00
// +build json
package transport
2016-06-02 20:52:52 +02:00
import "encoding/json"
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-02 01:49:25 +02:00
ConnectionReuse bool `json:"connectionReuse"`
}
2016-06-11 02:05:29 +02:00
jsonConfig := &JsonConfig{
ConnectionReuse: true,
}
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-02 20:52:52 +02:00
this.ConnectionReuse = jsonConfig.ConnectionReuse
2016-06-02 01:49:25 +02:00
return nil
}