v2ray 9 роки тому
батько
коміт
f5d613f10a

+ 2 - 4
transport/config.go

@@ -8,7 +8,7 @@ import (
 // Config for V2Ray transport layer.
 type Config struct {
 	tcpConfig *tcp.Config
-	kcpConfig *kcp.Config
+	kcpConfig kcp.Config
 }
 
 // Apply applies this Config.
@@ -16,8 +16,6 @@ func (this *Config) Apply() error {
 	if this.tcpConfig != nil {
 		this.tcpConfig.Apply()
 	}
-	if this.kcpConfig != nil {
-		this.kcpConfig.Apply()
-	}
+	this.kcpConfig.Apply()
 	return nil
 }

+ 5 - 3
transport/config_json.go

@@ -12,14 +12,16 @@ import (
 func (this *Config) UnmarshalJSON(data []byte) error {
 	type JsonConfig struct {
 		TCPConfig *tcp.Config `json:"tcpSettings"`
-		KCPCOnfig *kcp.Config `json:"kcpSettings"`
+		KCPConfig kcp.Config  `json:"kcpSettings"`
+	}
+	jsonConfig := &JsonConfig{
+		KCPConfig: kcp.DefaultConfig(),
 	}
-	jsonConfig := new(JsonConfig)
 	if err := json.Unmarshal(data, jsonConfig); err != nil {
 		return err
 	}
 	this.tcpConfig = jsonConfig.TCPConfig
-	this.kcpConfig = jsonConfig.KCPCOnfig
+	this.kcpConfig = jsonConfig.KCPConfig
 
 	return nil
 }

+ 14 - 18
transport/internet/kcp/config.go

@@ -38,29 +38,25 @@ fast3,fast2,fast,normal
 ->>>>>> less bandwich wasted
 */
 type Config struct {
-	Mode         string
-	Mtu          int
-	Sndwnd       int
-	Rcvwnd       int
-	Acknodelay   bool
-	Dscp         int
-	ReadTimeout  int
-	WriteTimeout int
+	Mtu        int
+	Sndwnd     int
+	Rcvwnd     int
+	Acknodelay bool
 }
 
 func (this *Config) Apply() {
 	effectiveConfig = *this
 }
 
-var (
-	effectiveConfig = Config{
-		Mode:         "normal",
-		Mtu:          1350,
-		Sndwnd:       1024,
-		Rcvwnd:       1024,
-		Dscp:         0,
-		ReadTimeout:  600,
-		WriteTimeout: 500,
-		Acknodelay:   false,
+func DefaultConfig() Config {
+	return Config{
+		Mtu:        1350,
+		Sndwnd:     1024,
+		Rcvwnd:     1024,
+		Acknodelay: true,
 	}
+}
+
+var (
+	effectiveConfig = DefaultConfig()
 )

+ 1 - 31
transport/internet/kcp/config_json.go

@@ -8,45 +8,15 @@ import (
 
 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"`
-		Acknodelay   *bool   `json:"AcknowledgeNoDelay"`
-		Dscp         *int    `json:"Dscp"`
-		ReadTimeout  *int    `json:"ReadTimeout"`
-		WriteTimeout *int    `json:"WriteTimeout"`
+		Mtu *int `json:"mtu"`
 	}
 	jsonConfig := new(JSONConfig)
 	if err := json.Unmarshal(data, &jsonConfig); err != nil {
 		return err
 	}
-	if jsonConfig.Mode != nil {
-		this.Mode = *jsonConfig.Mode
-	}
-
 	if jsonConfig.Mtu != nil {
 		this.Mtu = *jsonConfig.Mtu
 	}
 
-	if jsonConfig.Sndwnd != nil {
-		this.Sndwnd = *jsonConfig.Sndwnd
-	}
-	if jsonConfig.Rcvwnd != nil {
-		this.Rcvwnd = *jsonConfig.Rcvwnd
-	}
-	if jsonConfig.Acknodelay != nil {
-		this.Acknodelay = *jsonConfig.Acknodelay
-	}
-	if jsonConfig.Dscp != nil {
-		this.Dscp = *jsonConfig.Dscp
-	}
-	if jsonConfig.ReadTimeout != nil {
-		this.ReadTimeout = *jsonConfig.ReadTimeout
-	}
-	if jsonConfig.WriteTimeout != nil {
-		this.WriteTimeout = *jsonConfig.WriteTimeout
-	}
-
 	return nil
 }