Skip to content

Commit

Permalink
Allow connection to ws console over IPv6. Fixes GNS3/gns3-web-ui#1400
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmj committed Aug 2, 2023
1 parent 88a1cef commit 658bfb7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion gns3server/handlers/api/controller/node_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import aiohttp
import asyncio
import ipaddress

from gns3server.web.route import Route
from gns3server.controller import Controller
Expand Down Expand Up @@ -477,7 +478,16 @@ async def ws_console(request, response):
await ws.prepare(request)
request.app['websockets'].add(ws)

ws_console_compute_url = "ws://{compute_host}:{compute_port}/v2/compute/projects/{project_id}/{node_type}/nodes/{node_id}/console/ws".format(compute_host=compute.host,
compute_host = compute.host
try:
# handle IPv6 address
ip = ipaddress.ip_address(compute_host)
if isinstance(ip, ipaddress.IPv6Address):
compute_host = '[' + compute_host + ']'
except ValueError:
pass

ws_console_compute_url = "ws://{compute_host}:{compute_port}/v2/compute/projects/{project_id}/{node_type}/nodes/{node_id}/console/ws".format(compute_host=compute_host,
compute_port=compute.port,
project_id=project.id,
node_type=node.node_type,
Expand Down

0 comments on commit 658bfb7

Please sign in to comment.