From 2ad12084ba38640fff42f35c83705b1c28754e54 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Fri, 14 Sep 2018 16:51:12 +0200 Subject: [PATCH] Revert "put buffer into client session as allocation optimization" This reverts commit 09b601528b522b1d3f4d9d77e36d606f41798bf9. --- proxy/vmess/encoding/client.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/proxy/vmess/encoding/client.go b/proxy/vmess/encoding/client.go index 30ea48e3..4ae7dac5 100644 --- a/proxy/vmess/encoding/client.go +++ b/proxy/vmess/encoding/client.go @@ -37,8 +37,6 @@ type ClientSession struct { responseBodyIV [16]byte responseReader io.Reader responseHeader byte - - buffer [33]byte // 16 + 16 + 1 } var clientSessionPool = sync.Pool{ @@ -47,11 +45,10 @@ var clientSessionPool = sync.Pool{ // NewClientSession creates a new ClientSession. func NewClientSession(idHash protocol.IDHash) *ClientSession { - session := clientSessionPool.Get().(*ClientSession) - - randomBytes := session.buffer[:] + randomBytes := make([]byte, 33) // 16 + 16 + 1 common.Must2(rand.Read(randomBytes)) + session := clientSessionPool.Get().(*ClientSession) copy(session.requestBodyKey[:], randomBytes[:16]) copy(session.requestBodyIV[:], randomBytes[16:32]) session.responseHeader = randomBytes[32]