Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 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
2 changes: 2 additions & 0 deletions notebook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
os.path.join(os.path.dirname(__file__), "templates"),
]

DEFAULT_NOTEBOOK_PORT = 8888

del os

from .nbextensions import install_nbextension
Expand Down
19 changes: 12 additions & 7 deletions notebook/base/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import notebook
from notebook._tz import utcnow
from notebook.i18n import combine_translations
from notebook.utils import is_hidden, url_path_join, url_is_absolute, url_escape
from notebook.utils import is_hidden, url_path_join, url_is_absolute, url_escape, urldecode_unix_socket_path
from notebook.services.security import csp_report_uri

#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -471,13 +471,18 @@ def check_host(self):
if host.startswith('[') and host.endswith(']'):
host = host[1:-1]

try:
addr = ipaddress.ip_address(host)
except ValueError:
# Not an IP address: check against hostnames
allow = host in self.settings.get('local_hostnames', ['localhost'])
# UNIX socket handling
check_host = urldecode_unix_socket_path(host)
if check_host.startswith('/') and os.path.exists(check_host):
allow = True
else:
allow = addr.is_loopback
try:
addr = ipaddress.ip_address(host)
except ValueError:
# Not an IP address: check against hostnames
allow = host in self.settings.get('local_hostnames', ['localhost'])
else:
allow = addr.is_loopback

if not allow:
self.log.warning(
Expand Down
Loading