Filter APIPA address range when finding IP addresses.#78
Filter APIPA address range when finding IP addresses.#78andreikop merged 1 commit intoandreikop:masterfrom
Conversation
|
@jterrace could you clarify why this range shall not be included? |
|
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: |
There was a problem hiding this comment.
You could probably use is_link_local instead https://docs.python.org/3/library/ipaddress.html#ipaddress.IPv4Address.is_link_local
There was a problem hiding this comment.
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.
| 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: |
There was a problem hiding this comment.
Not sure this makes sense since this will always be an IPv6 address
Without this, the discovery fails, because it includes 169 addresses, e.g.