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

Implement dual-stack support #861

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DerEnderKeks
Copy link

@DerEnderKeks DerEnderKeks commented Feb 24, 2024

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.

pychromecast/dial.py Outdated Show resolved Hide resolved
@emontnemery
Copy link
Collaborator

Please fix the CI issues

Copy link
Collaborator

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some hosts will have ipv6 disabled, and creating an ipv6 socket will fail, the IPV6 specifics needs to be wrapped with an OSError check with fall back to IPv4.

@DerEnderKeks
Copy link
Author

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

By using an INET6 socket with IPV6_V6ONLY disabled, legacy IPv4 can still be reached. To connect to v4 IPs, the addresses are mapped to IPv6. IPv6 addresses are only used when a hostname resolves to one and the system has a non-local IPv6 available. For hosts with IPv6 completely disabled for some reason, the socket falls back to v4-only.
@emontnemery
Copy link
Collaborator

@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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants