mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-01 04:38:12 +00:00
If listen on all interface do not return localhost as console
Fix https://github.com/GNS3/gns3-gui/issues/1574
This commit is contained in:
parent
f737989e44
commit
a8ffaa9cb5
@ -411,8 +411,16 @@ class Compute:
|
|||||||
def _getUrl(self, path):
|
def _getUrl(self, path):
|
||||||
host = self._host
|
host = self._host
|
||||||
# IPV6
|
# IPV6
|
||||||
if host and ":" in host:
|
if host:
|
||||||
host = "[{}]".format(host)
|
# IPV6
|
||||||
|
if ":" in host:
|
||||||
|
# Reduce IPV6 to his simple form
|
||||||
|
host = str(ipaddress.IPv6Address(host))
|
||||||
|
if host == "::":
|
||||||
|
host = "::1"
|
||||||
|
host = "[{}]".format(host)
|
||||||
|
elif host == "0.0.0.0":
|
||||||
|
host = "127.0.0.1"
|
||||||
return "{}://{}:{}/v2/compute{}".format(self._protocol, host, self._port, path)
|
return "{}://{}:{}/v2/compute{}".format(self._protocol, host, self._port, path)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
@ -127,7 +127,7 @@ NODE_OBJECT_SCHEMA = {
|
|||||||
"type": ["integer", "null"]
|
"type": ["integer", "null"]
|
||||||
},
|
},
|
||||||
"console_host": {
|
"console_host": {
|
||||||
"description": "Console host",
|
"description": "Console host. Warning if the host is 0.0.0.0 or :: (listen on all interfaces) you need to use the same address you use to connect to the controller.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
|
@ -43,9 +43,17 @@ def test_init(compute):
|
|||||||
def test_getUrl(controller):
|
def test_getUrl(controller):
|
||||||
compute = Compute("my_compute_id", protocol="https", host="localhost", port=84, controller=controller)
|
compute = Compute("my_compute_id", protocol="https", host="localhost", port=84, controller=controller)
|
||||||
assert compute._getUrl("/test") == "https://localhost:84/v2/compute/test"
|
assert compute._getUrl("/test") == "https://localhost:84/v2/compute/test"
|
||||||
|
# IPV6 localhost
|
||||||
compute = Compute("my_compute_id", protocol="https", host="::1", port=84, controller=controller)
|
compute = Compute("my_compute_id", protocol="https", host="::1", port=84, controller=controller)
|
||||||
assert compute._getUrl("/test") == "https://[::1]:84/v2/compute/test"
|
assert compute._getUrl("/test") == "https://[::1]:84/v2/compute/test"
|
||||||
|
|
||||||
|
# Listen on all interfaces aka 0.0.0.0 require us to connect via 127.0.0.1
|
||||||
|
compute = Compute("my_compute_id", protocol="https", host="0.0.0.0", port=84, controller=controller)
|
||||||
|
assert compute._getUrl("/test") == "https://127.0.0.1:84/v2/compute/test"
|
||||||
|
# IPV6
|
||||||
|
compute = Compute("my_compute_id", protocol="https", host="::", port=84, controller=controller)
|
||||||
|
assert compute._getUrl("/test") == "https://[::1]:84/v2/compute/test"
|
||||||
|
|
||||||
|
|
||||||
def test_host_ip(controller):
|
def test_host_ip(controller):
|
||||||
compute = Compute("my_compute_id", protocol="https", host="localhost", port=84, controller=controller)
|
compute = Compute("my_compute_id", protocol="https", host="localhost", port=84, controller=controller)
|
||||||
|
Loading…
Reference in New Issue
Block a user