Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions tests/utils/test_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def test_ip6_to_address_and_index():
"""Test we can extract from mocked adapters."""
adapters = _generate_mock_adapters()
assert netutils.ip6_to_address_and_index(adapters, "2001:db8::") == (('2001:db8::', 1, 1), 1)
assert netutils.ip6_to_address_and_index(adapters, "2001:db8::%1") == (('2001:db8::', 1, 1), 1)
with pytest.raises(RuntimeError):
assert netutils.ip6_to_address_and_index(adapters, "2005:db8::")

Expand Down
2 changes: 2 additions & 0 deletions zeroconf/_utils/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def get_all_addresses_v6() -> List[Tuple[Tuple[str, int, int], int]]:


def ip6_to_address_and_index(adapters: List[Any], ip: str) -> Tuple[Tuple[str, int, int], int]:
if '%' in ip:
ip = ip[: ip.index('%')] # Strip scope_id.
ipaddr = ipaddress.ip_address(ip)
for adapter in adapters:
for adapter_ip in adapter.ips:
Expand Down