fix: owner review 3 phase 1: server ports for clients, screenshot baselines (#16)
CI / Build and test (push) Successful in 9m36s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 9s
Release / Build, test and publish (push) Successful in 14m4s
CI / PostgreSQL 16 integration (push) Successful in 8m26s
CI / PostgreSQL 17 integration (push) Successful in 8m43s
CI / Docker image (push) Successful in 50s
Release / Server image (push) Successful in 1m23s

Clients could not reach a server in a container whose ports are published as other host ports: the panel showed the container's ports, the template had no public HTTP port, and a bare host meant port 443. Public ports become panel settings, the panel shows the client address, both clients default to 8443, and an address that answers as another service is named as not a Chronos server (its certificate never offered for trust). The screenshot baselines are captured on the development PC and committed; measured values are fixed while the capture runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #16.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-11-04 12:33:22 +01:00
1 parent 30a5b03f37
commit 255e149087
306 files changed
+2023 -206

No files matched your search

+93 -4
View File
@@ -4,10 +4,16 @@
// Audit log clean-up schedule's age limit (0 while it is off), and saving a new one sets it. Jobs run one at a time
// (owner review 1): the parallelism (photos at once) and the priority queue apply at once, as do the log levels,
// retention, size limits and rotation (owner review 2, R11). About (version, API, database, uptime) is the last group,
// read-only (owner review 2); #/about opens here on it.
// read-only (owner review 2); #/about opens here on it. Network (owner review 3): the public ports are the host ports
// clients use when they differ from the listening ones (a container publishes 8443 as another port) and apply at once;
// in a container the listening ports are the container's, read-only. Client address is what to type in the Uploader and
// in Chronos: this host as the browser reached it, on the HTTPS port this page came through (else the public HTTPS port;
// the proxy's address in TLS mode proxy). When that port is not the saved one, a button fills it in; saving a public HTTPS
// port other than the page's asks first, as the HTTPS redirect follows it at once.
import { t, applyStrings, languages } from "../i18n.js";
import { escapeHtml, attr, toast, errorText, nativeName, fingerprint, formatDuration, markInvalid, clearInvalid, invalidText, escapeReverts, routeParams, PROXY_WARNING } from "../ui.js";
import { escapeHtml, attr, toast, errorText, nativeName, fingerprint, formatDuration, markInvalid, clearInvalid, invalidText, escapeReverts, routeParams, confirmDialog, PROXY_WARNING } from "../ui.js";
import { kindLabel } from "../jobs.js";
import { icons } from "../icons.js";
/** Levels of the priority queue, highest first. */
const LEVELS = ["high", "normal", "low"];
@@ -50,6 +56,21 @@ export async function render(root, { api, info, setMeta, actions }) {
const choice = (name, value, values, label) => field(name, `<select class="input" name="${name}" ${lock(name)}>${values.concat(values.includes(value) ? [] : [value])
.map((v) => `<option value="${attr(v)}" ${v === value ? "selected" : ""}>${escapeHtml(t(label(v)))}</option>`).join("")}</select>`);
const level = (name, value) => choice(name, value, LOG_LEVELS, (l) => `Admin.Settings.Level.${cap(l)}`);
// A container's listening port is the template's Target, mapped to a host port: shown, never edited here.
const listening = (name, value) => settings.inContainer
? field(`container${cap(name)}`, `<input class="input narrow num" type="number" name="${name}" value="${attr(value)}" disabled data-i18n-title="Admin.Settings.ContainerPort.Tip">`)
: number(name, value, 'min="1" max="65535"');
// Empty: the listening port, which the placeholder shows.
const publicPort = (name, value, port) => number(name, value ?? "", `min="1" max="65535" placeholder="${attr(port)}"`);
// This page came through another HTTPS port than the one saved (a container's 8443 published as 8444, Public HTTPS port
// still empty): a button fills it in, so the redirect, discovery and the client address follow.
const publicHttps = () => {
const page = pagePort();
if (page === null || page === savedHttps() || locked("publicHttpsPort")) return publicPort("publicHttpsPort", settings.publicHttpsPort, settings.httpsPort);
return field("publicHttpsPort", `<span class="inline"><input class="input narrow num" type="number" name="publicHttpsPort" value="${attr(settings.publicHttpsPort ?? "")}"
min="1" max="65535" placeholder="${attr(settings.httpsPort)}" data-i18n-title="Admin.Settings.PublicHttpsPort.Tip">
<button class="btn small" type="button" id="use-page-port" title="${attr(t("Admin.Settings.UsePagePort.Tip", page))}">${escapeHtml(t("Admin.Settings.UsePagePort", page))}</button></span>`);
};
function draw() {
root.innerHTML = `
@@ -75,8 +96,12 @@ export async function render(root, { api, info, setMeta, actions }) {
<section class="panel" aria-labelledby="network-title">
<div class="panel-head"><h2 id="network-title" data-i18n="Admin.Settings.Network"></h2>
${settings.proxyWarning ? PROXY_WARNING : ""}</div>
${number("httpPort", settings.httpPort, 'min="1" max="65535"')}
${number("httpsPort", settings.httpsPort, 'min="1" max="65535"')}
${listening("httpPort", settings.httpPort)}
${listening("httpsPort", settings.httpsPort)}
${publicPort("publicHttpPort", settings.publicHttpPort, settings.httpPort)}
${publicHttps()}
${field("clientAddress", `<span class="inline"><input class="input mono" id="client-address" readonly dir="ltr" value="${attr(clientAddress())}" data-i18n-title="Admin.Settings.ClientAddress.Tip">
<button class="btn icon" type="button" id="copy-address" data-i18n-title="Admin.Settings.CopyAddress.Tip">${icons.copy}</button></span>`)}
${field("tlsMode", `<select class="input" name="tlsMode" ${lock("tlsMode")}>${["auto", "pem", "proxy"].map((m) =>
`<option value="${m}" ${m === settings.tlsMode ? "selected" : ""}>${escapeHtml(t(`Admin.Settings.Tls.${cap(m)}`))}</option>`).join("")}</select>`)}
${text("tlsCert", settings.tlsCert, 'dir="ltr" spellcheck="false"')}
@@ -109,6 +134,21 @@ export async function render(root, { api, info, setMeta, actions }) {
form.addEventListener("submit", save);
form.elements.tlsMode.addEventListener("change", () => pemFiles(form));
pemFiles(form);
root.querySelector("#use-page-port")?.addEventListener("click", (e) => {
form.elements.publicHttpsPort.value = String(pagePort());
e.currentTarget.remove();
form.elements.publicHttpsPort.focus();
});
const address = root.querySelector("#client-address");
root.querySelector("#copy-address").addEventListener("click", async () => {
try {
await navigator.clipboard.writeText(address.value);
toast(t("Admin.Settings.AddressCopied"));
} catch {
address.focus();
address.select();
}
});
// The levels matter only while the priority queue is on.
form.elements.priorityQueue.addEventListener("change", () => { root.querySelector(".priorities").hidden = !form.elements.priorityQueue.checked; });
}
@@ -140,6 +180,29 @@ export async function render(root, { api, info, setMeta, actions }) {
return dashboard ? formatDuration(dashboard.uptimeSeconds + (Date.now() - dashboard.at) / 1000) : "—";
}
/**
* What clients type to reach this server: the host name the browser used (an IPv6 address in brackets) on the port
* this page came through over HTTPS, which reaches the server whatever is saved; over plain HTTP (this machine), the
* public HTTPS port, else the HTTPS port; behind a reverse proxy, the proxy's address this page came through.
*/
function clientAddress() {
if (settings.tlsMode === "proxy") return location.origin;
const host = location.hostname.includes(":") && !location.hostname.startsWith("[") ? `[${location.hostname}]` : location.hostname;
const port = pagePort() ?? savedHttps();
return port === 443 ? `https://${host}` : `https://${host}:${port}`;
}
/** The HTTPS port clients are told to use, as saved: the public one, else the one the server listens on. */
function savedHttps() {
return settings.publicHttpsPort ?? settings.httpsPort;
}
/** The port this page came through when the browser speaks HTTPS to the server itself (not through a proxy), else null. */
function pagePort() {
if (location.protocol !== "https:" || settings.tlsMode === "proxy") return null;
return Number(location.port || 443);
}
/** The certificate and key files are used only in Own certificate mode; elsewhere they are off and say so. */
function pemFiles(form) {
const pem = form.elements.tlsMode.value === "pem";
@@ -157,6 +220,29 @@ export async function render(root, { api, info, setMeta, actions }) {
form.querySelectorAll("[aria-invalid]").forEach(clearInvalid);
const data = new FormData(form);
const value = (name, fallback) => (form.elements[name]?.disabled ? fallback : data.get(name));
// Text a number field cannot read is sent as -1, which the server refuses, so it is marked rather than cleared.
const publicValue = (name) => {
const input = form.elements[name];
if (input.disabled) return settings[name];
if (input.validity.badInput) return -1;
return input.value.trim() === "" ? 0 : Number(input.value);
};
// A new public HTTPS port other than the one this page came through moves the HTTPS redirect away from it at once: a
// typo would send the panel's link to a port where nothing, or another service, answers. Asked once before saving.
const nextPublic = publicValue("publicHttpsPort");
const page = pagePort();
const nextHttps = nextPublic === 0 || nextPublic == null ? settings.httpsPort : nextPublic;
if (page !== null && nextPublic !== -1 && nextHttps !== savedHttps() && nextHttps !== page && !await confirmDialog({
title: t("Admin.Settings.PortChangeTitle", nextHttps),
body: t("Admin.Settings.PortChangeBody", page),
confirm: t("Admin.Settings.PortChangeConfirm"),
confirmTip: t("Admin.Settings.PortChangeConfirm.Tip", nextHttps),
cancel: t("Admin.Common.Keep"),
cancelTip: t("Admin.Settings.PortChangeKeep.Tip"),
})) {
form.elements.publicHttpsPort.focus();
return;
}
const request = {
...settings,
serverName: String(value("serverName", settings.serverName)).trim(),
@@ -167,6 +253,9 @@ export async function render(root, { api, info, setMeta, actions }) {
discovery: form.elements.discovery.disabled ? settings.discovery : form.elements.discovery.checked,
httpPort: Number(value("httpPort", settings.httpPort)),
httpsPort: Number(value("httpsPort", settings.httpsPort)),
// Empty clears a public port (0); a locked one is sent as it is.
publicHttpPort: publicValue("publicHttpPort"),
publicHttpsPort: nextPublic,
tlsMode: String(value("tlsMode", settings.tlsMode)),
tlsCert: String(value("tlsCert", settings.tlsCert ?? "")).trim() || null,
tlsKey: String(value("tlsKey", settings.tlsKey ?? "")).trim() || null,