mirror of https://github.com/v2ray/v2ray-core
28 lines
709 B
Go
28 lines
709 B
Go
// +build json
|
|
|
|
package kcp
|
|
|
|
import (
|
|
"encoding/json"
|
|
)
|
|
|
|
func (this *Config) UnmarshalJSON(data []byte) error {
|
|
type JSONConfig struct {
|
|
Mode string `json:"Mode"`
|
|
Mtu int `json:"MaximumTransmissionUnit"`
|
|
Sndwnd int `json:"SendingWindowSize"`
|
|
Rcvwnd int `json:"ReceivingWindowSize"`
|
|
Fec int `json:"ForwardErrorCorrectionGroupSize"`
|
|
Acknodelay bool `json:"AcknowledgeNoDelay"`
|
|
Dscp int `json:"Dscp"`
|
|
ReadTimeout int `json:"ReadTimeout"`
|
|
WriteTimeout int `json:"WriteTimeout"`
|
|
}
|
|
jsonConfig := effectiveConfig
|
|
if err := json.Unmarshal(data, &jsonConfig); err != nil {
|
|
return err
|
|
}
|
|
*this = jsonConfig
|
|
return nil
|
|
}
|