1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-13 20:08:55 +00:00

Fix IPV6 server support

Fix #717
This commit is contained in:
Julien Duponchelle 2016-10-17 14:10:25 +02:00
parent 421e127603
commit b9b0feed62
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
2 changed files with 12 additions and 4 deletions

View File

@ -409,7 +409,11 @@ class Compute:
self._controller.notification.emit("compute.updated", self.__json__())
def _getUrl(self, path):
return "{}://{}:{}/v2/compute{}".format(self._protocol, self._host, self._port, path)
host = self._host
# IPV6
if host and ":" in host:
host = "[{}]".format(host)
return "{}://{}:{}/v2/compute{}".format(self._protocol, host, self._port, path)
@asyncio.coroutine
def _run_http_query(self, method, path, data=None, timeout=10, raw=False):

View File

@ -40,6 +40,13 @@ def test_init(compute):
assert compute.id == "my_compute_id"
def test_getUrl(controller):
compute = Compute("my_compute_id", protocol="https", host="localhost", port=84, controller=controller)
assert compute._getUrl("/test") == "https://localhost:84/v2/compute/test"
compute = Compute("my_compute_id", protocol="https", host="::1", port=84, controller=controller)
assert compute._getUrl("/test") == "https://[::1]:84/v2/compute/test"
def test_host_ip(controller):
compute = Compute("my_compute_id", protocol="https", host="localhost", port=84, controller=controller)
assert compute.host_ip == "127.0.0.1"
@ -92,7 +99,6 @@ def test_compute_httpQueryNotConnected(compute, controller, async_run):
controller.notification.emit.assert_called_with("compute.updated", compute.__json__())
def test_compute_httpQueryNotConnectedGNS3vmNotRunning(compute, controller, async_run):
"""
We are not connected to the remote and it's a GNS3 VM. So we need to start it
@ -117,8 +123,6 @@ def test_compute_httpQueryNotConnectedGNS3vmNotRunning(compute, controller, asyn
controller.notification.emit.assert_called_with("compute.updated", compute.__json__())
def test_compute_httpQueryNotConnectedInvalidVersion(compute, async_run):
compute._connected = False
response = AsyncioMagicMock()