Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multi-user service not working with packet #6

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion shadowaead/service_multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
Loading