1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-07-21 12:44:17 -04:00
v2fly/transport/internet/ws/config_json.go
2016-08-13 22:07:47 +08:00

30 lines
694 B
Go

package ws
import (
"encoding/json"
)
func (this *Config) UnmarshalJSON(data []byte) error {
type JsonConfig struct {
ConnectionReuse bool `json:"connectionReuse"`
Path string `json:"Path"`
Pto string `json:"Pto"`
Cert string `json:"Cert"`
PrivKey string `json:"PrivKey"`
}
jsonConfig := &JsonConfig{
ConnectionReuse: true,
Path: "",
Pto: "",
}
if err := json.Unmarshal(data, jsonConfig); err != nil {
return err
}
this.ConnectionReuse = jsonConfig.ConnectionReuse
this.Path = jsonConfig.Path
this.Pto = jsonConfig.Pto
this.PrivKey = jsonConfig.PrivKey
this.Cert = jsonConfig.Cert
return nil
}