Skip to content

Commit 2dad596

Browse files
committed
fix(voice): add additional guards to voice recieve
1 parent 280ef44 commit 2dad596

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/voice/src/receive/VoiceReceiver.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ export class VoiceReceiver {
185185
if (!stream) return;
186186

187187
if (this.connectionData.encryptionMode && this.connectionData.nonceBuffer && this.connectionData.secretKey) {
188+
// As a guard, we shouldn't parse packets that (1) aren't voice packets and (2) are not in the right RTP version
189+
// 0x78 (120) is the default Opus payload type, the marker bit is (largely) unused here by Discord
190+
if (msg[1] !== 0x78) return;
191+
192+
// Ignore packets not in RTP version 2
193+
const rtpVersion = msg[0]! >> 6;
194+
if (rtpVersion !== 2) return;
195+
188196
try {
189197
const packet = this.parsePacket(
190198
msg,

0 commit comments

Comments
 (0)