1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-08 02:05:31 -05:00

Feat: use different qtls modules for different Go version

This commit is contained in:
秋のかえで
2022-04-05 14:17:19 +08:00
parent 56371d87ef
commit e0df70b16d
5 changed files with 62 additions and 6 deletions

View File

@@ -8,7 +8,6 @@ import (
"io"
"github.com/lucas-clemente/quic-go/quicvarint"
"github.com/marten-seemann/qtls-go1-17"
"golang.org/x/crypto/hkdf"
"github.com/v2fly/v2ray-core/v5/common"
@@ -37,10 +36,10 @@ const (
var (
quicSaltOld = []byte{0xaf, 0xbf, 0xec, 0x28, 0x99, 0x93, 0xd2, 0x4c, 0x9e, 0x97, 0x86, 0xf1, 0x9c, 0x61, 0x11, 0xe0, 0x43, 0x90, 0xa8, 0x99}
quicSalt = []byte{0x38, 0x76, 0x2c, 0xf7, 0xf5, 0x59, 0x34, 0xb3, 0x4d, 0x17, 0x9a, 0xe6, 0xa4, 0xc8, 0x0c, 0xad, 0xcc, 0xbb, 0x7f, 0x0a}
initialSuite = &qtls.CipherSuiteTLS13{
initialSuite = &CipherSuiteTLS13{
ID: tls.TLS_AES_128_GCM_SHA256,
KeyLen: 16,
AEAD: qtls.AEADAESGCMTLS13,
AEAD: AEADAESGCMTLS13,
Hash: crypto.SHA256,
}
errNotQuic = errors.New("not quic")
@@ -153,7 +152,7 @@ func SniffQUIC(b []byte) (*SniffHeader, error) {
key := hkdfExpandLabel(crypto.SHA256, secret, []byte{}, "quic key", 16)
iv := hkdfExpandLabel(crypto.SHA256, secret, []byte{}, "quic iv", 12)
cipher := qtls.AEADAESGCMTLS13(key, iv)
cipher := AEADAESGCMTLS13(key, iv)
nonce := cache.Extend(int32(cipher.NonceSize()))
binary.BigEndian.PutUint64(nonce[len(nonce)-8:], uint64(packetNumber))
decrypted, err := cipher.Open(b[extHdrLen:extHdrLen], nonce, data, b[:extHdrLen])