Skip to content

Commit fa36f0b

Browse files
authored
fix(voice): properly ignore non-voice packets (#1302)
1 parent 7c39e1a commit fa36f0b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/voice/VoiceConnection.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,10 @@ class VoiceConnection extends EventEmitter {
561561

562562
registerReceiveEventHandler() {
563563
this.udpSocket.on("message", (msg) => {
564+
if(msg[1] !== 0x78) { // unknown payload type, ignore
565+
return;
566+
}
567+
564568
const nonce = Buffer.alloc(24);
565569
msg.copy(nonce, 0, 0, 12);
566570
let data;
@@ -586,11 +590,7 @@ class VoiceConnection extends EventEmitter {
586590
// Not a RFC5285 One Byte Header Extension (not negotiated)
587591
if(hasExtension) { // RFC3550 5.3.1: RTP Header Extension
588592
const l = data[2] << 8 | data[3];
589-
let index = 4 + l * 4;
590-
while(data[index] == 0) {
591-
++index;
592-
}
593-
data = data.subarray(index);
593+
data = data.subarray(4 + l * 4);
594594
}
595595
if(this.receiveStreamOpus) {
596596
/**

0 commit comments

Comments
 (0)