mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
voice: clean up packet handling
This commit is contained in:
@@ -32,14 +32,14 @@ class PacketHandler extends EventEmitter {
|
||||
}
|
||||
|
||||
parseBuffer(buffer) {
|
||||
const { secretKey, encryptionMode } = this.receiver.connection.authentication;
|
||||
const { secret_key, mode } = this.receiver.connection.authentication;
|
||||
|
||||
// Choose correct nonce depending on encryption
|
||||
let end;
|
||||
if (encryptionMode === 'xsalsa20_poly1305_lite') {
|
||||
if (mode === 'xsalsa20_poly1305_lite') {
|
||||
buffer.copy(this.nonce, 0, buffer.length - 4);
|
||||
end = buffer.length - 4;
|
||||
} else if (encryptionMode === 'xsalsa20_poly1305_suffix') {
|
||||
} else if (mode === 'xsalsa20_poly1305_suffix') {
|
||||
buffer.copy(this.nonce, 0, buffer.length - 24);
|
||||
end = buffer.length - 24;
|
||||
} else {
|
||||
@@ -47,7 +47,7 @@ class PacketHandler extends EventEmitter {
|
||||
}
|
||||
|
||||
// Open packet
|
||||
let packet = secretbox.methods.open(buffer.slice(12, end), this.nonce, secretKey);
|
||||
let packet = secretbox.methods.open(buffer.slice(12, end), this.nonce, secret_key);
|
||||
if (!packet) return new Error('Failed to decrypt voice packet');
|
||||
packet = Buffer.from(packet);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user