Skip to content

Commit

Permalink
don't include link-local (169.254) addresses in public_ips
Browse files Browse the repository at this point in the history
public_ips is meant to return addresses that might be connectable, which link-local are not
  • Loading branch information
minrk committed Sep 21, 2024
1 parent 3b1a9fe commit 843fc37
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion jupyter_client/localinterfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ def _populate_from_list(addrs: Sequence[str] | None) -> None:
for ip in addrs:
local_ips.append(ip)
if not ip.startswith("127."):
public_ips.append(ip)
if not ip.startswith("169.254."):
# don't include link-local address in public_ips
public_ips.append(ip)
elif not LOCALHOST:
LOCALHOST = ip

Expand Down Expand Up @@ -168,6 +170,9 @@ def _load_ips_psutil() -> None:
addr = address_data.address
if not (iface.startswith("lo") or addr.startswith("127.")):
public_ips.append(addr)
elif addr.startswith("169.254."):
# don't include link-local address in public_ips
pass
elif not LOCALHOST:
LOCALHOST = addr
local_ips.append(addr)
Expand Down Expand Up @@ -198,6 +203,9 @@ def _load_ips_netifaces() -> None:
continue
if not (iface.startswith("lo") or addr.startswith("127.")):
public_ips.append(addr)
elif addr.startswith("169.254."):
# don't include link-local address in public_ips
pass
elif not LOCALHOST:
LOCALHOST = addr
local_ips.append(addr)
Expand Down

0 comments on commit 843fc37

Please sign in to comment.