1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 12:46:49 +00:00

fix(console): novncd reaches a VNC console where it listens

- A console listening on a given address is reached on that address;
  the compute's host name is used only for a wildcard listener (0.0.0.0,
  ::, none). It was always the host name, which may resolve to another
  interface.
- ::1 and localhost count as loopback like 127.0.0.0/8: such a console
  on a TCP or TLS host is refused instead of being tried on the host's
  name.
- The console page says why such a console cannot open and what to change
  (listen on all interfaces, or add the host over SSH) instead of a
  generic connection error.
This commit is contained in:
catborise 2026-10-26 19:58:42 +03:00
parent 68b104dfe4
commit 9c4c525800
3 changed files with 73 additions and 8 deletions

View file

@ -10,6 +10,7 @@ from django.utils.translation import gettext_lazy as _
from instances.models import Instance
from instances.utils import can_open_console
from libvirt import libvirtError
from vrtManager.connection import CONN_TCP, CONN_TLS
from vrtManager.instance import wvmInstance
@ -105,8 +106,11 @@ def console(request):
console_websocket_port = conn.get_console_websocket_port()
console_passwd = conn.get_console_passwd()
running = conn.instance.isActive()
# novncd reaches a console that listens on its host's loopback only
# through SSH (or on this host)
unreachable = instance.compute.type in (CONN_TCP, CONN_TLS) and conn.console_listens_locally()
except (libvirtError, ValueError, IndexError, Instance.DoesNotExist):
running = False
running = unreachable = False
console_type = None
console_websocket_port = None
console_passwd = None
@ -114,6 +118,13 @@ def console(request):
if console_type and not running: # a shut-off VM has no console to connect to
console_error = _("The VM is not running: start it to open its console.")
response = render(request, "console-vnc-lite.html", locals())
elif console_type == "vnc" and unreachable:
console_error = _(
"This console listens only on its host, which the panel reaches over TCP or TLS. "
"Let the console listen on all interfaces in the VM's console settings, "
"or add the host as an SSH host."
)
response = render(request, "console-vnc-lite.html", locals())
elif console_type == "vnc":
console_page = "console-vnc-" + view_type + ".html"
response = render(request, console_page, locals())