Skip to content

Commit a71a822

Browse files
authored
Merge pull request #3767 from takluyver/reenable-host-check
Re-enable Host header check after 5.6
2 parents be16b95 + 0300f73 commit a71a822

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

notebook/notebookapp.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -852,10 +852,6 @@ def _token_changed(self, change):
852852
@default('allow_remote_access')
853853
def _default_allow_remote(self):
854854
"""Disallow remote access if we're listening only on loopback addresses"""
855-
# Disable the check temporarily because of Mac issues:
856-
# https://github.com/jupyter/notebook/issues/3754
857-
return True
858-
859855
try:
860856
addr = ipaddress.ip_address(self.ip)
861857
except ValueError:
@@ -864,7 +860,18 @@ def _default_allow_remote(self):
864860
addr = info[4][0]
865861
if not py3compat.PY3:
866862
addr = addr.decode('ascii')
867-
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)):
868875
return True
869876
return False
870877
else:

0 commit comments

Comments
 (0)