From c088ab3d1ae860a7c7bfa522b24305ced32b0643 Mon Sep 17 00:00:00 2001 From: Matt McClaskey Date: Thu, 30 Oct 2025 06:16:19 -0400 Subject: [PATCH] VNC-275 added explicit keepalive --- .gitmodules | 2 +- common/rfb/SMsgHandler.cxx | 4 ++++ common/rfb/SMsgHandler.h | 1 + common/rfb/SMsgReader.cxx | 8 ++++++++ common/rfb/SMsgReader.h | 1 + common/rfb/VNCSConnectionST.cxx | 13 +++++++++++++ common/rfb/VNCSConnectionST.h | 1 + common/rfb/msgTypes.h | 2 ++ kasmweb | 2 +- 9 files changed, 32 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 8232a78..34b096c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,7 @@ [submodule "kasmweb"] path = kasmweb url = https://github.com/kasmtech/noVNC.git - branch = master + branch = feature/VNC-275_server_idle_timeout [submodule "kasmvnc-functional-tests"] path = kasmvnc-functional-tests url = git@gitlab.com:kasm-technologies/internal/kasmvnc-functional-tests.git diff --git a/common/rfb/SMsgHandler.cxx b/common/rfb/SMsgHandler.cxx index ac9e588..23cd5fc 100644 --- a/common/rfb/SMsgHandler.cxx +++ b/common/rfb/SMsgHandler.cxx @@ -104,3 +104,7 @@ void SMsgHandler::setDesktopSize(int fb_width, int fb_height, cp.height = fb_height; cp.screenLayout = layout; } + +void SMsgHandler::keepAlive() +{ +} diff --git a/common/rfb/SMsgHandler.h b/common/rfb/SMsgHandler.h index 8856b9f..b8a6e7f 100644 --- a/common/rfb/SMsgHandler.h +++ b/common/rfb/SMsgHandler.h @@ -61,6 +61,7 @@ namespace rfb { virtual void sendStats(const bool toClient = true) = 0; virtual void handleFrameStats(rdr::U32 all, rdr::U32 render) = 0; + virtual void keepAlive(); virtual bool canChangeKasmSettings() const = 0; diff --git a/common/rfb/SMsgReader.cxx b/common/rfb/SMsgReader.cxx index 06d7953..933b1d8 100644 --- a/common/rfb/SMsgReader.cxx +++ b/common/rfb/SMsgReader.cxx @@ -106,6 +106,9 @@ void SMsgReader::readMsg() case msgTypeUnixRelay: readUnixRelay(); break; + case msgTypeKeepAlive: + readKeepAlive(); + break; default: fprintf(stderr, "unknown message type %d\n", msgType); throw Exception("unknown message type"); @@ -319,6 +322,11 @@ void SMsgReader::readFrameStats() handler->handleFrameStats(all, render); } +void SMsgReader::readKeepAlive() +{ + handler->keepAlive(); +} + void SMsgReader::readQEMUMessage() { int subType = is->readU8(); diff --git a/common/rfb/SMsgReader.h b/common/rfb/SMsgReader.h index 60d49c0..77af609 100644 --- a/common/rfb/SMsgReader.h +++ b/common/rfb/SMsgReader.h @@ -59,6 +59,7 @@ namespace rfb { void readRequestStats(); void readFrameStats(); void readBinaryClipboard(); + void readKeepAlive(); void readQEMUMessage(); void readQEMUKeyEvent(); diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx index cf3af0b..f8768fb 100644 --- a/common/rfb/VNCSConnectionST.cxx +++ b/common/rfb/VNCSConnectionST.cxx @@ -49,6 +49,10 @@ static LogWriter vlog("VNCSConnST"); static Cursor emptyCursor(0, 0, Point(0, 0), NULL); +namespace { +const rdr::U32 CLIENT_KEEPALIVE_KEYSYM = 1; +} + extern rfb::BoolParameter disablebasicauth; extern "C" char unixrelaynames[MAX_UNIX_RELAYS][MAX_UNIX_RELAY_NAME_LEN]; @@ -861,6 +865,10 @@ public: void VNCSConnectionST::keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down) { rdr::U32 lookup; + if (keycode == 0 && keysym == CLIENT_KEEPALIVE_KEYSYM) { + return; + } + lastEventTime = time(0); server->lastUserInputTime = lastEventTime; if (!(accessRights & AccessKeyEvents)) return; @@ -1699,6 +1707,11 @@ void VNCSConnectionST::handleFrameStats(rdr::U32 all, rdr::U32 render) frameTracking = false; } +void VNCSConnectionST::keepAlive() +{ + // Keepalive traffic should not influence idle disconnect timers. +} + // setCursor() is called whenever the cursor has changed shape or pixel format. // If the client supports local cursor then it will arrange for the cursor to // be sent to the client. diff --git a/common/rfb/VNCSConnectionST.h b/common/rfb/VNCSConnectionST.h index 6d8068c..4148494 100644 --- a/common/rfb/VNCSConnectionST.h +++ b/common/rfb/VNCSConnectionST.h @@ -172,6 +172,7 @@ namespace rfb { virtual void sendStats(const bool toClient = true); virtual void handleFrameStats(rdr::U32 all, rdr::U32 render); + virtual void keepAlive(); bool is_owner() const { bool read, write, owner; diff --git a/common/rfb/msgTypes.h b/common/rfb/msgTypes.h index 9098b33..cd8d49d 100644 --- a/common/rfb/msgTypes.h +++ b/common/rfb/msgTypes.h @@ -35,6 +35,7 @@ namespace rfb { const int msgTypeUpgradeToUdp = 181; const int msgTypeSubscribeUnixRelay = 182; const int msgTypeUnixRelay = 183; + const int msgTypeKeepAlive = 184; const int msgTypeServerFence = 248; const int msgTypeUserAddedToSession = 253; @@ -61,6 +62,7 @@ namespace rfb { //const int msgTypeUpgradeToUdp = 181; //const int msgTypeSubscribeUnixRelay = 182; //const int msgTypeUnixRelay = 183; + //const int msgTypeKeepAlive = 184; const int msgTypeClientFence = 248; diff --git a/kasmweb b/kasmweb index da6b8f3..52b190d 160000 --- a/kasmweb +++ b/kasmweb @@ -1 +1 @@ -Subproject commit da6b8f3cfbed05891380f33aa4ca541c99d1f4c6 +Subproject commit 52b190d8feabe54b029420450011e36d26bc7cfc