1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-10-14 04:54:03 -04:00

Added TestsEnabled Settings to enable VMessAEAD test

This commit is contained in:
Shelikhoo
2020-06-08 16:50:50 +08:00
parent 00103d1f73
commit d06a4d1f50
6 changed files with 34 additions and 13 deletions

View File

@@ -2,6 +2,7 @@ package encoding
import (
"bytes"
"context"
"crypto/aes"
"crypto/cipher"
"crypto/md5"
@@ -13,6 +14,7 @@ import (
"hash/fnv"
"io"
"os"
"strings"
vmessaead "v2ray.com/core/proxy/vmess/aead"
"golang.org/x/crypto/chacha20poly1305"
@@ -49,13 +51,20 @@ type ClientSession struct {
}
// NewClientSession creates a new ClientSession.
func NewClientSession(idHash protocol.IDHash) *ClientSession {
func NewClientSession(idHash protocol.IDHash, ctx context.Context) *ClientSession {
randomBytes := make([]byte, 33) // 16 + 16 + 1
common.Must2(rand.Read(randomBytes))
session := &ClientSession{}
session.isAEADRequest = true
session.isAEADRequest = false
if ctxValueTestsEnabled := ctx.Value(vmess.TestsEnabled); ctxValueTestsEnabled != nil {
testsEnabled := ctxValueTestsEnabled.(string)
if strings.Contains(testsEnabled, "VMessAEAD") {
session.isAEADRequest = true
}
}
if vmessexp, vmessexp_found := os.LookupEnv("VMESSAEADEXPERIMENT"); vmessexp_found {
if vmessexp == "y" {