From b17edf907e74ca2e5c1c5abbe77be13a47b3305c Mon Sep 17 00:00:00 2001 From: v2ray Date: Sat, 11 Jun 2016 02:05:29 +0200 Subject: [PATCH 1/2] enable connection reuse by default --- transport/config_json.go | 4 +++- transport/transport.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/transport/config_json.go b/transport/config_json.go index fb724bfc3..95fd56e02 100644 --- a/transport/config_json.go +++ b/transport/config_json.go @@ -8,7 +8,9 @@ func (this *Config) UnmarshalJSON(data []byte) error { type JsonConfig struct { ConnectionReuse bool `json:"connectionReuse"` } - jsonConfig := new(JsonConfig) + jsonConfig := &JsonConfig{ + ConnectionReuse: true, + } if err := json.Unmarshal(data, jsonConfig); err != nil { return err } diff --git a/transport/transport.go b/transport/transport.go index c6bd97bf2..ce88dd163 100644 --- a/transport/transport.go +++ b/transport/transport.go @@ -1,7 +1,7 @@ package transport var ( - connectionReuse = false + connectionReuse = true ) func IsConnectionReusable() bool { From ffce784dcec5e2ffee444855e09430770f456d48 Mon Sep 17 00:00:00 2001 From: v2ray Date: Sat, 11 Jun 2016 13:29:33 +0200 Subject: [PATCH 2/2] comments --- transport/config.go | 2 ++ transport/transport.go | 1 + 2 files changed, 3 insertions(+) diff --git a/transport/config.go b/transport/config.go index 967b0b1b7..f96021af8 100644 --- a/transport/config.go +++ b/transport/config.go @@ -1,9 +1,11 @@ package transport +// Config for V2Ray transport layer. type Config struct { ConnectionReuse bool } +// Apply applies this Config. func (this *Config) Apply() error { if this.ConnectionReuse { connectionReuse = true diff --git a/transport/transport.go b/transport/transport.go index ce88dd163..9d5cfc8f2 100644 --- a/transport/transport.go +++ b/transport/transport.go @@ -4,6 +4,7 @@ var ( connectionReuse = true ) +// IsConnectionReusable returns true if V2Ray is trying to reuse TCP connections. func IsConnectionReusable() bool { return connectionReuse }