diff options
-rw-r--r-- | .bumpversion.cfg | 2 | ||||
-rw-r--r-- | PKGBUILD | 3 | ||||
-rw-r--r-- | kvmd/__init__.py | 2 | ||||
-rw-r--r-- | kvmd/apps/kvmd/api/export.py | 8 | ||||
-rw-r--r-- | kvmd/htserver.py | 6 | ||||
-rwxr-xr-x | setup.py | 2 | ||||
-rw-r--r-- | testenv/Dockerfile | 1 | ||||
-rw-r--r-- | web/share/js/bb.js | 3 | ||||
-rw-r--r-- | web/share/js/keypad.js | 20 | ||||
-rw-r--r-- | web/share/js/kvm/stream_janus.js | 29 |
10 files changed, 50 insertions, 26 deletions
diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 5024803e..eaceb17f 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,7 +1,7 @@ [bumpversion] commit = True tag = True -current_version = 3.234 +current_version = 3.238 parse = (?P<major>\d+)\.(?P<minor>\d+)(\.(?P<patch>\d+)(\-(?P<release>[a-z]+))?)? serialize = {major}.{minor} @@ -32,7 +32,7 @@ for _variant in "${_variants[@]}"; do pkgname+=(kvmd-platform-$_platform-$_board) done pkgbase=kvmd -pkgver=3.234 +pkgver=3.238 pkgrel=1 pkgdesc="The main PiKVM daemon" url="https://github.com/pikvm/kvmd" @@ -44,6 +44,7 @@ depends=( python-yaml python-aiohttp python-aiofiles + python-async-lru python-passlib python-pyotp python-qrcode diff --git a/kvmd/__init__.py b/kvmd/__init__.py index 83d7646c..01e76ba6 100644 --- a/kvmd/__init__.py +++ b/kvmd/__init__.py @@ -20,4 +20,4 @@ # ========================================================================== # -__version__ = "3.234" +__version__ = "3.238" diff --git a/kvmd/apps/kvmd/api/export.py b/kvmd/apps/kvmd/api/export.py index cfcbde41..a5d4d0bf 100644 --- a/kvmd/apps/kvmd/api/export.py +++ b/kvmd/apps/kvmd/api/export.py @@ -24,6 +24,8 @@ import asyncio from typing import Any +import async_lru + from aiohttp.web import Request from aiohttp.web import Response @@ -49,6 +51,10 @@ class ExportApi: @exposed_http("GET", "/export/prometheus/metrics") async def __prometheus_metrics_handler(self, _: Request) -> Response: + return Response(text=(await self.__get_prometheus_metrics())) + + @async_lru.alru_cache(maxsize=1, ttl=5) + async def __get_prometheus_metrics(self) -> str: (atx_state, hw_state, fan_state, gpio_state) = await asyncio.gather(*[ self.__atx.get_state(), self.__info_manager.get_submanager("hw").get_state(), @@ -68,7 +74,7 @@ class ExportApi: self.__append_prometheus_rows(rows, hw_state["health"], "pikvm_hw") self.__append_prometheus_rows(rows, fan_state, "pikvm_fan") - return Response(text="\n".join(rows)) + return "\n".join(rows) def __append_prometheus_rows(self, rows: list[str], value: Any, path: str) -> None: if isinstance(value, bool): diff --git a/kvmd/htserver.py b/kvmd/htserver.py index fa2aedc4..df5a3123 100644 --- a/kvmd/htserver.py +++ b/kvmd/htserver.py @@ -41,14 +41,10 @@ from aiohttp.web import StreamResponse from aiohttp.web import WebSocketResponse from aiohttp.web import WSMsgType from aiohttp.web import Application +from aiohttp.web import AccessLogger from aiohttp.web import run_app from aiohttp.web import normalize_path_middleware -try: - from aiohttp.web import AccessLogger # type: ignore -except ImportError: - from aiohttp.helpers import AccessLogger # type: ignore - from .logging import get_logger from .errors import OperationError @@ -56,7 +56,7 @@ def main() -> None: setup( name="kvmd", - version="3.234", + version="3.238", url="https://github.com/pikvm/kvmd", license="GPLv3", author="Maxim Devaev", diff --git a/testenv/Dockerfile b/testenv/Dockerfile index 7dedc9ec..a4246989 100644 --- a/testenv/Dockerfile +++ b/testenv/Dockerfile @@ -41,6 +41,7 @@ RUN pacman --noconfirm --ask=4 -Syy \ python-yaml \ python-aiohttp \ python-aiofiles \ + python-async-lru \ python-periphery \ python-passlib \ python-pyotp \ diff --git a/web/share/js/bb.js b/web/share/js/bb.js index 0fa94ada..3a54e8e7 100644 --- a/web/share/js/bb.js +++ b/web/share/js/bb.js @@ -25,6 +25,7 @@ export var browser = new function() { // https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser/9851769 + // https://github.com/fingerprintjs/fingerprintjs/discussions/641 // Opera 8.0+ let is_opera = ( @@ -34,7 +35,7 @@ export var browser = new function() { ); // Firefox 1.0+ - let is_firefox = (typeof InstallTrigger !== "undefined"); + let is_firefox = (typeof mozInnerScreenX !== "undefined"); // Safari 3.0+ "[object HTMLElementConstructor]" let is_safari = (function() { diff --git a/web/share/js/keypad.js b/web/share/js/keypad.js index 5a50b715..9c74dcd8 100644 --- a/web/share/js/keypad.js +++ b/web/share/js/keypad.js @@ -119,24 +119,20 @@ export function Keypad(__keys_parent, __sendKey, __apply_fixes) { return; } } - __commonHandler(__merged[code][0], state, false); if (__fix_mac_cmd && apply_fixes) { - __fixMacCmd(); + __fixMacCmd(code, state); } + __commonHandler(__merged[code][0], state, false); __unholdModifiers(); } }; - var __fixMacCmd = function() { - // https://bugs.chromium.org/p/chromium/issues/detail?id=28089 - // https://bugzilla.mozilla.org/show_bug.cgi?id=1299553 - if (__isActive(__modifiers["MetaLeft"][0]) || __isActive(__modifiers["MetaRight"][0])) { - for (let code in __keys) { - setTimeout(function() { - if (__isActive(__keys[code][0])) { - self.emitByCode(code, false, false); - } - }, 100); + var __fixMacCmd = function(code, state) { + if ((code == "MetaLeft" || code == "MetaRight") && !state) { + for (code in __keys) { + if (__isActive(__keys[code][0])) { + self.emitByCode(code, false, false); + } } } }; diff --git a/web/share/js/kvm/stream_janus.js b/web/share/js/kvm/stream_janus.js index 13c32244..5c73e336 100644 --- a/web/share/js/kvm/stream_janus.js +++ b/web/share/js/kvm/stream_janus.js @@ -220,10 +220,30 @@ export function JanusStreamer(__setActive, __setInactive, __setInfo, __allow_aud }, "onremotestream": function(stream) { - __logInfo("Got a remote stream:", stream); + let tracks = stream.getTracks(); + __logInfo("Got a remote stream changes:", stream, tracks); + + let has_video = false; + for (let track of tracks) { + if (track.kind == "video") { + has_video = true; + break; + } + } + + if (!has_video && __isOnline()) { + // Найдено в Windows 11 и Chrome/Edge. + // При перезагрузке целевого хоста браузер мьютит трек, + // приходит стрим без видеотрека и всё умирает. + // Связь должна как-то сама восстанавливаться, + // но этого почему-то не происходит. Костыль решает проблему. + __destroyJanus(); + } + _Janus.attachMediaStream($("stream-video"), stream); __sendKeyRequired(); __startInfoInterval(); + // FIXME: Задержка уменьшается, но начинаются заикания на кейфреймах. // - https://github.com/Glimesh/janus-ftl-plugin/issues/101 /*if (__handle && __handle.webrtcStuff && __handle.webrtcStuff.pc) { @@ -265,7 +285,6 @@ export function JanusStreamer(__setActive, __setInactive, __setInfo, __allow_aud var __updateInfo = function() { if (__handle !== null) { - let online = !!(__state && __state.source && __state.source.online); let info = ""; if (__handle !== null) { // https://wiki.whatwg.org/wiki/Video_Metrics @@ -283,10 +302,14 @@ export function JanusStreamer(__setActive, __setInactive, __setInfo, __allow_aud info = `${__handle.getBitrate()}`.replace("kbits/sec", "kbps"); } } - __setInfo(true, online, info); + __setInfo(true, __isOnline(), info); } }; + var __isOnline = function() { + return !!(__state && __state.source && __state.source.online); + }; + var __sendWatch = function() { if (__handle) { __logInfo(`Sending WATCH(audio=${__allow_audio}) + FEATURES ...`); |