Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions wsdiscovery/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

logger = logging.getLogger("util")

_APIPA_RANGE = ipaddress.ip_network("169.254.0.0/16")


def createSkelSoapMessage(soapAction):
doc = minidom.Document()
Expand Down Expand Up @@ -259,14 +261,14 @@ def _getNetworkAddrs(protocol_version):
for ip in iface.ips:
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

addrs.append(ip_address)
elif protocol_version == socket.AF_INET6:
for iface in ifaces:
for ip in iface.ips:
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

addrs.append(ip_address)
else:
logger.warning(f"requested protocol version ({protocol_version}) is not"
Expand Down