Skip to content

Commit 843fc37

Browse files
committed
don't include link-local (169.254) addresses in public_ips
public_ips is meant to return addresses that might be connectable, which link-local are not
1 parent 3b1a9fe commit 843fc37

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

jupyter_client/localinterfaces.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ def _populate_from_list(addrs: Sequence[str] | None) -> None:
8787
for ip in addrs:
8888
local_ips.append(ip)
8989
if not ip.startswith("127."):
90-
public_ips.append(ip)
90+
if not ip.startswith("169.254."):
91+
# don't include link-local address in public_ips
92+
public_ips.append(ip)
9193
elif not LOCALHOST:
9294
LOCALHOST = ip
9395

@@ -168,6 +170,9 @@ def _load_ips_psutil() -> None:
168170
addr = address_data.address
169171
if not (iface.startswith("lo") or addr.startswith("127.")):
170172
public_ips.append(addr)
173+
elif addr.startswith("169.254."):
174+
# don't include link-local address in public_ips
175+
pass
171176
elif not LOCALHOST:
172177
LOCALHOST = addr
173178
local_ips.append(addr)
@@ -198,6 +203,9 @@ def _load_ips_netifaces() -> None:
198203
continue
199204
if not (iface.startswith("lo") or addr.startswith("127.")):
200205
public_ips.append(addr)
206+
elif addr.startswith("169.254."):
207+
# don't include link-local address in public_ips
208+
pass
201209
elif not LOCALHOST:
202210
LOCALHOST = addr
203211
local_ips.append(addr)

0 commit comments

Comments
 (0)