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

feat(console): add comprehensive test suite and expand send keys menu

- Add 23 unit and integration tests covering console views, authorization, URL/path normalization, and novncd daemon token extraction
- Refactor console/novncd arg parsing into __main__ block for clean test imports
- Expand Send Key(s) menu into categorized sections (System, Navigation/Desktop, Terminal Control, Virtual Consoles)
- Implement non-destructive LIFO sendKeyCombo using public rfb.sendKey API, eliminating vendor debt
- Wire Send Key actions across Lite, Full, and PTY (xterm) console templates
- Add modern navigator.keyboard.lock support during fullscreen sessions
This commit is contained in:
catborise 2026-09-26 12:10:35 +03:00
parent a444a2ba40
commit 591429b0c9
7 changed files with 679 additions and 80 deletions

View file

@ -7,16 +7,9 @@ from django.http.response import HttpResponseServerError
from django.shortcuts import render
from django.utils.translation import gettext_lazy as _
from instances.models import Instance
from django.conf import settings
from libvirt import libvirtError
from vrtManager.instance import wvmInstance
from webvirtcloud.settings import (
SOCKETIO_PUBLIC_HOST,
SOCKETIO_PUBLIC_PATH,
SOCKETIO_PUBLIC_PORT,
WS_PUBLIC_HOST,
WS_PUBLIC_PATH,
WS_PUBLIC_PORT,
)
def console(request):
@ -72,14 +65,18 @@ def console(request):
console_type = conn.get_console_type()
console_websocket_port = conn.get_console_websocket_port()
console_passwd = conn.get_console_passwd()
except libvirtError:
except (libvirtError, ValueError, IndexError, Instance.DoesNotExist):
console_type = None
console_websocket_port = None
console_passwd = None
ws_port = console_websocket_port if console_websocket_port else WS_PUBLIC_PORT
ws_host = WS_PUBLIC_HOST if WS_PUBLIC_HOST else request.get_host()
ws_path = WS_PUBLIC_PATH if WS_PUBLIC_PATH else "/"
ws_public_port = getattr(settings, "WS_PUBLIC_PORT", 6080)
ws_public_host = getattr(settings, "WS_PUBLIC_HOST", None)
ws_public_path = getattr(settings, "WS_PUBLIC_PATH", "/")
ws_port = console_websocket_port if console_websocket_port else ws_public_port
ws_host = ws_public_host if ws_public_host else request.get_host()
ws_path = ws_public_path if ws_public_path else "/"
if ":" in ws_host:
ws_host = re.sub(":[0-9]+", "", ws_host)
@ -91,11 +88,15 @@ def console(request):
console_page = "console-" + console_type + "-" + view_type + ".html"
response = render(request, console_page, locals())
elif console_type == "pty":
socketio_public_host = getattr(settings, "SOCKETIO_PUBLIC_HOST", None)
socketio_public_port = getattr(settings, "SOCKETIO_PUBLIC_PORT", 6081)
socketio_public_path = getattr(settings, "SOCKETIO_PUBLIC_PATH", "socket.io/")
socketio_host = (
SOCKETIO_PUBLIC_HOST if SOCKETIO_PUBLIC_HOST else request.get_host()
socketio_public_host if socketio_public_host else request.get_host()
)
socketio_port = SOCKETIO_PUBLIC_PORT if SOCKETIO_PUBLIC_PORT else 6081
socketio_path = SOCKETIO_PUBLIC_PATH if SOCKETIO_PUBLIC_PATH else "/"
socketio_port = socketio_public_port if socketio_public_port else 6081
socketio_path = socketio_public_path if socketio_public_path else "/"
if ":" in socketio_host:
socketio_host = re.sub(":[0-9]+", "", socketio_host)