From 3aa5102036dcfcd9e5b6b454c2b1a9e819997b7a Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Wed, 29 Nov 2017 23:08:02 +0100 Subject: [PATCH] lazy init of authenticator --- proxy/shadowsocks/protocol.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/proxy/shadowsocks/protocol.go b/proxy/shadowsocks/protocol.go index 3dfdfc882..27f1520e2 100644 --- a/proxy/shadowsocks/protocol.go +++ b/proxy/shadowsocks/protocol.go @@ -299,7 +299,6 @@ func DecodeUDPPacket(user *protocol.User, payload *buf.Buffer) (*protocol.Reques account := rawAccount.(*MemoryAccount) var iv []byte - var authenticator *Authenticator if !account.Cipher.IsAEAD() && account.Cipher.IVSize() > 0 { // Keep track of IV as it gets removed from payload in DecodePacket. iv = make([]byte, account.Cipher.IVSize()) @@ -333,7 +332,7 @@ func DecodeUDPPacket(user *protocol.User, payload *buf.Buffer) (*protocol.Reques payloadLen := payload.Len() - AuthSize authBytes := payload.BytesFrom(payloadLen) - authenticator = NewAuthenticator(HeaderKeyGenerator(account.Key, iv)) + authenticator := NewAuthenticator(HeaderKeyGenerator(account.Key, iv)) actualAuth := make([]byte, AuthSize) authenticator.Authenticate(payload.BytesTo(payloadLen))(actualAuth) if !bytes.Equal(actualAuth, authBytes) {