home-assistant-libs / pychromecast

Library for Python 3 to communicate with the Google Chromecast.
MIT License
2.51k stars 378 forks source link

Implement dual-stack support #861

Open DerEnderKeks opened 4 months ago

DerEnderKeks commented 4 months ago

This PR adds support for IPv6 and thus dual-stack. It contains two changes:

  1. Unsetting the Host header when requesting the /setup/eureka_info endpoint, as I noticed that my NVIDIA Shield blocks any request (empty body with status code 403) when a domain is set in the header, at least when requesting via IPv6.
  2. Using a dual-stack socket and IPv6-mapped addresses for the protobuf socket. This remains fully compatible with legacy IPv4, as long as the host can open IPv6 sockets, which any OS from at least the last decade should be able to do.

Let me know if I overlooked anything, but the Youtube example now works fine with both, IPv4 and IPv6.

emontnemery commented 4 months ago

Please fix the CI issues

DerEnderKeks commented 4 months ago

The socket will now fall back to IPv4, for systems that are misconfigured to have IPv6 disabled ;)

emontnemery commented 3 months ago

@DerEnderKeks please don't amend your previous commit when making changes, it makes it hard to review (this project always squashes before merge, so no matter how many commits are on your branch, it will end up as a single commit)

DerEnderKeks commented 3 months ago

Alright (although I always consider it an unnessacary loss of information when you squash PRs into a single commit). I fixed the formatting, the check should pass now.