mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-09 10:57:20 -05:00
Revert "put buffer into client session as allocation optimization"
This reverts commit 09b601528b
.
This commit is contained in:
parent
eeca745e89
commit
2ad12084ba
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user