Skip to content

Commit 0300f73

Browse files
committed
Work around Mac's scoped link-local address for localhost
1 parent 2bb4252 commit 0300f73

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

notebook/notebookapp.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,18 @@ def _default_allow_remote(self):
860860
addr = info[4][0]
861861
if not py3compat.PY3:
862862
addr = addr.decode('ascii')
863-
if not ipaddress.ip_address(addr).is_loopback:
863+
864+
try:
865+
parsed = ipaddress.ip_address(addr.split('%')[0])
866+
except ValueError:
867+
self.log.warning("Unrecognised IP address: %r", addr)
868+
continue
869+
870+
# Macs map localhost to 'fe80::1%lo0', a link local address
871+
# scoped to the loopback interface. For now, we'll assume that
872+
# any scoped link-local address is effectively local.
873+
if not (parsed.is_loopback
874+
or (('%' in addr) and parsed.is_link_local)):
864875
return True
865876
return False
866877
else:

0 commit comments

Comments
 (0)