From f0a42b6b6708ec1d7898949e2b3ff67321a9a8ed Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Wed, 16 Aug 2023 08:29:33 +0800 Subject: [PATCH] Fix multi-user service not working with packet --- shadowaead/service_multi.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shadowaead/service_multi.go b/shadowaead/service_multi.go index 0a12377..cb73b7f 100644 --- a/shadowaead/service_multi.go +++ b/shadowaead/service_multi.go @@ -159,6 +159,7 @@ func (s *MultiService[U]) newPacket(ctx context.Context, conn N.PacketConn, buff } var readCipher cipher.AEAD var err error + decrypted := make([]byte, 0, buffer.Len()) for u, m := range s.methodMap { key := buf.NewSize(m.keySaltLength) Kdf(m.key, buffer.To(m.keySaltLength), key) @@ -168,13 +169,14 @@ func (s *MultiService[U]) newPacket(ctx context.Context, conn N.PacketConn, buff return err } var packet []byte - packet, err = readCipher.Open(buffer.Index(m.keySaltLength), rw.ZeroBytes[:readCipher.NonceSize()], buffer.From(m.keySaltLength), nil) + packet, err = readCipher.Open(decrypted, rw.ZeroBytes[:readCipher.NonceSize()], buffer.From(m.keySaltLength), nil) if err != nil { continue } buffer.Advance(m.keySaltLength) buffer.Truncate(len(packet)) + copy(buffer.Bytes(), packet) user, method = u, m break