Closed samclane closed 1 year ago
Can confirm, same problem here. Would love a way to select the network adapter.
Potential breaking change, but you could add an additional filter to this line to exclude Hyper-v adapters.
It's not clear at this time if all Hyper-V interfaces cause this error or just specific types. I see WSL is in play on your machine. However, some Hyper-V interface types could be how the host actually does access the LAN.
Edit: Not just Hyper-V adapters cause this. In order to solve the issue, I added a continue filter at the adapter level on L43.
Here's what I ultimately ended up doing to filter out the [I assume] bad interface types and allow for manual selection of an interface to use. In device.py:
"""added global default variable IFINDEX"""
DEFAULT_TIMEOUT = 1 # second
DEFAULT_ATTEMPTS = 1
IFINDEX = 24
VERBOSE = False
#
#...lines omitted...
#
"""added logic to override the list of all adapters if global IFINDEX is passed to function."""
"""added regex filter based on interface nice_name for a few values that I felt like shouldn't be included in all_adapters"""
def get_broadcast_addrs(use_index: int = None):
broadcast_addrs = []
all_adapters = ifaddr.get_adapters()
if use_index is not None:
to_process = [a for a in all_adapters if a.index == use_index]
else:
to_process = all_adapters
for iface in to_process:
if re.search(
"VPN|TAP|Bluetooth|Loopback|Virtual Adapter|Hyper-V", iface.nice_name
):
continue
#
#...lines omitted...
#
"""added check to see if ifindex != none"""
if IFINDEX:
UDP_BROADCAST_IP_ADDRS = get_broadcast_addrs(use_index=IFINDEX)
else:
UDP_BROADCAST_IP_ADDRS = get_broadcast_addrs()
UDP_BROADCAST_PORT = 56700
I've downloaded the latest version of this library and have both hyper-v and vmware virtual apdaters on my computer and am getting this OSError: [WinError 10051] A socket operation was attempted to an unreachable network error.
These are what the adapters look like on my system,
Problem: Running
lifxLAN.get_devices()
with aHyper-V Virtual Ethernet Adapter
enabled causes Python to throw:OSError: [WinError 10051] A socket operation was attempted to an unreachable network
Traceback:
Workaround: Disable the Hyper-V adapter in your Control Panel
System Info:
OS: Windows 10 Python Version: 3.8.3 (venv) Pip List:
I've tried updating all my packages, including the latest src release of lifxlan, with no changes.
Additional Files: