Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 'reconnect' setting and patch noVNC to fix issue after browser tab has been idle. #8

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
FROM ghcr.io/linuxserver/baseimage-kasmvnc:debianbookworm-12c6f55b-ls87 AS buildstage
# taken from https://github.com/linuxserver/docker-baseimage-kasmvnc/blob/debianbookworm/Dockerfile
# modified to apply 'novnc.patch' (fixing a disconnect/reconnect issue)
FROM node:12-buster AS wwwstage

ARG KASMWEB_RELEASE="5ba4695e6526a27b8e38ec8d55dc33b39143e68a"

RUN \
echo "**** build clientside ****" && \
mkdir /src && \
cd /src && \
wget https://github.com/kasmtech/noVNC/tarball/${KASMWEB_RELEASE} -O - \
| tar --strip-components=1 -xz

COPY ./patches/novnc.patch /src/
RUN \
export QT_QPA_PLATFORM=offscreen && \
export QT_QPA_FONTDIR=/usr/share/fonts && \
echo "apply novnc.patch" && \
cd /src && \
patch -p1 -i novnc.patch && \
npm install && \
npm run-script build

RUN \
echo "**** organize output ****" && \
mkdir /build-out && \
cd /src && \
rm -rf node_modules/ && \
cp -R ./* /build-out/ && \
cd /build-out && \
rm *.md && \
rm AUTHORS && \
cp index.html vnc.html && \
mkdir Downloads

FROM ghcr.io/linuxserver/baseimage-kasmvnc:debianbookworm-f7a8978f-ls89 AS buildstage

# these are specified in Makefile
ARG ARCH
Expand Down Expand Up @@ -104,6 +139,7 @@ RUN \
FROM scratch

COPY --from=buildstage / .
COPY --from=wwwstage /build-out /usr/local/share/kasmvnc/www

# since we start from scratch, we need these env variables from the base images
ENV \
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ PKG_VERSION := $(shell yq e ".version" manifest.yaml)
TS_FILES := $(shell find ./ -name \*.ts)
ROOT_FILES := $(shell find ./root)
ASSET_FILES := $(shell find ./assets/compat)
PATCH_FILES := $(shell find ./patches)

.DELETE_ON_ERROR:

Expand Down Expand Up @@ -37,7 +38,7 @@ clean:
scripts/embassy.js: $(TS_FILES)
deno bundle scripts/embassy.ts scripts/embassy.js

docker-images/x86_64.tar: manifest.yaml Dockerfile docker_entrypoint.sh $(ROOT_FILES)
docker-images/x86_64.tar: manifest.yaml Dockerfile docker_entrypoint.sh $(ROOT_FILES) $(PATCH_FILES)
mkdir -p docker-images
docker buildx build --tag start9/$(PKG_ID)/main:$(PKG_VERSION) \
--build-arg ARCH=x86_64 \
Expand Down
7 changes: 7 additions & 0 deletions docker_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ EOF
fi
fi

# remove reference to non-existing file, see: https://github.com/linuxserver/kclient/issues/8
sed -i '/<script src="public\/js\/pcm-player\.js"><\/script>/d' /kclient/public/index.html

# add '&reconnect=' setting to kclient html
RECONNECT=$(yq e '.reconnect' /root/data/start9/config.yaml)
sed -i "s/\(index\.html?autoconnect=1\)/&\&reconnect=$RECONNECT/" /kclient/public/index.html

# hack to disable systemd-inhibit, which Wasabi uses for sleep/shutdown detection
# we don't need it, since we run in a container and don't use systemd or sleep the system.
# this gets rid of a lot of repeated warning logs
Expand Down
7 changes: 3 additions & 4 deletions manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
id: wasabi-webtop
title: "Wasabi"
version: 2.2.1
version: 2.2.1.1
release-notes: |
* Update to Wasabi 2.2.1.0 - See [full changelog](https://github.com/WalletWasabi/WalletWasabi/releases/tag/v2.2.1.0)
* Fix connecting to own Bitcoin Core P2P node
* Fix minor theme issues
* Add 'Automatically reconnect' option. Enable this to reconnect to the desktop when the connection is lost or the browser tab has been idle for too long.
* fix a minor issue when browser tab becomes idle (Cannot read properties of undefined (reading 'lastActiveAt'))
license: MIT
wrapper-repo: "https://github.com/remcoros/wasabi-webtop-startos"
upstream-repo: "https://github.com/WalletWasabi/WalletWasabi"
Expand Down
54 changes: 54 additions & 0 deletions patches/novnc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
diff --git a/app/ui.js b/app/ui.js
index d973ffd..8d9515e 100644
--- a/app/ui.js
+++ b/app/ui.js
@@ -1628,15 +1628,17 @@ const UI = {
// UI.disconnect() won't be used in those cases.
UI.connected = false;

+ clearInterval(UI._sessionTimeoutInterval);
+
UI.rfb = undefined;

if (!e.detail.clean) {
UI.updateVisualState('disconnected');
if (wasConnected) {
UI.showStatus(_("Something went wrong, connection is closed"),
- 'error');
+ 'error', 0, true);
} else {
- UI.showStatus(_("Failed to connect to server"), 'error');
+ UI.showStatus(_("Failed to connect to server"), 'error', 0, true);
}
} else if (UI.getSetting('reconnect', false) === true && !UI.inhibitReconnect) {
UI.updateVisualState('reconnecting');
@@ -1646,7 +1648,7 @@ const UI = {
return;
} else {
UI.updateVisualState('disconnected');
- UI.showStatus(_("Disconnected"), 'normal');
+ UI.showStatus(_("Disconnected"), 'error', 0, true);
}

document.title = PAGE_TITLE;
diff --git a/vnc.html b/vnc.html
index e5b5177..565f273 100644
--- a/vnc.html
+++ b/vnc.html
@@ -478,13 +478,14 @@
</div>
</li>
<li><hr></li>
- <li>
+ <li class="noVNC_hidden">
<label class="switch">
<input id="noVNC_setting_reconnect" type="checkbox">
+ <span class="slider round"></span>
<span class="slider-label">Automatic Reconnect</span>
</label>
</li>
- <li>
+ <li class="noVNC_hidden">
<label for="noVNC_setting_reconnect_delay">Reconnect Delay (ms):</label>
<input id="noVNC_setting_reconnect_delay" type="number">
</li>
6 changes: 6 additions & 0 deletions scripts/procedures/getConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ export const [getConfig, setConfigMatcher] = compat.getConfigAndMatcher({
"pattern-description": "Must not contain newline or quote characters.",
copyable: true,
},
reconnect: {
type: "boolean",
name: "Automatically reconnect",
description: "Automatically reconnect when the connection to the desktop is lost or the browser tab has been idle for too long.",
default: false,
},
wasabi: {
type: "object",
name: "Wasabi settings",
Expand Down
21 changes: 20 additions & 1 deletion scripts/procedures/migrations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
import { compat, types as T } from "../deps.ts";

export const migration: T.ExpectedExports.migration = compat.migrations
.fromMapping({}, "2.2.1" );
.fromMapping({
"2.2.1.1": {
up: compat.migrations.updateConfig(
(config: any) => {
config["reconnect"] = false;
return config;
},
true,
{ version: "2.2.1.1", type: "up" },
),
down: compat.migrations.updateConfig(
(config: any) => {
delete config["reconnect"];
return config;
},
true,
{ version: "2.2.1.1", type: "down" },
),
},
}, "2.2.1.1");