mirror of
https://github.com/jupyter/notebook.git
synced 2025-04-06 13:50:29 +08:00
Merge pull request #2850 from wking/localinterfaces-localhost
Consolidate host IP detection in utils.localinterfaces This PR replaces a number of hard-coded 127.0.0.1 references with LOCALHOST, and consolidates the computation of LOCALHOST, LOCAL_IPS, and a new PUBLIC_IPS in the localinterfaces module. It's unclear to me when LOCALHOST would not be 127.0.0.1. I suppose you could have another IP in the 127.0.0.0/8 block, or a IPv6 address. It may also be possible to not have a loopback interface at all. In that case it's possible that we need a LOOPBACK variable in utils.localinterfaces which is a valid loopback interface or None, so that consumers can differentiate between generic IPs pointing back to the local host and the loopback interface.
This commit is contained in:
commit
c82b22b2f1
@ -70,6 +70,7 @@ from IPython.zmq.ipkernel import (
|
||||
IPKernelApp
|
||||
)
|
||||
from IPython.utils.importstring import import_item
|
||||
from IPython.utils.localinterfaces import LOCALHOST
|
||||
from IPython.utils.traitlets import (
|
||||
Dict, Unicode, Integer, List, Enum, Bool,
|
||||
DottedObjectName
|
||||
@ -87,9 +88,6 @@ _notebook_id_regex = r"(?P<notebook_id>\w+-\w+-\w+-\w+-\w+)"
|
||||
_profile_regex = r"(?P<profile>[^\/]+)" # there is almost no text that is invalid
|
||||
_cluster_action_regex = r"(?P<action>start|stop)"
|
||||
|
||||
|
||||
LOCALHOST = '127.0.0.1'
|
||||
|
||||
_examples = """
|
||||
ipython notebook # start the notebook
|
||||
ipython notebook --profile=sympy # use the sympy profile
|
||||
@ -610,7 +608,7 @@ class NotebookApp(BaseIPythonApplication):
|
||||
info("Use Control-C to stop this server and shut down all kernels.")
|
||||
|
||||
if self.open_browser or self.file_to_run:
|
||||
ip = self.ip or '127.0.0.1'
|
||||
ip = self.ip or LOCALHOST
|
||||
try:
|
||||
browser = webbrowser.get(self.browser or None)
|
||||
except webbrowser.Error as e:
|
||||
|
Loading…
x
Reference in New Issue
Block a user