1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2025-07-12 08:16:09 +00:00

voice/udp: Reflect upstream changes from Discord

This commit is contained in:
Stefan Ric 2023-03-20 21:27:59 +01:00 committed by diamondburned
parent ba9d20b34b
commit 82c55dffac

View file

@ -90,9 +90,8 @@ func DialConnectionCustom(
} }
// https://discord.com/developers/docs/topics/voice-connections#ip-discovery // https://discord.com/developers/docs/topics/voice-connections#ip-discovery
ssrcBuffer := [70]byte{ var ssrcBuffer [74]byte
0x1, 0x2, binary.BigEndian.PutUint16(ssrcBuffer[0:2], 1)
}
binary.BigEndian.PutUint16(ssrcBuffer[2:4], 70) binary.BigEndian.PutUint16(ssrcBuffer[2:4], 70)
binary.BigEndian.PutUint32(ssrcBuffer[4:8], ssrc) binary.BigEndian.PutUint32(ssrcBuffer[4:8], ssrc)
@ -101,15 +100,15 @@ func DialConnectionCustom(
return nil, errors.Wrap(err, "failed to write SSRC buffer") return nil, errors.Wrap(err, "failed to write SSRC buffer")
} }
var ipBuffer [70]byte var ipBuffer [74]byte
// ReadFull makes sure to read all 70 bytes. // ReadFull makes sure to read all 74 bytes.
_, err = io.ReadFull(conn, ipBuffer[:]) _, err = io.ReadFull(conn, ipBuffer[:])
if err != nil { if err != nil {
return nil, errors.Wrap(err, "failed to read IP buffer") return nil, errors.Wrap(err, "failed to read IP buffer")
} }
ipbody := ipBuffer[4:68] ipbody := ipBuffer[8:72]
nullPos := bytes.Index(ipbody, []byte{'\x00'}) nullPos := bytes.Index(ipbody, []byte{'\x00'})
if nullPos < 0 { if nullPos < 0 {
@ -117,7 +116,7 @@ func DialConnectionCustom(
} }
ip := ipbody[:nullPos] ip := ipbody[:nullPos]
port := binary.LittleEndian.Uint16(ipBuffer[68:70]) port := binary.LittleEndian.Uint16(ipBuffer[72:74])
// https://discord.com/developers/docs/topics/voice-connections#encrypting-and-sending-voice // https://discord.com/developers/docs/topics/voice-connections#encrypting-and-sending-voice
packet := [12]byte{ packet := [12]byte{