From 2bb4252f2187ae07e5ba7733774f23132bb1e280 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Sat, 14 Jul 2018 14:06:20 +0200 Subject: [PATCH 1/2] Re-enable Host header check after 5.6 --- notebook/notebookapp.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py index 20edc14d2..7500fcc26 100755 --- a/notebook/notebookapp.py +++ b/notebook/notebookapp.py @@ -852,10 +852,6 @@ class NotebookApp(JupyterApp): @default('allow_remote_access') def _default_allow_remote(self): """Disallow remote access if we're listening only on loopback addresses""" - # Disable the check temporarily because of Mac issues: - # https://github.com/jupyter/notebook/issues/3754 - return True - try: addr = ipaddress.ip_address(self.ip) except ValueError: From 0300f7341d42a93cf709b018c6880a6c1a6a635e Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Sun, 15 Jul 2018 09:13:26 +0200 Subject: [PATCH 2/2] Work around Mac's scoped link-local address for localhost --- notebook/notebookapp.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py index 7500fcc26..64bd30f95 100755 --- a/notebook/notebookapp.py +++ b/notebook/notebookapp.py @@ -860,7 +860,18 @@ class NotebookApp(JupyterApp): addr = info[4][0] if not py3compat.PY3: addr = addr.decode('ascii') - if not ipaddress.ip_address(addr).is_loopback: + + try: + parsed = ipaddress.ip_address(addr.split('%')[0]) + except ValueError: + self.log.warning("Unrecognised IP address: %r", addr) + continue + + # Macs map localhost to 'fe80::1%lo0', a link local address + # scoped to the loopback interface. For now, we'll assume that + # any scoped link-local address is effectively local. + if not (parsed.is_loopback + or (('%' in addr) and parsed.is_link_local)): return True return False else: