Skip to content

Conversation

@jterrace
Copy link
Contributor

Without this, the discovery fails, because it includes 169 addresses, e.g.

>       sock.setsockopt(ip_proto, self._get_multicast(), iface)
E       OSError: [WinError 10049] The requested address is not valid in its context

python-ws-discovery\wsdiscovery\threaded.py:124: OSError

@andreikop
Copy link
Owner

@jterrace could you clarify why this range shall not be included?

@jterrace
Copy link
Contributor Author

Yes, this is the "Automatic Private IP Addressing" (APIPA), which is the range 169.254.0.1 to 169.254.255.254. You can read a little bit more about it at https://en.wikipedia.org/wiki/Link-local_address

This range is link-local and non-forwardable, which doesn't support multicast. It's mainly just used by Windows when an interface gets auto assigned a 169 address when there's no connectivity. There error above gets surfaced when trying to use these link-local adapters on Windows because multicast is not supported on this address range.

if isinstance(ip.ip, str):
ip_address = ipaddress.ip_address(ip.ip)
if not ip_address.is_loopback:
if not ip_address.is_loopback and ip_address not in _APIPA_RANGE:
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yeah that would probably work. Looks like the PR was already merged, but I can test it out and send another PR to simplify if it works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, it works: sent #81

if isinstance(ip.ip, tuple):
ip_address = ipaddress.ip_address(f"{ip.ip[0]}%{ip.ip[2]}")
if not ip_address.is_loopback:
if not ip_address.is_loopback and ip_address not in _APIPA_RANGE:
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure this makes sense since this will always be an IPv6 address

@andreikop andreikop merged commit 8c37685 into andreikop:master Jan 20, 2025
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.

3 participants