Browse Source

Fix udp discovery not using 74 byte layout

pull/9280/head
Florian Spieß 2 years ago
committed by GitHub
parent
commit
6910943703
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      discord/gateway.py

8
discord/gateway.py

@ -948,16 +948,16 @@ class DiscordVoiceWebSocket:
state.voice_port = data['port'] state.voice_port = data['port']
state.endpoint_ip = data['ip'] state.endpoint_ip = data['ip']
packet = bytearray(70) packet = bytearray(74)
struct.pack_into('>H', packet, 0, 1) # 1 = Send struct.pack_into('>H', packet, 0, 1) # 1 = Send
struct.pack_into('>H', packet, 2, 70) # 70 = Length struct.pack_into('>H', packet, 2, 70) # 70 = Length
struct.pack_into('>I', packet, 4, state.ssrc) struct.pack_into('>I', packet, 4, state.ssrc)
state.socket.sendto(packet, (state.endpoint_ip, state.voice_port)) state.socket.sendto(packet, (state.endpoint_ip, state.voice_port))
recv = await self.loop.sock_recv(state.socket, 70) recv = await self.loop.sock_recv(state.socket, 74)
_log.debug('received packet in initial_connection: %s', recv) _log.debug('received packet in initial_connection: %s', recv)
# the ip is ascii starting at the 4th byte and ending at the first null # the ip is ascii starting at the 8th byte and ending at the first null
ip_start = 4 ip_start = 8
ip_end = recv.index(0, ip_start) ip_end = recv.index(0, ip_start)
state.ip = recv[ip_start:ip_end].decode('ascii') state.ip = recv[ip_start:ip_end].decode('ascii')

Loading…
Cancel
Save