mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-02 17:27:50 -04:00
26 lines
549 B
Go
26 lines
549 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"`
|
||
|
}
|
||
|
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
|
||
|
return nil
|
||
|
}
|