The port is a big endian unsigned short.

See https://github.com/discordapp/discord-api-docs/pull/1244
This commit is contained in:
Lorenzo 2019-12-06 19:33:15 +01:00 committed by GitHub
parent b458cc7b7d
commit 1b9108ffd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -721,9 +721,7 @@ class DiscordVoiceWebSocket(websockets.client.WebSocketClientProtocol):
ip_end = recv.index(0, ip_start)
state.ip = recv[ip_start:ip_end].decode('ascii')
# the port is a little endian unsigned short in the last two bytes
# yes, this is different endianness from everything else
state.port = struct.unpack_from('<H', recv, len(recv) - 2)[0]
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)