|
|
@ -1047,23 +1047,23 @@ class DiscordVoiceWebSocket: |
|
|
|
state.voice_port = data['port'] |
|
|
|
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, 2, 70) # 70 = Length |
|
|
|
struct.pack_into('>I', packet, 4, state.ssrc) |
|
|
|
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) |
|
|
|
|
|
|
|
# the ip is ascii starting at the 4th byte and ending at the first null |
|
|
|
ip_start = 4 |
|
|
|
# The IP is ASCII starting at the 8th byte and ending at the first null |
|
|
|
ip_start = 8 |
|
|
|
ip_end = recv.index(0, ip_start) |
|
|
|
state.ip = recv[ip_start:ip_end].decode('ascii') |
|
|
|
|
|
|
|
state.port = struct.unpack_from('>H', recv, len(recv) - 2)[0] |
|
|
|
_log.debug('Detected ip: %s, port: %s.', state.ip, state.port) |
|
|
|
|
|
|
|
# there *should* always be at least one supported mode (xsalsa20_poly1305) |
|
|
|
# There *should* always be at least one supported mode (xsalsa20_poly1305) |
|
|
|
modes = [mode for mode in data['modes'] if mode in self._connection.supported_modes] |
|
|
|
_log.debug('Received supported encryption modes: %s.', ", ".join(modes)) |
|
|
|
|
|
|
|