Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions notebook/base/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

from traitlets.config import Application
from ipython_genutils.path import filefind
from ipython_genutils.py3compat import string_types
from ipython_genutils.py3compat import string_types, PY3

import notebook
from notebook._tz import utcnow
Expand Down Expand Up @@ -427,11 +427,15 @@ def check_host(self):
if host.startswith('[') and host.endswith(']'):
host = host[1:-1]

if not PY3:
# ip_address only accepts unicode on Python 2
host = host.decode('utf8', 'replace')

try:
addr = ipaddress.ip_address(host)
except ValueError:
# Not an IP address: check against hostnames
allow = host in self.settings.get('local_hostnames', [])
allow = host in self.settings.get('local_hostnames', ['localhost'])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

additionally, added 'localhost' as the default here so that it is defined by default when used outside NotebookApp, e.g. nbdime.

else:
allow = addr.is_loopback

Expand Down