From e40eefae101ce1495287ef99e358e408d5d5b509 Mon Sep 17 00:00:00 2001 From: Gzxhwq Date: Sat, 4 Feb 2023 14:57:07 +0800 Subject: [PATCH] xray: add patch for go 1.18+ Cherry-pick from https://github.com/yichya/openwrt-xray/commit/ae279a179110f09bc5dadf21eabcc15bb453dfe1 --- .../010-compatible-with-go-1.18+.patch | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 xray-core/patches/010-compatible-with-go-1.18+.patch diff --git a/xray-core/patches/010-compatible-with-go-1.18+.patch b/xray-core/patches/010-compatible-with-go-1.18+.patch new file mode 100644 index 000000000..6479717cb --- /dev/null +++ b/xray-core/patches/010-compatible-with-go-1.18+.patch @@ -0,0 +1,87 @@ +diff --git a/common/protocol/quic/qtls_go118.go b/common/protocol/quic/qtls_go118.go +index e701adf..429037d 100644 +--- a/common/protocol/quic/qtls_go118.go ++++ b/common/protocol/quic/qtls_go118.go +@@ -1,9 +1,11 @@ ++//go:build go1.18 && !go1.19 ++ + package quic + + import ( + "crypto/cipher" + +- "github.com/quic-go/qtls-go1-20" ++ "github.com/quic-go/qtls-go1-18" + ) + + type ( +diff --git a/common/protocol/quic/qtls_go119.go b/common/protocol/quic/qtls_go119.go +new file mode 100644 +index 0000000..4ab25af +--- /dev/null ++++ b/common/protocol/quic/qtls_go119.go +@@ -0,0 +1,18 @@ ++//go:build go1.19 && !go1.20 ++ ++package quic ++ ++import ( ++ "crypto/cipher" ++ ++ "github.com/quic-go/qtls-go1-19" ++) ++ ++type ( ++ // A CipherSuiteTLS13 is a cipher suite for TLS 1.3 ++ CipherSuiteTLS13 = qtls.CipherSuiteTLS13 ++) ++ ++func AEADAESGCMTLS13(key, fixedNonce []byte) cipher.AEAD { ++ return qtls.AEADAESGCMTLS13(key, fixedNonce) ++} +diff --git a/common/protocol/quic/qtls_go120.go b/common/protocol/quic/qtls_go120.go +new file mode 100644 +index 0000000..e182c75 +--- /dev/null ++++ b/common/protocol/quic/qtls_go120.go +@@ -0,0 +1,18 @@ ++//go:build go1.20 ++ ++package quic ++ ++import ( ++ "crypto/cipher" ++ ++ "github.com/quic-go/qtls-go1-20" ++) ++ ++type ( ++ // A CipherSuiteTLS13 is a cipher suite for TLS 1.3 ++ CipherSuiteTLS13 = qtls.CipherSuiteTLS13 ++) ++ ++func AEADAESGCMTLS13(key, fixedNonce []byte) cipher.AEAD { ++ return qtls.AEADAESGCMTLS13(key, fixedNonce) ++} +diff --git a/go.mod b/go.mod +index 49d8a74..7277794 100644 +--- a/go.mod ++++ b/go.mod +@@ -11,6 +11,8 @@ require ( + github.com/miekg/dns v1.1.50 + github.com/pelletier/go-toml v1.9.5 + github.com/pires/go-proxyproto v0.6.2 ++ github.com/quic-go/qtls-go1-18 v0.2.0 ++ github.com/quic-go/qtls-go1-19 v0.2.0 + github.com/quic-go/qtls-go1-20 v0.1.0 + github.com/quic-go/quic-go v0.32.0 + github.com/refraction-networking/utls v1.2.0 +@@ -44,8 +46,6 @@ require ( + github.com/klauspost/cpuid/v2 v2.2.3 // indirect + github.com/onsi/ginkgo/v2 v2.8.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect +- github.com/quic-go/qtls-go1-18 v0.2.0 // indirect +- github.com/quic-go/qtls-go1-19 v0.2.0 // indirect + github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect + go.uber.org/atomic v1.10.0 // indirect + golang.org/x/exp v0.0.0-20230131160201-f062dba9d201 // indirect