Browse Source

Enable tls1.3 if not explicitly disabled

Shelikhoo 6 years ago
parent
commit
fa976b8a1b
2 changed files with 16 additions and 7 deletions
  1. 0 7
      transport/internet/tls/tls.go
  2. 16 0
      transport/internet/tls/tls13_workaround.go

+ 0 - 7
transport/internet/tls/tls.go

@@ -4,7 +4,6 @@ package tls
 
 import (
 	"crypto/tls"
-	"os"
 
 	"v2ray.com/core/common/buf"
 	"v2ray.com/core/common/net"
@@ -66,9 +65,3 @@ func Server(c net.Conn, config *tls.Config) net.Conn {
 	tlsConn := tls.Server(c, config)
 	return &conn{Conn: tlsConn}
 }
-
-func init() {
-	// opt-in TLS 1.3 for Go1.12
-	// TODO: remove this line when Go1.13 is released.
-	_ = os.Setenv("GODEBUG", os.Getenv("GODEBUG")+",tls13=1")
-}

+ 16 - 0
transport/internet/tls/tls13_workaround.go

@@ -0,0 +1,16 @@
+// +build !confonly
+
+package tls
+
+import (
+	"os"
+	"strings"
+)
+
+func init() {
+	// opt-in TLS 1.3 for Go1.12
+	// TODO: remove this line when Go1.13 is released.
+	if !strings.Contains(os.Getenv("GODEBUG"), "tls13") {
+		_ = os.Setenv("GODEBUG", os.Getenv("GODEBUG")+",tls13=1")
+	}
+}