Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ip discovery changes (74 byte udp packets) #1955

Merged
merged 7 commits into from Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -24,6 +24,9 @@ These changes are available on the `master` branch, but have not yet been releas

- Fixed the type-hinting of `SlashCommandGroup.walk_commands()` to reflect actual
behavior. ([#1852](https://github.com/Pycord-Development/pycord/pull/1852))
- Fixed the voice ip discovery due to the recent
[announced change](https://discord.com/channels/613425648685547541/697138785317814292/1080623873629884486).
([#1955](https://github.com/Pycord-Development/pycord/pull/1955))

## [2.4.0] - 2023-02-10

Expand Down
8 changes: 4 additions & 4 deletions discord/gateway.py
Expand Up @@ -892,16 +892,16 @@ async def initial_connection(self, data):
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")

Expand Down