Skip to content

Commit

Permalink
fix: ip discovery changes (74 byte udp packets) (#1955)
Browse files Browse the repository at this point in the history
* fix: ip discovery changes (74 byte udp packets)

* chore: Pr will be 1955

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update CHANGELOG.md

Signed-off-by: Lala Sabathil <aiko@aitsys.dev>

* Update CHANGELOG.md

Co-authored-by: BobDotCom <71356958+BobDotCom@users.noreply.github.com>
Signed-off-by: Lala Sabathil <aiko@aitsys.dev>

---------

Signed-off-by: Lala Sabathil <aiko@aitsys.dev>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: BobDotCom <71356958+BobDotCom@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 2, 2023
1 parent eb90387 commit cab0d71
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit cab0d71

Please sign in to comment.