diff --git a/README.md b/README.md
index 731df52..6d3ae66 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ open the same one on a server next week.
```mermaid
flowchart LR
- B["Your browser"] -->|noVNC| D["warmbox daemon
on your host"]
+ B["Your browser"] -->|voxl / noVNC| D["warmbox daemon
on your host"]
D --> V["Linux desktop
in a small VM"]
I[("OS image
read-only, shared")] --> V
V <--> S[("Your volume
files and apps")]
@@ -62,6 +62,7 @@ updating are in [docs/install.md](docs/install.md).
| You want to | How |
|---|---|
| Get a desktop fast | warmbox keeps a few VMs booted and ready, so **New desktop** takes about a second. |
+| Type and scroll in the tab | The console streams H.264 at 60 fps and takes keyboard, mouse and clipboard. |
| Choose the operating system | `warmbox create --image lxqt` |
| Keep your work | Attach a volume. The desktop can be destroyed and your files stay. |
| Move to another computer | Store the volume in a bucket and attach it on another host. |
@@ -162,7 +163,7 @@ background jobs and interactive sessions too, and all of it is in
| Status | What |
|---|---|
-| Solid and used daily | XFCE and LXQt desktops, the ready pool, accounts and workspaces, volumes with snapshots and clones, image build, pack and pull, running commands and moving files through the API |
+| Solid and used daily | XFCE and LXQt desktops, the voxl console, the ready pool, accounts and workspaces, volumes with snapshots and clones, image build, pack and pull, running commands and moving files through the API |
| Solid on Linux only | Memory checkpoints: `checkpoint`, `restore`, `hibernate` and `wake` |
| Experimental | `warmbox-app` and the `/p/` port proxy |
| Not built yet | Screenshots and input through the API, `omarchy` outside macOS, memory checkpoints on macOS, GPU and audio |
@@ -171,7 +172,8 @@ background jobs and interactive sessions too, and all of it is in
- The dashboard is plain HTTP unless you give it a certificate, so it only
listens on your own machine by default. To reach it from elsewhere, follow
- [docs/remote-access.md](docs/remote-access.md).
+ [docs/remote-access.md](docs/remote-access.md). The console needs HTTPS or
+ localhost — browsers only decode video on a secure origin.
- Everything inside a desktop runs as root.
- A volume attaches to one desktop at a time.
- Desktops have no GPU and no audio.
diff --git a/cmd/warmbox/main.go b/cmd/warmbox/main.go
index 1cee082..d7e203f 100644
--- a/cmd/warmbox/main.go
+++ b/cmd/warmbox/main.go
@@ -1,6 +1,6 @@
// Command warmbox is the self-hosted GUI-desktop orchestrator: it boots
// microVMs from a pre-baked image with vfkit, keeps a warm pool, and streams
-// each desktop to the browser over noVNC.
+// each desktop to the browser — voxl by default, noVNC as the fallback.
package main
import (
@@ -197,7 +197,7 @@ func editDistance(a, b string) int {
}
func usage() {
- fmt.Fprint(os.Stderr, `warmbox — self-hosted GUI desktop orchestrator (vfkit + noVNC)
+ fmt.Fprint(os.Stderr, `warmbox — self-hosted GUI desktop orchestrator (vfkit + voxl)
Usage:
warmbox daemon Run the orchestrator (web dashboard + REST API)
@@ -205,9 +205,10 @@ Usage:
systemd on Linux):
install | start | stop | restart | status
warmbox setup Install what's missing: hypervisor, guest image, noVNC
+ (the fallback console)
warmbox login Sign in as a user (stores a session)
warmbox logout End the CLI session
- warmbox create Provision a desktop, print its noVNC URL
+ warmbox create Provision a desktop, print its console URL
(--ttl 600 stops it by itself; --idempotency-key
makes a retry safe)
warmbox images List the named guest images the daemon can boot
diff --git a/deploy/guest/Dockerfile b/deploy/guest/Dockerfile
index db9034f..e772bb1 100644
--- a/deploy/guest/Dockerfile
+++ b/deploy/guest/Dockerfile
@@ -26,6 +26,48 @@ WORKDIR /src
COPY agent/ ./
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /warmbox-agent .
+# voxl — the default console streamer (H.264 over a WebSocket, decoded by
+# WebCodecs). Built from the published crate rather than a git clone so the
+# image carries an exact, checksum-verified version; its build script bundles
+# the browser client, so esbuild and clang (for bindgen over x264.h) are
+# build-time only.
+#
+# This is the one dependency that needs a C toolchain, which is why it is its
+# own stage: the build tools stay out of the runtime image.
+FROM alpine:3.22 AS voxlbuild
+ARG VOXL_VERSION=0.3.2
+RUN apk add --no-cache \
+ rust cargo pkgconf musl-dev linux-headers \
+ clang20 clang20-dev clang20-libclang llvm20-dev \
+ x264-dev libyuv libyuv-dev opus-dev pulseaudio-dev libxcb-dev esbuild
+ENV LIBCLANG_PATH=/usr/lib/llvm20/lib
+# Alpine ships libyuv's headers (libyuv-dev) and its shared object (libyuv),
+# but no pkg-config file — and voxl's build script asks pkg-config for it, so
+# the build would stop at "The file libyuv.pc needs to be installed". This is
+# that file, describing exactly what the two packages install.
+RUN printf '%s\n' \
+ 'prefix=/usr' \
+ 'exec_prefix=${prefix}' \
+ 'libdir=${exec_prefix}/lib' \
+ 'includedir=${prefix}/include' \
+ 'Name: libyuv' \
+ 'Description: YUV scaling and conversion' \
+ 'Version: 0' \
+ 'Libs: -L${libdir} -lyuv' \
+ 'Cflags: -I${includedir}' \
+ > /usr/lib/pkgconfig/libyuv.pc
+RUN cargo install voxl-server --version "${VOXL_VERSION}" --locked --root /voxl
+
+# A directory that is empty for a headless image, so the final stage can copy
+# it unconditionally: a screenless guest has nothing to stream and should not
+# carry the encoder.
+FROM alpine:3.22 AS voxlstage
+ARG DESKTOP=xfce
+COPY --from=voxlbuild /voxl/bin/voxl /usr/local/bin/voxl
+RUN set -eux; \
+ mkdir -p /out; \
+ if [ "${DESKTOP}" != "none" ]; then mv /usr/local/bin/voxl /out/voxl; fi
+
FROM alpine:3.22
ARG BROWSER=chromium
@@ -179,9 +221,18 @@ RUN set -eux; \
rm -rf /themes
COPY --from=agentbuild /warmbox-agent /usr/local/bin/warmbox-agent
+COPY --from=voxlstage /out/ /usr/local/bin/
COPY init /init
RUN chmod +x /init /usr/local/bin/warmbox-agent
+# voxl's runtime libraries: x264 for the encoder, libyuv to convert the frame,
+# Opus and the PulseAudio client because the binary links them (it runs with
+# --audio-enabled=false — the guest has no sound device).
+RUN set -eux; \
+ if [ "${DESKTOP}" != "none" ]; then \
+ apk add --no-cache x264-libs libyuv opus libpulse libxcb; \
+ fi
+
# HEADLESS=1 marks the image as one with no screen: /init reads this file and
# skips Xvnc and the desktop session, reporting ready off the agent port
# instead. It is a file inside the image rather than a cmdline flag from the
diff --git a/deploy/guest/init b/deploy/guest/init
index 00579dd..9cab2cf 100644
--- a/deploy/guest/init
+++ b/deploy/guest/init
@@ -319,6 +319,40 @@ else
log "xfce procs: $(ps -o comm= 2>/dev/null | grep -E 'xfwm4|xfce4-panel|xfdesktop|xfsettingsd|xfconfd|xfce4-terminal' | tr '\n' ' ')"
log "session log: $(tail -4 /var/log/xfce-session.log 2>&1 | tr '\n' '|')"
+
+ # --- voxl: the default console streamer ---
+ # H.264 over a WebSocket, decoded by the browser's WebCodecs, instead of
+ # RFB. Xvnc stays up underneath: it is both the X server voxl reads and the
+ # fallback console, so an image built before voxl — or a browser without
+ # WebCodecs — still gets a desktop. Best-effort: a streamer that fails to
+ # start must never stop the VM reporting ready.
+ #
+ # The password rides in the environment, not on a command line: this is a
+ # guest-local /proc, so unlike the kernel cmdline the host cannot read it.
+ # It is the same per-VM secret noVNC is given, so neither console widens
+ # what a sibling VM on the NAT could already reach.
+ if command -v voxl >/dev/null 2>&1; then
+ if [ "$VNC_AUTH" = "1" ] && [ -n "$VNCPASS" ]; then
+ VOXL_PASSWORD="$VNCPASS" voxl --addr 0.0.0.0 --port 6901 \
+ --audio-enabled=false >/var/log/voxl.log 2>&1 &
+ else
+ voxl --addr 0.0.0.0 --port 6901 --enable-basic-auth=false \
+ --audio-enabled=false >/var/log/voxl.log 2>&1 &
+ fi
+ i=0
+ while [ $i -lt 50 ]; do
+ ss -ltn 2>/dev/null | grep -q ':6901' && break
+ sleep 0.1
+ i=$((i+1))
+ done
+ if ss -ltn 2>/dev/null | grep -q ':6901'; then
+ log "voxl streaming on :6901 (H.264 over WebCodecs)"
+ else
+ log "WARN: voxl did not start: $(tail -3 /var/log/voxl.log 2>/dev/null | tr '\n' '|')"
+ fi
+ else
+ log "voxl not in this image: noVNC is the console"
+ fi
fi
# --- readiness callback ---
@@ -326,8 +360,13 @@ fi
# /files and runs talk to, and on an image with a screen that screen has to be
# streamable too — hence 5900. A headless image has no 5900 to wait for, and
# gating on it would leave create hanging until the daemon's own timeout.
+# When voxl is listening, gate on it instead: it is the console a browser will
+# actually get, and reporting ready a moment early means the first /d/ load
+# falls back to noVNC for no reason.
if [ -f /etc/warmbox/headless ]; then
READY_PORT=7077
+elif ss -ltn 2>/dev/null | grep -q ':6901'; then
+ READY_PORT=6901
else
READY_PORT=5900
fi
diff --git a/deploy/guest/smoke.sh b/deploy/guest/smoke.sh
index f469b44..6737603 100755
--- a/deploy/guest/smoke.sh
+++ b/deploy/guest/smoke.sh
@@ -100,3 +100,16 @@ fi
note "ok: $(cat "$WD/create.json")"
note "'$NAME' boots and reports ready"
+
+# Which console the desktop link picked. A note, not an assertion: an image
+# built before voxl is supposed to fall back to noVNC, and the smoke test is
+# run against published images too.
+id=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["id"])' "$WD/create.json" 2>/dev/null || true)
+if [ -n "$id" ]; then
+ console=$(curl -s -b "$JAR" "http://127.0.0.1:$PORT/d/$id" || true)
+ case "$console" in
+ */voxl/*) note "console: voxl (H.264)" ;;
+ */vnc/*) note "console: noVNC fallback" ;;
+ *) note "console: no screen" ;;
+ esac
+fi
diff --git a/docs/agent-api.md b/docs/agent-api.md
index 7ca5a85..c569346 100644
--- a/docs/agent-api.md
+++ b/docs/agent-api.md
@@ -86,10 +86,10 @@ events dispatched, nothing arriving in the guest. `AcceptKeyEvents`,
them changes it.
So a guest that cannot be typed into over VNC is a desktop you can only look
-at, which is why warmbox drives the screen through its own agent instead, and
-the VNC server is left to do what it is good at: showing the screen. The
-limitation is recorded in [limitations.md](limitations.md): a human cannot
-type into the browser console yet.
+at, which is why warmbox drives the screen through its own agent as well. The
+default console does not have this problem — voxl injects input with XTEST
+directly — but the noVNC fallback still does, so the agent API remains the
+reliable path for anything that must type. See [limitations.md](limitations.md).
### History and processes
```
diff --git a/docs/api.md b/docs/api.md
index a384787..86557b1 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -15,6 +15,11 @@ A result:
{ "ok": true, "id": "9f2c1ab4", "vnc": "/d/9f2c1ab4" }
```
+`vnc` is the console page. It serves the voxl stream by default and falls back
+to noVNC when the image has no streamer; add `?classic=1` to ask for noVNC
+explicitly. The stream itself is mounted at `/voxl//` (page, WebSocket,
+`/screenshot`, `/record`, `/wait`).
+
A failure:
```json
diff --git a/docs/development.md b/docs/development.md
index 9e86d6a..f744ba8 100644
--- a/docs/development.md
+++ b/docs/development.md
@@ -107,7 +107,8 @@ comes up fails the workflow.
snapshot/restore.
- **The agent API**: TTY, screenshot and input, so an agent can drive the screen
as well as the shell ([agent-api.md](agent-api.md)).
-- **WebRTC streaming**: replace noVNC/RFB for latency and bandwidth.
+- **Streaming**: voxl (H.264/WebCodecs) is the default console; noVNC/RFB is the
+ fallback. A WebRTC transport is the next step for lossy networks.
- **Windows**: a WSL2 guide, or a native WHPX QEMU backend. Unverified. The seam
is `internal/desktop/backend.go`.
- **Tests**: API and VM-lifecycle integration.
diff --git a/docs/limitations.md b/docs/limitations.md
index a36e325..5c80c63 100644
--- a/docs/limitations.md
+++ b/docs/limitations.md
@@ -15,8 +15,10 @@ loopback by default and refuses a network address without TLS or an explicit
`--insecure`.
Each guest's VNC server requires a per-VM password, generated inside the guest
-and handed to noVNC with the console URL. The guest sits behind the hypervisor's
-NAT, so that port is never on the LAN.
+and handed to noVNC with the console URL. voxl uses the same secret. The guest
+sits behind the hypervisor's NAT, so neither port is ever on the LAN, and voxl
+additionally refuses any browser request whose origin is not the console page's
+own.
Guests are on QEMU user-mode networking (`-netdev user`), never tap or
vhost-net. That is deliberate: slirp ends the guest's L2/L3 in QEMU's userspace
@@ -31,23 +33,32 @@ trade this boundary for LAN reachability.
What remains is the guest itself. It runs as root, and none of this is hardened
against someone who already has the desktop.
-## You cannot type into the browser console yet
+## The noVNC fallback cannot type
-The desktop streams to the browser, and the mouse works — but **keystrokes do
-not reach the guest over VNC**. The VNC server accepts the key events and
-then drops them before they reach the X server, while the same keystrokes
-work over the agent's own channel.
+The default console is **voxl**: H.264 over a WebSocket, decoded by the
+browser's WebCodecs. It carries keyboard, mouse, clipboard and scrolling.
+
+The fallback is noVNC, which the daemon still serves — an image built before
+voxl has no streamer, and a browser without WebCodecs cannot decode one. Over
+that fallback **keystrokes do not reach the guest**: the VNC server accepts the
+key events and then drops them before they reach the X server, while the same
+keystrokes work over the agent's own channel.
This was checked rather than assumed: the RFB bytes on the wire are correct,
pointer events and screen updates work, `xdotool` (XTEST) types into the
guest perfectly, and the same failure reproduces in a real browser with
noVNC. `AcceptKeyEvents`, `xkeyboard-config` and TigerVNC's `RawKeyboard`
-were each tried; none of them changes it.
+were each tried; none of them changes it. voxl injects keys through XTEST
+itself, which is why the default console does not have the problem. An agent is
+never blocked either way: it types through the agent API,
+`POST /api/desktops/{id}/input`.
+
+## The default console needs HTTPS or localhost
-So today the browser console is a *watch* screen, not a *drive* screen. An
-agent is not blocked: it types through the agent API instead —
-`POST /api/desktops/{id}/input` — which works. Fixing the human path means
-either a different VNC server in the guest or a newer TigerVNC.
+Browsers only expose WebCodecs on a secure origin. `http://localhost:7070`
+qualifies; so does a Tailscale or TLS endpoint. A plain-HTTP daemon reached
+over a network address (`--insecure`) serves a console that loads and then
+refuses to decode — use `?classic=1` there, which selects noVNC.
## EFI disk images are macOS-only
@@ -71,6 +82,17 @@ Guests get virtio-gpu without 3D, so a Wayland desktop composites through Mesa
`llvmpipe`. The Omarchy image is tuned for it, with a small output and effects
off. X11 is much lighter for remote display.
+## The console streams X11, not Wayland
+
+voxl captures an X11 display, so it is what the XFCE and LXQt images use. The
+Omarchy image is a Wayland session and keeps its own VNC path; `/d/` notices the
+streamer is not there and serves noVNC instead.
+
+voxl links x264, which is GPL-2.0, so a guest image that ships it is distributed
+under the GPL. warmbox itself (Apache-2.0) is unaffected — voxl is a separate
+process inside the guest — but the image, which already carries GPL-2.0
+TigerVNC, must ship with that obligation met.
+
## Images are big
Images are a few hundred MB compressed and download in one piece. Omarchy is the
diff --git a/docs/oss-positioning.md b/docs/oss-positioning.md
index 85e0f08..0fddc28 100644
--- a/docs/oss-positioning.md
+++ b/docs/oss-positioning.md
@@ -16,7 +16,8 @@ lock-in to one cloud, or a bespoke pile of QEMU/Firecracker/Docker glue per team
A single binary with one opinionated stack baked in:
- `internal/desktop/manager.go` shells out to **vfkit** directly.
-- `internal/vnc/websockify.go` *is* the streaming transport (noVNC/RFB).
+- `internal/vnc/websockify.go` *is* the fallback streaming transport (noVNC/RFB);
+ `internal/api` proxies the default one (voxl, H.264).
- `internal/config` + `internal/sync` are welded to **rclone/S3**.
- `cmd/warmbox/main.go` wires all of it together.
@@ -46,6 +47,7 @@ backends** (hypervisors) and **pluggable transports** (screen/input).
- Reference implementation: this repo.
- First backend: vfkit (macOS/Apple Silicon). Second: Cloud Hypervisor or QEMU (Linux/x86_64).
- First transport: VNC/noVNC. Then WebRTC.
+- Now: voxl (H.264 over WebSocket) is the default; noVNC is the fallback.
- Storage: the portable volume store (see `docs/volumes.md`).
One sentence: *"containerd for agent sandboxes."*
diff --git a/internal/api/auth.go b/internal/api/auth.go
index 52368a3..362008f 100644
--- a/internal/api/auth.go
+++ b/internal/api/auth.go
@@ -200,6 +200,7 @@ func minRoleFor(method, path string) int {
case strings.HasPrefix(path, "/d/") ||
strings.HasPrefix(path, "/websockify/") ||
strings.HasPrefix(path, "/vnc/") ||
+ strings.HasPrefix(path, "/voxl/") ||
strings.HasPrefix(path, "/p/"):
return catalog.RoleRank(catalog.RoleMember)
case strings.HasPrefix(path, "/api/"):
diff --git a/internal/api/headers_test.go b/internal/api/headers_test.go
index 07768b1..519b81d 100644
--- a/internal/api/headers_test.go
+++ b/internal/api/headers_test.go
@@ -69,3 +69,20 @@ func TestNoVNCPageIsExemptFromTheCSP(t *testing.T) {
t.Error("the console page lost its CSP")
}
}
+
+// voxl is a vendored app we serve, like noVNC, and its page brings its own
+// bundles and worklets. A CSP that blocked them would leave the console on a
+// black frame with nothing in the daemon's log to explain it, so the stream
+// namespace is exempt for the same reason noVNC's is.
+func TestVoxlIsExemptFromTheCSP(t *testing.T) {
+ s := &Server{}
+ for _, path := range []string{"/voxl/abc123/", "/voxl/abc123/main.js", "/voxl/abc123/ws"} {
+ if got := headerFor(t, s, path).Get("Content-Security-Policy"); got != "" {
+ t.Errorf("%s served with %q, which blocks voxl's bootstrap", path, got)
+ }
+ }
+ // Everything else keeps it, including the neighbouring proxy namespace.
+ if h := headerFor(t, s, "/p/abc123/6901/"); h.Get("Content-Security-Policy") == "" {
+ t.Error("the generic port proxy lost its CSP")
+ }
+}
diff --git a/internal/api/server.go b/internal/api/server.go
index 4d20c00..349effb 100644
--- a/internal/api/server.go
+++ b/internal/api/server.go
@@ -234,7 +234,10 @@ func (s *Server) Handler() http.Handler {
// Publish a guest HTTP server (e.g. an agent-built dashboard) at a link.
mux.HandleFunc("GET /p/{id}/{port}/", s.expose)
- // Short desktop URL: serves noVNC full-screen, no token in the address bar.
+ // The desktop's voxl stream (page, websocket, screenshots, /wait).
+ mux.HandleFunc("GET /voxl/{id}/", s.voxlStream)
+
+ // Short desktop URL: the voxl console, or noVNC when the guest has none.
mux.HandleFunc("GET /d/{id}", s.dash)
// Static noVNC assets, one namespace per VM.
@@ -267,18 +270,19 @@ func (s *Server) GuestHandler() http.Handler {
// the app satisfies (same-origin scripts, inline styles for the charts,
// same-origin websockets for the console, blob workers for noVNC).
//
-// noVNC is the one exception, and it is a deliberate one. vnc.html boots from an
-// inline module script — `import UI from "./app/ui.js"; …` — which script-src
-// 'self' refuses. A refused bootstrap is completely silent: noVNC's UI never
-// starts, so it never opens the websocket, so the daemon has nothing to log and
-// the page sits on its loading screen forever. Allowing that script by hash
-// would work exactly until a noVNC release changed it, and then break the
-// console just as silently, so the CSP stops at our own documents: noVNC is a
-// vendored app we serve, not a page we wrote.
+// noVNC and voxl are the exceptions, and they are deliberate ones. Both are
+// vendored apps we serve, not pages we wrote, and both bootstrap in ways
+// `script-src 'self'` refuses: noVNC's vnc.html starts from an inline module
+// script, and voxl's page pulls its own bundles and worklets. A refused
+// bootstrap is completely silent — the UI never starts, so it never opens the
+// websocket, so the daemon has nothing to log and the page sits on its loading
+// screen forever. Allowing those scripts by hash would work exactly until the
+// next release changed them, and then break the console just as silently, so
+// the CSP stops at our own documents.
func (s *Server) securityHeaders(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := w.Header()
- if !strings.HasPrefix(r.URL.Path, "/vnc/") {
+ if !strings.HasPrefix(r.URL.Path, "/vnc/") && !strings.HasPrefix(r.URL.Path, "/voxl/") {
h.Set("Content-Security-Policy",
"default-src 'self'; base-uri 'none'; form-action 'self'; frame-ancestors 'self'; "+
"img-src 'self' data: blob:; style-src 'self' 'unsafe-inline'; "+
@@ -363,7 +367,7 @@ func (s *Server) withAuth(next http.Handler) http.Handler {
// gate: everything else falls to webui, which serves a real file if one exists
// and the SPA shell otherwise.
func isShellPath(p string) bool {
- for _, prefix := range []string{"/api/", "/internal/", "/websockify/", "/p/", "/d/", "/vnc/"} {
+ for _, prefix := range []string{"/api/", "/internal/", "/websockify/", "/p/", "/d/", "/vnc/", "/voxl/"} {
if strings.HasPrefix(p, prefix) {
return false
}
@@ -969,14 +973,15 @@ func (s *Server) createWithVolume(w http.ResponseWriter, r *http.Request, name,
writeJSON(w, http.StatusCreated, out)
}
-// dashHTML is the short desktop page: noVNC fills the viewport. The iframe
-// inherits the session cookie, so the URL carries no credential.
-const dashHTML = `
-warmbox
+// consoleHTML is the short desktop page: the console fills the viewport, and the
+// iframe inherits the session cookie, so the URL carries no credential of its
+// own. Which console is chosen is the only thing that varies.
+const consoleHTML = `
+warmbox
-
+
`
// headlessHTML is what /d/ shows for a desktop with no screen: the link is
@@ -999,8 +1004,10 @@ or start something long-lived with /runs.
Back to desktops
`
-// dash serves the short desktop URL. A request that still carries ?token= is
-// redirected to the bare path only when a login cookie already proves the
+// dash serves the short desktop URL: voxl when the guest runs it, noVNC
+// otherwise. `?classic=1` asks for the noVNC console explicitly, which is also
+// what a browser without WebCodecs needs. A request that still carries ?token=
+// is redirected to the bare path only when a login cookie already proves the
// session — otherwise the query token IS the credential (API tokens don't set
// cookies) and stripping it would lock the client out.
func (s *Server) dash(w http.ResponseWriter, r *http.Request) {
@@ -1018,15 +1025,52 @@ func (s *Server) dash(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/d/"+id, http.StatusFound)
return
}
- // noVNC reads `password` from the query string. It is the per-VM VNC
- // password the guest generated, so the console is not open to anything else
- // on the host that can reach the guest's port.
- pass := ""
- if p := vm.VNCPassword(); p != "" {
- pass = "&password=" + url.QueryEscape(p)
+ // Both consoles take the per-VM password the guest generated, so neither is
+ // open to anything else on the host that can reach the guest's ports.
+ pass := vm.VNCPassword()
+
+ src := "/vnc/" + id + "/vnc.html?autoconnect=1&resize=scale&show_dot=1&path=/websockify/" + id
+ if r.URL.Query().Get("classic") != "" || !s.voxlUp(r.Context(), vm) {
+ if pass != "" {
+ src += "&password=" + url.QueryEscape(pass)
+ }
+ } else {
+ src = "/voxl/" + id + "/"
+ if pass != "" {
+ src += "?token=" + url.QueryEscape(pass)
+ }
}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
- fmt.Fprintf(w, dashHTML, id, id, pass)
+ fmt.Fprintf(w, consoleHTML, src)
+}
+
+// voxlUp reports whether this desktop's streamer answers. Images built before
+// voxl have nothing on the port, so the console falls back to noVNC instead of
+// showing a page that can never connect. The probe is cheap and host-local: the
+// guest is on the NAT next door, and the timeout only costs the page it is on.
+func (s *Server) voxlUp(ctx context.Context, vm *desktop.VM) bool {
+ if s.cfg == nil {
+ return false
+ }
+ port := s.cfg.GuestVoxlPort
+ ip := vm.IP()
+ if port <= 0 || ip == "" {
+ return false
+ }
+ ctx, cancel := context.WithTimeout(ctx, 400*time.Millisecond)
+ defer cancel()
+ req, err := http.NewRequestWithContext(ctx, http.MethodGet,
+ "http://"+net.JoinHostPort(ip, strconv.Itoa(port))+"/healthz", nil)
+ if err != nil {
+ return false
+ }
+ resp, err := guestTransport.RoundTrip(req)
+ if err != nil {
+ return false
+ }
+ defer resp.Body.Close()
+ _, _ = io.Copy(io.Discard, io.LimitReader(resp.Body, 512))
+ return resp.StatusCode == http.StatusOK
}
func (s *Server) list(w http.ResponseWriter, r *http.Request) {
@@ -1516,6 +1560,53 @@ func (s *Server) expose(w http.ResponseWriter, r *http.Request) {
proxy.ServeHTTP(w, r)
}
+// voxlStream proxies the desktop's voxl streamer: the page at the root of
+// /voxl//, its websocket, its screenshots and its /wait endpoint.
+//
+// voxl refuses any request whose Origin is not the host it was asked for, which
+// is what stops another site's page from driving the desktop. Our page is
+// served from the dashboard's origin, so every request through here would be
+// refused; rewriting Origin to the address we dial (an IP, which cannot be
+// rebound) makes it look like voxl's own page. Direct requests, which never
+// pass through this handler and keep their real Origin, are still refused.
+func (s *Server) voxlStream(w http.ResponseWriter, r *http.Request) {
+ id := r.PathValue("id")
+ vm, ok := s.visibleVM(w, r, id)
+ if !ok {
+ return
+ }
+ port := s.cfg.GuestVoxlPort
+ if port <= 0 {
+ http.NotFound(w, r)
+ return
+ }
+ ip := vm.IP()
+ if ip == "" {
+ writeErr(w, r, http.StatusServiceUnavailable, "desktop_not_ready", "desktop not ready", nil)
+ return
+ }
+ target := net.JoinHostPort(ip, strconv.Itoa(port))
+ prefix := "/voxl/" + id
+
+ proxy := &httputil.ReverseProxy{
+ Director: func(req *http.Request) {
+ req.URL.Scheme = "http"
+ req.URL.Host = target
+ req.URL.Path = strings.TrimPrefix(req.URL.Path, prefix)
+ if req.URL.Path == "" {
+ req.URL.Path = "/"
+ }
+ req.Host = target
+ req.Header.Set("Origin", "http://"+target)
+ },
+ Transport: guestTransport,
+ ErrorHandler: func(w http.ResponseWriter, _ *http.Request, err error) {
+ s.fail(w, r, http.StatusBadGateway, "stream_unreachable", "could not reach the desktop's streamer", err)
+ },
+ }
+ proxy.ServeHTTP(w, r)
+}
+
func (s *Server) novnc(w http.ResponseWriter, r *http.Request) {
id := r.PathValue("id")
if _, ok := s.visibleVM(w, r, id); !ok {
diff --git a/internal/desktop/config.go b/internal/desktop/config.go
index c1536d8..608043b 100644
--- a/internal/desktop/config.go
+++ b/internal/desktop/config.go
@@ -99,6 +99,13 @@ type Config struct {
// GuestVNCPort is the VNC port the guest listens on.
GuestVNCPort int
+ // GuestVoxlPort is the port the guest's voxl streamer listens on. voxl is
+ // the default console: H.264 over a WebSocket, decoded by the browser's
+ // WebCodecs. The VNC server above stays up as the fallback, because an
+ // image built before voxl has nothing on this port and a browser without
+ // WebCodecs cannot decode it. 0 disables the voxl console entirely.
+ GuestVoxlPort int
+
// AgentPort is the port warmbox-agent listens on inside the guest.
AgentPort int
// GuestSSHPort is the port the guest's SSH server listens on (dropbear,
@@ -166,6 +173,7 @@ func DefaultConfig() *Config {
CPUs: 4,
Display: "1280x800",
GuestVNCPort: 5900,
+ GuestVoxlPort: 6901,
AgentPort: 7077,
GuestSSHPort: 22,
PoolSize: 2,