Compare commits
3
Commits
v1.1.0
...
2585b5d45f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2585b5d45f | ||
|
|
0aa2fb8135 | ||
|
|
369e754bec |
No files matched your search
@@ -225,6 +225,11 @@ security problems go privately to the maintainers (`SECURITY.md`), never into a
|
|||||||
prefixes when it copies the files to a separate releases repository: keep them verbatim. To try the template, save
|
prefixes when it copies the files to a separate releases repository: keep them verbatim. To try the template, save
|
||||||
it on the Unraid server as a user template (`/boot/config/plugins/dockerMan/templates-user/my-chronos-server.xml`)
|
it on the Unraid server as a user template (`/boot/config/plugins/dockerMan/templates-user/my-chronos-server.xml`)
|
||||||
and pick *chronos-server* in Docker › *Add container* › *Template*.
|
and pick *chronos-server* in Docker › *Add container* › *Template*.
|
||||||
|
- Ports: in a container the server listens on 8080 and 8443 (read-only in the admin panel); the host ports clients use
|
||||||
|
are the *Public HTTP/HTTPS port* settings (`CHRONOS_PUBLIC_HTTP_PORT`, `CHRONOS_PUBLIC_HTTPS_PORT`). Clients type the
|
||||||
|
*Client address* of Settings › Network and TLS; LAN discovery reaches them only with host networking (Unraid network
|
||||||
|
type *Host*), where the port mappings do nothing and `CHRONOS_HTTP_PORT` / `CHRONOS_HTTPS_PORT` move the listening
|
||||||
|
ports off ones another service uses. The user guide (`deploy/releases-repo/README.md`) explains both.
|
||||||
|
|
||||||
## Repository layout
|
## Repository layout
|
||||||
|
|
||||||
|
|||||||
@@ -11,10 +11,14 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
postgres:
|
postgres:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
# Publishing a port as another host port ("18443:8443")? Set CHRONOS_PUBLIC_HTTPS_PORT (and _HTTP_PORT) below to the
|
# Clients connect to https://<host>:8443, the Client address the admin panel shows (Settings › Network and TLS).
|
||||||
# host port. LAN discovery reaches clients only with "network_mode: host"; on this bridge network clients add the
|
# Publishing a port as another host port ("18443:8443")? Keep the container port (after the colon) and set
|
||||||
# server by its address. With host networking drop "ports", give the postgres service
|
# CHRONOS_PUBLIC_HTTPS_PORT and CHRONOS_PUBLIC_HTTP_PORT below, or the public ports in the admin panel, to the host
|
||||||
|
# ports. LAN discovery reaches clients only with "network_mode: host"; on this bridge network clients type the
|
||||||
|
# client address. With host networking drop "ports", give the postgres service
|
||||||
# ports: ["127.0.0.1:5432:5432"] and set CHRONOS_DB_HOST to 127.0.0.1: the name "postgres" no longer resolves there.
|
# ports: ["127.0.0.1:5432:5432"] and set CHRONOS_DB_HOST to 127.0.0.1: the name "postgres" no longer resolves there.
|
||||||
|
# The server then listens on the host's 8080 and 8443 itself: if another service uses either, set CHRONOS_HTTP_PORT
|
||||||
|
# or CHRONOS_HTTPS_PORT below to a free port and leave the public ports unset.
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
- "8443:8443"
|
- "8443:8443"
|
||||||
@@ -35,7 +39,13 @@ services:
|
|||||||
# host itself, run this service with network_mode: host; the proxy then reaches Chronos over loopback.
|
# host itself, run this service with network_mode: host; the proxy then reaches Chronos over loopback.
|
||||||
CHRONOS_TLS_MODE: auto
|
CHRONOS_TLS_MODE: auto
|
||||||
# CHRONOS_TRUSTED_PROXIES: "172.30.0.10"
|
# CHRONOS_TRUSTED_PROXIES: "172.30.0.10"
|
||||||
|
# The host ports clients use, when "ports" publishes 8080 and 8443 as others. Set here, the admin panel can no
|
||||||
|
# longer change them.
|
||||||
|
# CHRONOS_PUBLIC_HTTP_PORT: "8080"
|
||||||
# CHRONOS_PUBLIC_HTTPS_PORT: "8443"
|
# CHRONOS_PUBLIC_HTTPS_PORT: "8443"
|
||||||
|
# The ports the server listens on, with network_mode: host only (on a bridge network the mapping above decides).
|
||||||
|
# CHRONOS_HTTP_PORT: "8080"
|
||||||
|
# CHRONOS_HTTPS_PORT: "8443"
|
||||||
CHRONOS_SERVER_NAME: Chronos Server
|
CHRONOS_SERVER_NAME: Chronos Server
|
||||||
# Jobs run one at a time. Photos the running job processes at once (default: half the cores), and the priority queue
|
# Jobs run one at a time. Photos the running job processes at once (default: half the cores), and the priority queue
|
||||||
# (a higher job pauses the running one, which resumes afterwards). Set here, they can no longer be changed in the
|
# (a higher job pauses the running one, which resumes afterwards). Set here, they can no longer be changed in the
|
||||||
|
|||||||
@@ -70,9 +70,12 @@ Create the archive folder owned by `PUID:PGID` first (for example `mkdir -p <fol
|
|||||||
empty folder, or one owned by root (as Docker creates a missing one), is given to `PUID:PGID` at start: the folder
|
empty folder, or one owned by root (as Docker creates a missing one), is given to `PUID:PGID` at start: the folder
|
||||||
itself, never its contents. Any other folder that user cannot write stops the container with a one-line error.
|
itself, never its contents. Any other folder that user cannot write stops the container with a one-line error.
|
||||||
|
|
||||||
Open `http://<host>:8080/admin`, sign in as `admin` with the password from `.env` and choose a new one. Chronos
|
Open `http://<host>:8080/admin`, sign in as `admin` with the password from `.env` and choose a new one. Chronos and
|
||||||
clients connect to `https://<host>:8443`; the first connection shows the server's certificate fingerprint, which the
|
the Uploader connect to the *Client address* the admin panel shows under Settings › Network and TLS, by default
|
||||||
admin panel shows under Settings so you can compare them.
|
`https://<host>:8443` (an address typed without a port means 8443; `https://<name>` alone means 443, a reverse proxy).
|
||||||
|
The first connection shows the server's certificate fingerprint, which the admin panel shows under Settings so you can
|
||||||
|
compare them. An address that answers but is not Chronos (another service on that port) is reported as such, and its
|
||||||
|
certificate is never offered for trust.
|
||||||
|
|
||||||
- Image: `gitea.encke-hake.ts.net/balbosoft/chronos-server:latest`, the newest stable release (before the first one,
|
- Image: `gitea.encke-hake.ts.net/balbosoft/chronos-server:latest`, the newest stable release (before the first one,
|
||||||
the newest pre-release); also `:<version>`, and `:nightly`, the development version rebuilt every night, not for
|
the newest pre-release); also `:<version>`, and `:nightly`, the development version rebuilt every night, not for
|
||||||
@@ -95,14 +98,20 @@ admin panel shows under Settings so you can compare them.
|
|||||||
variable fixes is read-only there, and its tooltip names the variable. The compose file and Unraid template of earlier
|
variable fixes is read-only there, and its tooltip names the variable. The compose file and Unraid template of earlier
|
||||||
versions set `CHRONOS_LOG_LEVEL: Information`, which now fixes both levels: remove it (compose: delete the line;
|
versions set `CHRONOS_LOG_LEVEL: Information`, which now fixes both levels: remove it (compose: delete the line;
|
||||||
Unraid: edit the container and clear *Log level*) to choose them in the panel.
|
Unraid: edit the container and clear *Log level*) to choose them in the panel.
|
||||||
- Other host ports: when you publish the container's ports as other host ports (`18443:8443`), set
|
- Other host ports: when you publish the container's ports as other host ports (`18443:8443`), keep the container
|
||||||
`CHRONOS_PUBLIC_HTTPS_PORT` (and `CHRONOS_PUBLIC_HTTP_PORT`) to the host ports, so the admin panel's redirect to HTTPS
|
ports (8080 and 8443: in a container the admin panel shows them read-only) and enter the host ports as *Public HTTP
|
||||||
and LAN discovery name the ports clients can reach.
|
port* and *Public HTTPS port* in Settings › Network and TLS, or set `CHRONOS_PUBLIC_HTTP_PORT` and
|
||||||
|
`CHRONOS_PUBLIC_HTTPS_PORT`, which then lock them. They apply at once: the client address, the admin panel's
|
||||||
|
redirect to HTTPS and LAN discovery name the ports clients can reach.
|
||||||
- LAN discovery (`CHRONOS_DISCOVERY`, on by default) needs host networking (`network_mode: host` in compose, Network
|
- LAN discovery (`CHRONOS_DISCOVERY`, on by default) needs host networking (`network_mode: host` in compose, Network
|
||||||
type *Host* on Unraid): on a bridge network its broadcasts never leave the container's network. Without it, add the
|
type *Host* on Unraid): on a bridge network its broadcasts never leave the container's network. Without it, type the
|
||||||
server in Chronos by its address. With `network_mode: host` the name `postgres` no longer resolves: remove the
|
client address in Chronos and in the Uploader. With `network_mode: host` the name `postgres` no longer resolves: remove the
|
||||||
`ports` of the `chronos` service, publish PostgreSQL on loopback (`ports: ["127.0.0.1:5432:5432"]` under `postgres`)
|
`ports` of the `chronos` service, publish PostgreSQL on loopback (`ports: ["127.0.0.1:5432:5432"]` under `postgres`)
|
||||||
and set `CHRONOS_DB_HOST: 127.0.0.1`.
|
and set `CHRONOS_DB_HOST: 127.0.0.1`.
|
||||||
|
- With host networking the port mappings do nothing: the server listens on the host's 8080 and 8443 itself, and the
|
||||||
|
container does not start when another service already uses either. Then add the variable `CHRONOS_HTTP_PORT` or
|
||||||
|
`CHRONOS_HTTPS_PORT` with a free port (compose: under `environment`; Unraid: *Add another Path, Port, Variable…* ›
|
||||||
|
*Variable*, Key `CHRONOS_HTTPS_PORT`), and leave the public ports empty: clients reach the listening ports directly.
|
||||||
- Behind a reverse proxy (`CHRONOS_TLS_MODE=proxy`), only the proxies listed in `CHRONOS_TRUSTED_PROXIES` may set
|
- Behind a reverse proxy (`CHRONOS_TLS_MODE=proxy`), only the proxies listed in `CHRONOS_TRUSTED_PROXIES` may set
|
||||||
`X-Forwarded-*` headers. By default that is loopback only: other machines on your network reach the HTTP port
|
`X-Forwarded-*` headers. By default that is loopback only: other machines on your network reach the HTTP port
|
||||||
directly, so they must not choose the address the sign-in limit and the audit log see. List your proxy's own
|
directly, so they must not choose the address the sign-in limit and the audit log see. List your proxy's own
|
||||||
@@ -126,10 +135,20 @@ admin panel shows under Settings so you can compare them.
|
|||||||
3. Docker › *Add container* › Template `chronos-server`. Set the admin password, the database host, password and the
|
3. Docker › *Add container* › Template `chronos-server`. Set the admin password, the database host, password and the
|
||||||
archive share (default `/mnt/user/Timelapse`). The database host is the Unraid server's IP address (the PostgreSQL
|
archive share (default `/mnt/user/Timelapse`). The database host is the Unraid server's IP address (the PostgreSQL
|
||||||
template publishes port 5432): container names resolve only when both containers are on the same custom Docker
|
template publishes port 5432): container names resolve only when both containers are on the same custom Docker
|
||||||
network, not on the default *bridge*. If you change the HTTPS port, enter the same port in *Public HTTPS port*.
|
network, not on the default *bridge*. If you change the HTTP or HTTPS port, enter the same port in *Public HTTP port*
|
||||||
|
or *Public HTTPS port* (or later in the admin panel's Settings › Network and TLS).
|
||||||
*Array view* is the same share under `/mnt/user0` (default `/mnt/user0/Timelapse`): the admin panel then shows the
|
*Array view* is the same share under `/mnt/user0` (default `/mnt/user0/Timelapse`): the admin panel then shows the
|
||||||
array's free space rather than the cache's. Change it with the archive share, or remove it and clear *Space path*.
|
array's free space rather than the cache's. Change it with the archive share, or remove it and clear *Space path*.
|
||||||
4. Open the WebUI (`http://[IP]:8080/admin`).
|
4. Open the WebUI (`http://[IP]:8080/admin`). Clients connect to the *Client address* in Settings › Network and TLS,
|
||||||
|
`https://[IP]:<HTTPS port>`. On network type *Bridge* LAN discovery stays inside Docker, so clients do not find the
|
||||||
|
server by themselves: type that address. Network type *Host* lets them find it; the server then listens on the
|
||||||
|
host's own 8080 and 8443, so when another service uses either, add the variable `CHRONOS_HTTP_PORT` or
|
||||||
|
`CHRONOS_HTTPS_PORT` first (see host networking above).
|
||||||
|
|
||||||
|
Upgrading a container made from an earlier template, or one on `:nightly`: edit the container, set *Repository* to
|
||||||
|
`…/chronos-server:latest`, and set *Public HTTP port* and *Public HTTPS port* to the host ports the template maps (for
|
||||||
|
example 8087 and 8444), or enter them in the admin panel. The ports the panel listed as HTTP and HTTPS port are the
|
||||||
|
container's (8080 and 8443), not the ones clients use.
|
||||||
|
|
||||||
The template file is [`unraid/chronos.xml`](unraid/chronos.xml).
|
The template file is [`unraid/chronos.xml`](unraid/chronos.xml).
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<Privileged>false</Privileged>
|
<Privileged>false</Privileged>
|
||||||
<Support>https://gitea.encke-hake.ts.net/BalboSoft/Chronos/issues</Support>
|
<Support>https://gitea.encke-hake.ts.net/BalboSoft/Chronos/issues</Support>
|
||||||
<Project>https://gitea.encke-hake.ts.net/BalboSoft/Chronos</Project>
|
<Project>https://gitea.encke-hake.ts.net/BalboSoft/Chronos</Project>
|
||||||
<Overview>Chronos Server keeps a shared, verified archive of time-lapse photo sequences and renders them. Pair it with the official PostgreSQL 17 container.</Overview>
|
<Overview>Chronos Server keeps a shared, verified archive of time-lapse photo sequences and renders them; pair it with the official PostgreSQL 17 container. Clients connect to the Client address the admin panel shows (Settings, Network and TLS); LAN discovery needs network type Host.</Overview>
|
||||||
<Category>MediaServer:Photos Tools:</Category>
|
<Category>MediaServer:Photos Tools:</Category>
|
||||||
<WebUI>http://[IP]:[PORT:8080]/admin</WebUI>
|
<WebUI>http://[IP]:[PORT:8080]/admin</WebUI>
|
||||||
<TemplateURL>https://gitea.encke-hake.ts.net/BalboSoft/Chronos/raw/branch/main/deploy/unraid/chronos.xml</TemplateURL>
|
<TemplateURL>https://gitea.encke-hake.ts.net/BalboSoft/Chronos/raw/branch/main/deploy/unraid/chronos.xml</TemplateURL>
|
||||||
@@ -21,9 +21,10 @@
|
|||||||
<DonateText/>
|
<DonateText/>
|
||||||
<DonateLink/>
|
<DonateLink/>
|
||||||
<Requires>A PostgreSQL 16 or 17 container (official "postgres" template) with a database and user for Chronos.</Requires>
|
<Requires>A PostgreSQL 16 or 17 container (official "postgres" template) with a database and user for Chronos.</Requires>
|
||||||
<Config Name="HTTP port" Target="8080" Default="8080" Mode="tcp" Description="Admin panel and API over HTTP." Type="Port" Display="always" Required="true" Mask="false">8080</Config>
|
<Config Name="HTTP port" Target="8080" Default="8080" Mode="tcp" Description="Admin panel and API over HTTP; when you change it, enter the same port in Public HTTP port. Network type Host ignores this mapping: the server then listens on 8080 itself." Type="Port" Display="always" Required="true" Mask="false">8080</Config>
|
||||||
<Config Name="HTTPS port" Target="8443" Default="8443" Mode="tcp" Description="API over TLS for Chronos clients. When you change it, enter the same port in Public HTTPS port." Type="Port" Display="always" Required="true" Mask="false">8443</Config>
|
<Config Name="HTTPS port" Target="8443" Default="8443" Mode="tcp" Description="API over TLS for Chronos clients, which connect to https://[server IP]:[this port]; when you change it, enter the same port in Public HTTPS port. Network type Host ignores this mapping: the server then listens on 8443 itself." Type="Port" Display="always" Required="true" Mask="false">8443</Config>
|
||||||
<Config Name="Public HTTPS port" Target="CHRONOS_PUBLIC_HTTPS_PORT" Default="" Mode="" Description="The HTTPS port above, when it is not 8443; the admin panel redirects there." Type="Variable" Display="always" Required="false" Mask="false"/>
|
<Config Name="Public HTTP port" Target="CHRONOS_PUBLIC_HTTP_PORT" Default="" Mode="" Description="The HTTP port above, when it is not 8080; LAN discovery announces it. Set here, the admin panel can no longer change it (empty: 8080, changeable in the admin panel)." Type="Variable" Display="always" Required="false" Mask="false"/>
|
||||||
|
<Config Name="Public HTTPS port" Target="CHRONOS_PUBLIC_HTTPS_PORT" Default="" Mode="" Description="The HTTPS port above, when it is not 8443: the port of the client address, the admin panel's redirect and LAN discovery. Set here, the admin panel can no longer change it (empty: 8443, changeable in the admin panel)." Type="Variable" Display="always" Required="false" Mask="false"/>
|
||||||
<Config Name="Archive" Target="/archive" Default="/mnt/user/Timelapse" Mode="rw" Description="Originals, sidecars, proxies and renders." Type="Path" Display="always" Required="true" Mask="false">/mnt/user/Timelapse</Config>
|
<Config Name="Archive" Target="/archive" Default="/mnt/user/Timelapse" Mode="rw" Description="Originals, sidecars, proxies and renders." Type="Path" Display="always" Required="true" Mask="false">/mnt/user/Timelapse</Config>
|
||||||
<Config Name="Array view" Target="/space" Default="/mnt/user0/Timelapse" Mode="ro" Description="Optional: the same share seen on the array only (/mnt/user0/<share>), to show the array's free space." Type="Path" Display="always" Required="false" Mask="false">/mnt/user0/Timelapse</Config>
|
<Config Name="Array view" Target="/space" Default="/mnt/user0/Timelapse" Mode="ro" Description="Optional: the same share seen on the array only (/mnt/user0/<share>), to show the array's free space." Type="Path" Display="always" Required="false" Mask="false">/mnt/user0/Timelapse</Config>
|
||||||
<Config Name="App data" Target="/data" Default="/mnt/user/appdata/chronos" Mode="rw" Description="Settings, TLS certificate, uploads in progress and logs." Type="Path" Display="always" Required="true" Mask="false">/mnt/user/appdata/chronos</Config>
|
<Config Name="App data" Target="/data" Default="/mnt/user/appdata/chronos" Mode="rw" Description="Settings, TLS certificate, uploads in progress and logs." Type="Path" Display="always" Required="true" Mask="false">/mnt/user/appdata/chronos</Config>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ Companion to `docs/BRIEF.md` (scope, behaviour) and `docs/ui/DESIGN.md` (looks).
|
|||||||
| `src/Chronos.Core` | net10.0 | Engine shared by every program: metadata, codecs, imaging, analysis, advisor, motion, render, video containers and managed encoders, archive format, naming, import planning, packaging, localization runtime, diagnostics, brand mark |
|
| `src/Chronos.Core` | net10.0 | Engine shared by every program: metadata, codecs, imaging, analysis, advisor, motion, render, video containers and managed encoders, archive format, naming, import planning, packaging, localization runtime, diagnostics, brand mark |
|
||||||
| `src/Chronos.Core.Windows` | net10.0-windows | WIC decoders and codec inventory, Media Foundation encoders, DXGI adapters, removable devices and volume free space, DPAPI, shell launcher, window chrome, power (P/Invoke/COM only) |
|
| `src/Chronos.Core.Windows` | net10.0-windows | WIC decoders and codec inventory, Media Foundation encoders, DXGI adapters, removable devices and volume free space, DPAPI, shell launcher, window chrome, power (P/Invoke/COM only) |
|
||||||
| `src/Chronos.Data` | net10.0 | `IDatabase`, SQLite binding, PostgreSQL wire client, migrations, repositories, the job engine, the archive engine (`Archiving`), the analysis/render engine (`Processing`) and the client sync engine (`Sync`) |
|
| `src/Chronos.Data` | net10.0 | `IDatabase`, SQLite binding, PostgreSQL wire client, migrations, repositories, the job engine, the archive engine (`Archiving`), the analysis/render engine (`Processing`) and the client sync engine (`Sync`) |
|
||||||
| `src/Chronos.Protocol` | net10.0 | API v1 DTOs, source-generated JSON context, typed `ChronosClient` with certificate pinning and bandwidth limiting |
|
| `src/Chronos.Protocol` | net10.0 | API v1 DTOs, source-generated JSON context, typed `ChronosClient` with certificate pinning and bandwidth limiting, `ChronosAddress` (how both clients read a typed server address) |
|
||||||
| `src/Chronos.Server` | net10.0 (Web SDK) | ASP.NET Core minimal API, auth, uploads, sync, jobs, render nodes, events, embedded admin panel, Windows service host |
|
| `src/Chronos.Server` | net10.0 (Web SDK) | ASP.NET Core minimal API, auth, uploads, sync, jobs, render nodes, events, embedded admin panel, Windows service host |
|
||||||
| `src/Chronos.Ui` | net10.0-windows (WPF) | Theme (DESIGN tokens), icons, standard and custom controls, visuals (charts, filmstrip, preview, curve editor, virtualizing grid), `Loc` markup extension, MVVM helpers, notification-area icon |
|
| `src/Chronos.Ui` | net10.0-windows (WPF) | Theme (DESIGN tokens), icons, standard and custom controls, visuals (charts, filmstrip, preview, curve editor, virtualizing grid), `Loc` markup extension, MVVM helpers, notification-area icon |
|
||||||
| `src/Chronos.App` | WPF exe `Chronos.exe` | Desktop client |
|
| `src/Chronos.App` | WPF exe `Chronos.exe` | Desktop client |
|
||||||
|
|||||||
+41
-5
@@ -1498,7 +1498,17 @@ Global job bar mirrors the active job.
|
|||||||
|
|
||||||
First connection shows the certificate fingerprint (trust-on-first-use); login modal;
|
First connection shows the certificate fingerprint (trust-on-first-use); login modal;
|
||||||
per-sequence sync actions and states; conflict resolution only for settings JSON (keep
|
per-sequence sync actions and states; conflict resolution only for settings JSON (keep
|
||||||
mine / take server / save both).
|
mine / take server / save both). The address field, here and in the Uploader (§15), reads
|
||||||
|
one rule: no scheme means HTTPS, and then no port means 8443, the server's HTTPS port;
|
||||||
|
`https://<name>` alone keeps 443 (a reverse proxy); a typed port is kept; a bare IPv6
|
||||||
|
address gets its brackets; a link-local one with a zone index is refused. An address that
|
||||||
|
answers but not as a Chronos Server (any redirect, an answer that is not JSON, an error
|
||||||
|
without Chronos's `X-Chronos-Api` header and error code, JSON of another shape, more than
|
||||||
|
1 MB, or plain HTTP on a port reached over HTTPS) fails with one sentence naming the
|
||||||
|
address and the port to check; behind a certificate not
|
||||||
|
trusted yet, `server/info` is read once without checking it and without credentials, and only
|
||||||
|
a Chronos answer leads to the fingerprint question, so another service's certificate is never
|
||||||
|
offered for trust (amended 2026-11-04, owner review 3).
|
||||||
|
|
||||||
### 12.8 Settings
|
### 12.8 Settings
|
||||||
|
|
||||||
@@ -2119,7 +2129,17 @@ clean-up* schedule's age limit, R10), Logs (amended 2026-10-26, R11: file level
|
|||||||
level (Trace…None, default Information), keep logs (days), file size (MB), logs total (MB),
|
level (Trace…None, default Information), keep logs (days), file size (MB), logs total (MB),
|
||||||
rotation (daily or hourly, UTC), keep audit (days; the *Audit log clean-up* schedule's age
|
rotation (daily or hourly, UTC), keep audit (days; the *Audit log clean-up* schedule's age
|
||||||
limit, §14.6), diagnostics logs (MB), applied without a restart)). A field an environment
|
limit, §14.6), diagnostics logs (MB), applied without a restart)). A field an environment
|
||||||
variable fixes is read-only, its tooltip naming that variable (`lockedBy`, §14.3; R11). The
|
variable fixes is read-only, its tooltip naming that variable (`lockedBy`, §14.3; R11).
|
||||||
|
Network and TLS (amended 2026-11-04, owner review 3): HTTP port and HTTPS port (in a
|
||||||
|
container *Container HTTP/HTTPS port*, read-only: the template maps them to host ports),
|
||||||
|
*Public HTTP port* and *Public HTTPS port* (empty: the listening port, shown as placeholder;
|
||||||
|
applied at once to LAN discovery and the HTTPS redirect), and a read-only *Client address*
|
||||||
|
with Copy: `https://<the host name the browser used>:<the HTTPS port the page came through,
|
||||||
|
else the public HTTPS port>`, the proxy's address in TLS mode proxy, which is what users type
|
||||||
|
in Chronos and the Uploader; when the page's HTTPS port is not the saved one, a *Use <port>*
|
||||||
|
button fills it in as the Public HTTPS port, and saving a Public HTTPS port other than the
|
||||||
|
page's asks first, as the redirect follows it at once; the discovery tooltip says that a
|
||||||
|
container needs network type Host for it. The
|
||||||
last group of Settings, About, is read-only: version, API version, database and uptime (the
|
last group of Settings, About, is read-only: version, API version, database and uptime (the
|
||||||
server name and the fingerprint are in the groups above); an old `#/about` link opens Settings on it (amended 2026-10-26,
|
server name and the fingerprint are in the groups above); an old `#/about` link opens Settings on it (amended 2026-10-26,
|
||||||
R4, R5). Same UI rules: tooltips only, light/dark, localised via `/api/v1/i18n`, keyboard
|
R4, R5). Same UI rules: tooltips only, light/dark, localised via `/api/v1/i18n`, keyboard
|
||||||
@@ -2270,10 +2290,20 @@ it has worked in between; uploads always check the archive's own volume, §14.4,
|
|||||||
conversion the tighter of the two, §14.3: amended 2026-10-26, R7),
|
conversion the tighter of the two, §14.3: amended 2026-10-26, R7),
|
||||||
`CHRONOS_DB=postgres|sqlite` (Linux: postgres only), `CHRONOS_DB_HOST`, `CHRONOS_DB_PORT=5432`,
|
`CHRONOS_DB=postgres|sqlite` (Linux: postgres only), `CHRONOS_DB_HOST`, `CHRONOS_DB_PORT=5432`,
|
||||||
`CHRONOS_DB_NAME`, `CHRONOS_DB_USER`, `CHRONOS_DB_PASSWORD`, `CHRONOS_DB_SSLMODE=prefer`,
|
`CHRONOS_DB_NAME`, `CHRONOS_DB_USER`, `CHRONOS_DB_PASSWORD`, `CHRONOS_DB_SSLMODE=prefer`,
|
||||||
`CHRONOS_HTTP_PORT=8080`, `CHRONOS_HTTPS_PORT=8443`, `CHRONOS_TLS_MODE=auto|pem|proxy`,
|
`CHRONOS_HTTP_PORT=8080`, `CHRONOS_HTTPS_PORT=8443` (in a container, where
|
||||||
|
`DOTNET_RUNNING_IN_CONTAINER=true`, the listening ports are the template's: only these
|
||||||
|
variables change them, which network type Host needs when another service uses 8080 or
|
||||||
|
8443; the admin panel shows them read-only and a `server.json` value is ignored with a
|
||||||
|
warning and removed at the next save), `CHRONOS_PUBLIC_HTTP_PORT` and `CHRONOS_PUBLIC_HTTPS_PORT` (the host
|
||||||
|
ports clients use when a container's ports are published as others: LAN discovery, the HTTPS
|
||||||
|
redirect and the admin panel's client address use them; also the admin panel's *Public
|
||||||
|
HTTP/HTTPS port*, `PublicHttpPort`/`PublicHttpsPort` in `server.json`, applied at once;
|
||||||
|
amended 2026-11-04, owner review 3), `CHRONOS_TLS_MODE=auto|pem|proxy`,
|
||||||
`CHRONOS_TLS_CERT`, `CHRONOS_TLS_KEY`, `CHRONOS_SERVER_NAME`, `CHRONOS_LANG=en`,
|
`CHRONOS_TLS_CERT`, `CHRONOS_TLS_KEY`, `CHRONOS_SERVER_NAME`, `CHRONOS_LANG=en`,
|
||||||
`CHRONOS_PARALLELISM` (photos the running job processes at once; `CHRONOS_WORKERS`, its former
|
`CHRONOS_PARALLELISM` (photos the running job processes at once; `CHRONOS_WORKERS`, its former
|
||||||
name, still sets it), `CHRONOS_PRIORITY_QUEUE=false`, `CHRONOS_DISCOVERY=true` (LAN UDP beacon),
|
name, still sets it), `CHRONOS_PRIORITY_QUEUE=false`, `CHRONOS_DISCOVERY=true` (LAN UDP beacon; it leaves a
|
||||||
|
container only with host networking, Unraid network type Host: amended 2026-11-04, owner
|
||||||
|
review 3),
|
||||||
`CHRONOS_LOG_LEVEL` (Trace|Debug|Information|Warning|Error|Critical|None, also `info`,
|
`CHRONOS_LOG_LEVEL` (Trace|Debug|Information|Warning|Error|Critical|None, also `info`,
|
||||||
`warn`, `off`; default Information: sets the level of the log files and of the console and
|
`warn`, `off`; default Information: sets the level of the log files and of the console and
|
||||||
locks both in the admin panel), `CHRONOS_LOG_CONSOLE_LEVEL` (the console alone, read after
|
locks both in the admin panel), `CHRONOS_LOG_CONSOLE_LEVEL` (the console alone, read after
|
||||||
@@ -2536,7 +2566,12 @@ the log variables, *Log level* `CHRONOS_LOG_LEVEL` included, and *Audit retentio
|
|||||||
`CHRONOS_AUDIT_RETENTION_DAYS` are advanced and empty by default (each description gives
|
`CHRONOS_AUDIT_RETENTION_DAYS` are advanced and empty by default (each description gives
|
||||||
the default), so the admin panel's Settings › Logs chooses them; a value given in the
|
the default), so the admin panel's Settings › Logs chooses them; a value given in the
|
||||||
template locks its setting; TZ also sets the time zone of the schedules; amended
|
template locks its setting; TZ also sets the time zone of the schedules; amended
|
||||||
2026-10-26, R10, R11), description ≤ 2 sentences.
|
2026-10-26, R10, R11), *Public HTTP port* `CHRONOS_PUBLIC_HTTP_PORT` and *Public HTTPS port*
|
||||||
|
`CHRONOS_PUBLIC_HTTPS_PORT`, empty by default, next to the ports, whose descriptions say to
|
||||||
|
enter the same host port there when it changes and that network type Host ignores the mapping (the
|
||||||
|
server then listens on 8080 and 8443 itself; the user guide says to add `CHRONOS_HTTP_PORT` /
|
||||||
|
`CHRONOS_HTTPS_PORT` when another service uses either); the overview names the client address and
|
||||||
|
that LAN discovery needs network type Host (amended 2026-11-04, owner review 3), description ≤ 2 sentences.
|
||||||
Registry and Project `https://gitea.encke-hake.ts.net/BalboSoft/Chronos`,
|
Registry and Project `https://gitea.encke-hake.ts.net/BalboSoft/Chronos`,
|
||||||
Support `https://gitea.encke-hake.ts.net/BalboSoft/Chronos/issues`, TemplateURL
|
Support `https://gitea.encke-hake.ts.net/BalboSoft/Chronos/issues`, TemplateURL
|
||||||
`https://gitea.encke-hake.ts.net/BalboSoft/Chronos/raw/branch/main/deploy/unraid/chronos.xml`,
|
`https://gitea.encke-hake.ts.net/BalboSoft/Chronos/raw/branch/main/deploy/unraid/chronos.xml`,
|
||||||
@@ -2735,6 +2770,7 @@ questions asked and the answers; DECISIONS rows give the reasons.
|
|||||||
| 2026-10-26 | Owner review 2, R7 (naming) | §7.1, §13, §14.3 | One naming rule for import, upload and Reorganize: the sequence's camera and lens, `{n}` its place, a frame without a time at the sequence's start; template rules everywhere a template is typed or sent (no folder level scans skip, one a value such as a title gives escaped with `_`; a file template keeps the extension, tells photos apart, holds no slash; long names shortened before `.{ext}`; titles as text), held to a template only when it is given anew; `invalid_template` names the rule. |
|
| 2026-10-26 | Owner review 2, R7 (naming) | §7.1, §13, §14.3 | One naming rule for import, upload and Reorganize: the sequence's camera and lens, `{n}` its place, a frame without a time at the sequence's start; template rules everywhere a template is typed or sent (no folder level scans skip, one a value such as a title gives escaped with `_`; a file template keeps the extension, tells photos apart, holds no slash; long names shortened before `.{ext}`; titles as text), held to a template only when it is given anew; `invalid_template` names the rule. |
|
||||||
| 2026-10-26 | Owner review 2, R7 (conversion) | §5, §7, §8.1, §8.3, §8.7, §9, §12.2, §12.4, §12.5, §13, §14.3, §14.4, §14.5, §14.8, §14.9 | Convert after import on the desktop (the Archive manager's set, the Library's selection) and the admin panel (the Library's selection): JPEG with a quality, TIFF-16 or linear DNG (the archival choice, scene-referred so a RAW's highlights above white and colours outside sRGB survive), Replace or New sequence chosen at every run and never remembered, behind a dry run that lists each sequence's photos, sizes and the photos that stay as they are with why, and the free space where the conversion writes; Replace confirmed by typing; the `convert` job (stored as 19) converts exactly the photos confirmed, one sequence at a time and all or nothing, resumable through its journals and staging, never twice at once; full-resolution decodes only (the managed decoders first, never a 16-bit file from an 8-bit RAW development; the server leaves what it cannot read to a PC), what Chronos reads from a photo never changed (profiles carried, a linear DNG of sRGB values only), Exif carried, every file verified by the server's decoders; Replace swaps the files of the frames in place under a crash-safe journal, the originals going into a replaced trash entry that Undo or Restore swaps back and that Empty erases only while the archive on disk shows each conversion intact, or deleted on its own word (a tombstone, the trash, an erasure record); import still copies byte for byte and the card keeps a converted photo's copy; sync and the ingest count every encoding of a photo as one; `POST /api/v1/archive/convert` with the plan cache it shares with Reorganize, `sequenceChanged` `converted` and `created`, the audit `archive_converted`. |
|
| 2026-10-26 | Owner review 2, R7 (conversion) | §5, §7, §8.1, §8.3, §8.7, §9, §12.2, §12.4, §12.5, §13, §14.3, §14.4, §14.5, §14.8, §14.9 | Convert after import on the desktop (the Archive manager's set, the Library's selection) and the admin panel (the Library's selection): JPEG with a quality, TIFF-16 or linear DNG (the archival choice, scene-referred so a RAW's highlights above white and colours outside sRGB survive), Replace or New sequence chosen at every run and never remembered, behind a dry run that lists each sequence's photos, sizes and the photos that stay as they are with why, and the free space where the conversion writes; Replace confirmed by typing; the `convert` job (stored as 19) converts exactly the photos confirmed, one sequence at a time and all or nothing, resumable through its journals and staging, never twice at once; full-resolution decodes only (the managed decoders first, never a 16-bit file from an 8-bit RAW development; the server leaves what it cannot read to a PC), what Chronos reads from a photo never changed (profiles carried, a linear DNG of sRGB values only), Exif carried, every file verified by the server's decoders; Replace swaps the files of the frames in place under a crash-safe journal, the originals going into a replaced trash entry that Undo or Restore swaps back and that Empty erases only while the archive on disk shows each conversion intact, or deleted on its own word (a tombstone, the trash, an erasure record); import still copies byte for byte and the card keeps a converted photo's copy; sync and the ingest count every encoding of a photo as one; `POST /api/v1/archive/convert` with the plan cache it shares with Reorganize, `sequenceChanged` `converted` and `created`, the audit `archive_converted`. |
|
||||||
| 2026-10-26 | Owner review 2, R8 (phase 5a: workspace and projects, local home) | §4.4, §5, §7, §12.2, §12.3, §12.6, §12.8, §14.5, §14.6 | A sequence's home (this PC's archive) keeps its projects: Main, mirrored both ways with the sequence's settings so older clients and sync keep working, and other named projects, each a linear history of immutable versions in the portable form (positions parked by photo, SHA-256 of canonical text), stored as sidecars in `.chronos/projects/` and indexed by migration 0009 (`projects`, `project_versions`, `renders.project_id`/`project_version_id`); deletions only on the archive's word, the trash read first; Edit opens only workspace projects: *Open in workspace* (project, proxies), the `workspace-copy` job (stored as 20, desktop only, hash-verified, resumable, space checked), the working state in a folder outside the library, the project button with its state chip and menu (Save version, Sync, History with Compare and Restore, Open, New, Rename, Delete, Remove local copy), push and pull with replay and field-level merge, conflicts only when both sides changed a setting (Keep mine, Take library's, Save both, Later), renders at the home with the settings embedded; Settings › Workspace (folder, sync, kept versions). The server home is phase 5b; originals, local render, clean-up and the rest of Settings › Workspace are phase 5c. |
|
| 2026-10-26 | Owner review 2, R8 (phase 5a: workspace and projects, local home) | §4.4, §5, §7, §12.2, §12.3, §12.6, §12.8, §14.5, §14.6 | A sequence's home (this PC's archive) keeps its projects: Main, mirrored both ways with the sequence's settings so older clients and sync keep working, and other named projects, each a linear history of immutable versions in the portable form (positions parked by photo, SHA-256 of canonical text), stored as sidecars in `.chronos/projects/` and indexed by migration 0009 (`projects`, `project_versions`, `renders.project_id`/`project_version_id`); deletions only on the archive's word, the trash read first; Edit opens only workspace projects: *Open in workspace* (project, proxies), the `workspace-copy` job (stored as 20, desktop only, hash-verified, resumable, space checked), the working state in a folder outside the library, the project button with its state chip and menu (Save version, Sync, History with Compare and Restore, Open, New, Rename, Delete, Remove local copy), push and pull with replay and field-level merge, conflicts only when both sides changed a setting (Keep mine, Take library's, Save both, Later), renders at the home with the settings embedded; Settings › Workspace (folder, sync, kept versions). The server home is phase 5b; originals, local render, clean-up and the rest of Settings › Workspace are phase 5c. |
|
||||||
|
| 2026-11-04 | Owner review 3 (ports) | §12.7, §14.8, §14.9, §15, §19.6 | The public HTTP/HTTPS ports are server settings as well as variables (a variable locks them), applied at once; in a container the listening ports are locked to the template's; the admin panel's Network and TLS shows the container's ports, the public ports and the client address with Copy; clients read an address without scheme or port as port 8443 and report an address that answers as something else, never offering its certificate for trust; the Unraid template and compose gain *Public HTTP port*. |
|
||||||
|
|
||||||
## Appendix A — `CLAUDE.md` content (create verbatim in Phase 0, keep updated)
|
## Appendix A — `CLAUDE.md` content (create verbatim in Phase 0, keep updated)
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,46 @@ commits follow Conventional Commits (release notes are generated from them by `C
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Chronos and the Uploader could not reach a server in a container whose ports are published as other host ports
|
||||||
|
(owner review 3). The admin panel's Settings › Network and TLS listed the container's ports (8080, 8443) as if
|
||||||
|
clients used them. In a container it now shows them read-only as *Container HTTP port* and *Container HTTPS port*,
|
||||||
|
followed by *Public HTTP port* and *Public HTTPS port* (the host ports; empty: the same as the listening ports) and
|
||||||
|
a *Client address* with Copy: exactly what to type in Chronos and in the Uploader. Opened over HTTPS, the client
|
||||||
|
address uses the port the page came through, and when the saved one differs a *Use …* button fills it in as the
|
||||||
|
Public HTTPS port. Saving a Public HTTPS port other than that one asks first, since the panel's link follows it at
|
||||||
|
once.
|
||||||
|
- An address typed without a port (`192.168.1.20`, `nas.local`) now means port 8443, as the placeholder shows;
|
||||||
|
`https://name` alone still means 443 (a reverse proxy), and a typed port is kept. Addresses saved earlier keep their
|
||||||
|
port.
|
||||||
|
- An address that answers but is not a Chronos Server (another service on that port: a web page, a redirect to its
|
||||||
|
sign-in page, a 404 or 401, JSON of another kind) now says *No Chronos server answers at …; check the port*, naming
|
||||||
|
the address with its port. Before, JSON of another kind passed as a server (the Uploader then sent it the
|
||||||
|
password), a 401 read as a wrong password, and another service's self-signed certificate was offered for trust;
|
||||||
|
that certificate is now never offered (redirects of any kind, error pages, JSON errors without Chronos's header and
|
||||||
|
oversized answers included). The HTTP port typed without a scheme (`192.168.1.20:8087`) gives the same message
|
||||||
|
instead of *The server did not answer*. The Uploader's certificate question names the address with its port.
|
||||||
|
- A link-local IPv6 address with a zone (`fe80::1%12`) is refused as an invalid address instead of losing its zone.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- The public ports are server settings: edited in the admin panel and applied at once to LAN discovery and the
|
||||||
|
redirect to HTTPS, or set by `CHRONOS_PUBLIC_HTTP_PORT` / `CHRONOS_PUBLIC_HTTPS_PORT`, which lock them. In a
|
||||||
|
container the listening ports change only through `CHRONOS_HTTP_PORT` / `CHRONOS_HTTPS_PORT`; a port saved for them
|
||||||
|
in `server.json` is ignored, with a warning in the log, and removed at the next save of the settings.
|
||||||
|
- The Unraid template and the compose file have *Public HTTP port* (`CHRONOS_PUBLIC_HTTP_PORT`) next to *Public HTTPS
|
||||||
|
port*; the port descriptions say to enter the same host port there. LAN discovery's tooltip, the template and the
|
||||||
|
user guide say that discovery leaves a container only with network type *Host*: on *Bridge*, type the client
|
||||||
|
address.
|
||||||
|
|
||||||
|
### Upgrade note for Unraid
|
||||||
|
- Edit the container: set *Repository* from `…/chronos-server:nightly` to `…/chronos-server:latest`, and set *Public
|
||||||
|
HTTP port* and *Public HTTPS port* to the host ports the template maps (for example 8087 and 8444), or, after the
|
||||||
|
update, enter them in the admin panel's Settings › Network and TLS. Then connect Chronos and the Uploader to the
|
||||||
|
*Client address* shown there (for example `https://192.168.1.20:8444`).
|
||||||
|
- Network type *Host* (for LAN discovery) ignores the port mappings: the server listens on the host's 8080 and 8443.
|
||||||
|
If another service uses either, add the variable `CHRONOS_HTTP_PORT` or `CHRONOS_HTTPS_PORT` with a free port first,
|
||||||
|
and leave the public ports empty.
|
||||||
|
|
||||||
## [0.1.0-rc.8] — 2026-11-03
|
## [0.1.0-rc.8] — 2026-11-03
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -611,3 +611,16 @@ One line per decision: date · decision · alternative · reason.
|
|||||||
| 2026-11-03 | Workspace texts: the workspace's strings live in the existing Editor, Tooltips, Settings and Errors areas; the home is called "the library" (the server home will name its server), Main is shown in the UI language (it: Principale), and versions carry the bare PC name (`Environment.MachineName`; History strips `chronos@`, `server@`, `workspace@` and `Chronos on`). (Owner review 2, R8.) | A new Workspace area | No new resource files to translate; the wording matches the rest of the desktop. |
|
| 2026-11-03 | Workspace texts: the workspace's strings live in the existing Editor, Tooltips, Settings and Errors areas; the home is called "the library" (the server home will name its server), Main is shown in the UI language (it: Principale), and versions carry the bare PC name (`Environment.MachineName`; History strips `chronos@`, `server@`, `workspace@` and `Chronos on`). (Owner review 2, R8.) | A new Workspace area | No new resource files to translate; the wording matches the rest of the desktop. |
|
||||||
| 2026-11-03 | `ProjectMenuViewModel` reaches the window only through `IWorkspaceUi` (dialogs, `ShowDialogWhenFree`, confirmations, toasts, opening and closing a project). A conflict found by an automatic sync waits for the open dialog and is asked once. (Owner review 2, R8.) | Depend on the shell; replace the open dialog | Its logic is tested without a window, and a background prompt never hides what the user is doing. |
|
| 2026-11-03 | `ProjectMenuViewModel` reaches the window only through `IWorkspaceUi` (dialogs, `ShowDialogWhenFree`, confirmations, toasts, opening and closing a project). A conflict found by an automatic sync waits for the open dialog and is asked once. (Owner review 2, R8.) | Depend on the shell; replace the open dialog | Its logic is tested without a window, and a background prompt never hides what the user is doing. |
|
||||||
| 2026-11-03 | Leases: `LeaseFile.TryAcquire` and `AcquireAsync` take `createDirectory` (default true); the copy's clean-up passes false. `WorkspaceSync.OpenAsync` reads the working state and the media under the project's lease; a lease still busy after the wait is `Errors.Workspace.Busy`. (Owner review 2, R8, fix rounds 1, 2 and 5.) | Always create the folder; read without the lease | A clean-up must never make a removed project folder again, and the editor never reads a half-written working state. |
|
| 2026-11-03 | Leases: `LeaseFile.TryAcquire` and `AcquireAsync` take `createDirectory` (default true); the copy's clean-up passes false. `WorkspaceSync.OpenAsync` reads the working state and the media under the project's lease; a lease still busy after the wait is `Errors.Workspace.Busy`. (Owner review 2, R8, fix rounds 1, 2 and 5.) | Always create the folder; read without the lease | A clean-up must never make a removed project folder again, and the editor never reads a half-written working state. |
|
||||||
|
| 2026-11-04 | Public ports are settings: `PublicHttpPort`/`PublicHttpsPort` in `server.json`, edited in Settings › Network and TLS, locked by `CHRONOS_PUBLIC_HTTP(S)_PORT`, applied at once by setting the shared `ServerOptions` that LAN discovery and the admin redirect read at every use. | Variables only | The owner read the container ports in the panel as the ports to use; the host ports must be settable where the ports are shown, and nothing caches them. |
|
||||||
|
| 2026-11-04 | `ServerSettingsDto` gains `PublicHttpPort`, `PublicHttpsPort` and `InContainer`, appended as optional positional members. In a request a null public port keeps the saved value and 0 clears it; responses send null when unset. | null clears | A client or script of the earlier shape sends no public ports: with null as "clear" every save from it would drop them, or be refused as `setting_locked` when a variable fixes them. |
|
||||||
|
| 2026-11-04 | In a container (`DOTNET_RUNNING_IN_CONTAINER=true`, read in `ServerOptions.Load`; tests set `ServerOptions.InContainer`) the listening ports are locked (listed in `Locked`, `lockedBy` `DOTNET_RUNNING_IN_CONTAINER` unless a `CHRONOS_HTTP(S)_PORT` sets them) and a `server.json` value for them is ignored with a warning at start; the variables still change them. | Keep honouring server.json | The template publishes the default container ports: a port saved from the panel before would leave the container unreachable after a restart. Host networking users who need other ports set the variables. |
|
||||||
|
| 2026-11-04 | Listening ports are validated only when a request changes them. | Always validate | A value the panel cannot change (a container's, the test server's 0) must never block saving the other settings. |
|
||||||
|
| 2026-11-04 | The admin panel's client address is computed in the browser: `https://` + `location.hostname` (IPv6 in brackets) + `:` + the port the page came through when the browser speaks HTTPS to the server itself, else (plain HTTP, only from the server's own machine) the public HTTPS port or HTTPS port (no port when 443); `location.origin` in TLS mode proxy. When the page's HTTPS port is not the saved one (a container's 8443 published as 8444, Public HTTPS port still empty), a *Use 8444* button next to Public HTTPS port fills it in. No other page shows a pairing code or a connect hint, so it appears only in Settings › Network and TLS. | Server-side address | Only the browser knows the host name the LAN uses for the server (an IP, a NAS name); the server sees its container address. |
|
||||||
|
| 2026-11-04 | One address rule for both clients, `Chronos.Protocol.Client.ChronosAddress` (both apps reference Chronos.Protocol, which builds on Linux): no scheme and no port means https on 8443, `https://host` keeps 443, a typed port is kept, a bare IPv6 address is bracketed. Saved addresses carry their scheme, so they keep their port. | A copy per app | The placeholder and the error text say `nas.local:8443`; "192.168.30.23" meant port 443. |
|
||||||
|
| 2026-11-04 | `ChronosClient.GetInfoAsync` throws `NotChronosServerException` when `server/info` is not Chronos's: any 3xx (Chronos never redirects it), any answer that is not JSON whatever its status, more than 1 MB, JSON without a Chronos `ServerInfo` (name, version, API version, lists, limits), or an error without the `X-Chronos-Api` header every Chronos response carries and a Chronos error code. A busy answer (408, 429, 502-504) with JSON or no body cannot tell. On an untrusted certificate it reads `server/info` once more with certificate checks off, no token, no cookies and no redirects, under the same rules, and only a Chronos answer leads to the fingerprint question. Nothing is trusted or stored by that read. | Ask about the fingerprint first | Before, `{}` was accepted as a server (the Uploader then sent the password to it), a 401 read as a wrong password, and the self-signed certificate of another service on port 8443 was offered for trust. |
|
||||||
|
| 2026-11-04 | The not-Chronos error names the normalised address (port included) in new keys `Server.Error.NotChronosAt` and `Uploader.Connect.Error.NotChronosAt`; the old keys stay as they are. | Add {0} to the old keys | The 36 other cultures translate the old keys without the placeholder; changing it would fail the i18n check until they are translated again. |
|
||||||
|
| 2026-11-04 | Saving a public HTTPS port (or clearing it to the listening one) other than both the saved one and the port this page came through over HTTPS asks first (*Send clients to port 8445?*); the server does not check it. | Server-side warning in the log | The HTTPS redirect follows the saved port at once, so a typo would send the panel's link to a dead port or another service's sign-in page; only the browser knows which port really reached the server. Saving other settings never asks. |
|
||||||
|
| 2026-11-04 | `GetInfoAsync`: when TLS fails on an HTTPS address and no certificate was refused (the port speaks plain HTTP: the HTTP port typed without a scheme, `192.168.30.23:8087`), it reads `server/info` over `http://` on the same authority, without credentials; any answer gives `NotChronosServerException` (check the port, the client address), no answer rethrows (unreachable). | Report it as unreachable | The server did answer; the useful advice is the port and the panel's client address. |
|
||||||
|
| 2026-11-04 | In a container, the first save of the settings removes `HttpPort` and `HttpsPort` from `server.json` (also when nothing else changed); the start-up warning says so. | Remove them at load | Load only reads; the panel cannot edit locked ports, so without this the warning came back at every start. |
|
||||||
|
| 2026-11-04 | Host networking: the guide, README and compose comments say the port mappings do nothing there, the server listens on the host's 8080/8443 and `CHRONOS_HTTP_PORT` / `CHRONOS_HTTPS_PORT` move it off ports another service uses (public ports empty). No template entries for them. | Advanced template entries *Listening HTTP/HTTPS port* | On Bridge such an entry would unmap the template's ports; Host users add a variable, which Unraid offers on every container. |
|
||||||
|
| 2026-11-04 | `ChronosAddress` refuses a link-local IPv6 address with a zone index (`fe80::1%12`): *Invalid address*. | Keep the zone as `%25` | `Uri` and the connection would drop the zone, failing later with a less clear error; the LAN address or name works. |
|
||||||
+20
-2
@@ -786,16 +786,23 @@
|
|||||||
<data name="Admin.Sequence.TooManyTags" xml:space="preserve"><value>A sequence has at most 50 tags.</value><comment>long</comment></data>
|
<data name="Admin.Sequence.TooManyTags" xml:space="preserve"><value>A sequence has at most 50 tags.</value><comment>long</comment></data>
|
||||||
<data name="Admin.Sequence.Unrate.Tip" xml:space="preserve"><value>Rated {0} out of 5; choose it again to clear the rating</value></data>
|
<data name="Admin.Sequence.Unrate.Tip" xml:space="preserve"><value>Rated {0} out of 5; choose it again to clear the rating</value></data>
|
||||||
<data name="Admin.Settings.About" xml:space="preserve"><value>About</value></data>
|
<data name="Admin.Settings.About" xml:space="preserve"><value>About</value></data>
|
||||||
|
<data name="Admin.Settings.AddressCopied" xml:space="preserve"><value>Address copied.</value></data>
|
||||||
<data name="Admin.Settings.AuditRetentionDays" xml:space="preserve"><value>Keep audit (days)</value></data>
|
<data name="Admin.Settings.AuditRetentionDays" xml:space="preserve"><value>Keep audit (days)</value></data>
|
||||||
<data name="Admin.Settings.AuditRetentionDays.Tip" xml:space="preserve"><value>Age limit of the Audit log clean-up schedule: older audit entries are deleted; 0: kept forever</value></data>
|
<data name="Admin.Settings.AuditRetentionDays.Tip" xml:space="preserve"><value>Age limit of the Audit log clean-up schedule: older audit entries are deleted; 0: kept forever</value></data>
|
||||||
<data name="Admin.Settings.ChunkSizeMib" xml:space="preserve"><value>Chunk size (MiB)</value></data>
|
<data name="Admin.Settings.ChunkSizeMib" xml:space="preserve"><value>Chunk size (MiB)</value></data>
|
||||||
<data name="Admin.Settings.ChunkSizeMib.Tip" xml:space="preserve"><value>Size of each upload chunk; smaller chunks resume faster on poor links</value></data>
|
<data name="Admin.Settings.ChunkSizeMib.Tip" xml:space="preserve"><value>Size of each upload chunk; smaller chunks resume faster on poor links</value></data>
|
||||||
|
<data name="Admin.Settings.ClientAddress" xml:space="preserve"><value>Client address</value></data>
|
||||||
|
<data name="Admin.Settings.ClientAddress.Tip" xml:space="preserve"><value>Type this in Chronos and in the Uploader to connect to this server</value></data>
|
||||||
<data name="Admin.Settings.ConsoleLogLevel" xml:space="preserve"><value>Console level</value></data>
|
<data name="Admin.Settings.ConsoleLogLevel" xml:space="preserve"><value>Console level</value></data>
|
||||||
<data name="Admin.Settings.ConsoleLogLevel.Tip" xml:space="preserve"><value>Least severe level written to the console, the container's log</value></data>
|
<data name="Admin.Settings.ConsoleLogLevel.Tip" xml:space="preserve"><value>Least severe level written to the console, the container's log</value></data>
|
||||||
|
<data name="Admin.Settings.ContainerHttpPort" xml:space="preserve"><value>Container HTTP port</value></data>
|
||||||
|
<data name="Admin.Settings.ContainerHttpsPort" xml:space="preserve"><value>Container HTTPS port</value></data>
|
||||||
|
<data name="Admin.Settings.ContainerPort.Tip" xml:space="preserve"><value>Port inside the container, fixed by its template; the host maps it to the port clients use, which goes in the public port below</value></data>
|
||||||
|
<data name="Admin.Settings.CopyAddress.Tip" xml:space="preserve"><value>Copy the client address</value></data>
|
||||||
<data name="Admin.Settings.DiagnosticsLogMb" xml:space="preserve"><value>Diagnostics logs (MB)</value></data>
|
<data name="Admin.Settings.DiagnosticsLogMb" xml:space="preserve"><value>Diagnostics logs (MB)</value></data>
|
||||||
<data name="Admin.Settings.DiagnosticsLogMb.Tip" xml:space="preserve"><value>How much of the end of each log file the diagnostics zip includes</value></data>
|
<data name="Admin.Settings.DiagnosticsLogMb.Tip" xml:space="preserve"><value>How much of the end of each log file the diagnostics zip includes</value></data>
|
||||||
<data name="Admin.Settings.Discovery" xml:space="preserve"><value>LAN discovery</value></data>
|
<data name="Admin.Settings.Discovery" xml:space="preserve"><value>LAN discovery</value></data>
|
||||||
<data name="Admin.Settings.Discovery.Tip" xml:space="preserve"><value>Announce this server on the local network so clients find it</value></data>
|
<data name="Admin.Settings.Discovery.Tip" xml:space="preserve"><value>Announce this server on the local network so clients find it; a container needs network type Host (in Bridge mode the announcements stay inside Docker: type the client address)</value></data>
|
||||||
<data name="Admin.Settings.Fingerprint" xml:space="preserve"><value>Fingerprint</value></data>
|
<data name="Admin.Settings.Fingerprint" xml:space="preserve"><value>Fingerprint</value></data>
|
||||||
<data name="Admin.Settings.Fingerprint.Tip" xml:space="preserve"><value>SHA-256 of the certificate; clients ask the user to compare it once</value></data>
|
<data name="Admin.Settings.Fingerprint.Tip" xml:space="preserve"><value>SHA-256 of the certificate; clients ask the user to compare it once</value></data>
|
||||||
<data name="Admin.Settings.HttpPort" xml:space="preserve"><value>HTTP port</value></data>
|
<data name="Admin.Settings.HttpPort" xml:space="preserve"><value>HTTP port</value></data>
|
||||||
@@ -833,6 +840,11 @@
|
|||||||
<data name="Admin.Settings.Parallelism.Tip" xml:space="preserve"><value>Photos the running job processes at once; jobs run one at a time</value></data>
|
<data name="Admin.Settings.Parallelism.Tip" xml:space="preserve"><value>Photos the running job processes at once; jobs run one at a time</value></data>
|
||||||
<data name="Admin.Settings.PemMissing" xml:space="preserve"><value>The PEM file was not found; enter its full path on the server.</value><comment>long</comment></data>
|
<data name="Admin.Settings.PemMissing" xml:space="preserve"><value>The PEM file was not found; enter its full path on the server.</value><comment>long</comment></data>
|
||||||
<data name="Admin.Settings.PemOnly.Tip" xml:space="preserve"><value>Used only in Own certificate mode</value></data>
|
<data name="Admin.Settings.PemOnly.Tip" xml:space="preserve"><value>Used only in Own certificate mode</value></data>
|
||||||
|
<data name="Admin.Settings.PortChangeBody" xml:space="preserve"><value>This page came through port {0}. The panel's link and LAN discovery move to the new port at once; if it is wrong, open the panel on port {0} to fix it.</value><comment>long</comment></data>
|
||||||
|
<data name="Admin.Settings.PortChangeConfirm" xml:space="preserve"><value>Save port</value></data>
|
||||||
|
<data name="Admin.Settings.PortChangeConfirm.Tip" xml:space="preserve"><value>Save {0} as the Public HTTPS port; clients and the HTTPS redirect use it at once</value></data>
|
||||||
|
<data name="Admin.Settings.PortChangeKeep.Tip" xml:space="preserve"><value>Back to the form, nothing saved</value></data>
|
||||||
|
<data name="Admin.Settings.PortChangeTitle" xml:space="preserve"><value>Send clients to port {0}?</value></data>
|
||||||
<data name="Admin.Settings.Priority.High" xml:space="preserve"><value>High</value></data>
|
<data name="Admin.Settings.Priority.High" xml:space="preserve"><value>High</value></data>
|
||||||
<data name="Admin.Settings.Priority.Low" xml:space="preserve"><value>Low</value></data>
|
<data name="Admin.Settings.Priority.Low" xml:space="preserve"><value>Low</value></data>
|
||||||
<data name="Admin.Settings.Priority.Normal" xml:space="preserve"><value>Normal</value></data>
|
<data name="Admin.Settings.Priority.Normal" xml:space="preserve"><value>Normal</value></data>
|
||||||
@@ -840,8 +852,12 @@
|
|||||||
<data name="Admin.Settings.PriorityQueue.Tip" xml:space="preserve"><value>On: a job of a higher level pauses the running one without asking, and that one resumes by itself afterwards. Off: jobs wait their turn</value></data>
|
<data name="Admin.Settings.PriorityQueue.Tip" xml:space="preserve"><value>On: a job of a higher level pauses the running one without asking, and that one resumes by itself afterwards. Off: jobs wait their turn</value></data>
|
||||||
<data name="Admin.Settings.ProxyBypassed" xml:space="preserve"><value>Not via proxy</value></data>
|
<data name="Admin.Settings.ProxyBypassed" xml:space="preserve"><value>Not via proxy</value></data>
|
||||||
<data name="Admin.Settings.ProxyBypassed.Tip" xml:space="preserve"><value>TLS mode is Reverse proxy, but this page did not come through a trusted proxy over HTTPS. Open it through your proxy, or add the proxy's address to CHRONOS_TRUSTED_PROXIES.</value></data>
|
<data name="Admin.Settings.ProxyBypassed.Tip" xml:space="preserve"><value>TLS mode is Reverse proxy, but this page did not come through a trusted proxy over HTTPS. Open it through your proxy, or add the proxy's address to CHRONOS_TRUSTED_PROXIES.</value></data>
|
||||||
|
<data name="Admin.Settings.PublicHttpPort" xml:space="preserve"><value>Public HTTP port</value></data>
|
||||||
|
<data name="Admin.Settings.PublicHttpPort.Tip" xml:space="preserve"><value>Host port clients use for HTTP when it differs from the HTTP port, as a container maps it; empty: the HTTP port</value></data>
|
||||||
|
<data name="Admin.Settings.PublicHttpsPort" xml:space="preserve"><value>Public HTTPS port</value></data>
|
||||||
|
<data name="Admin.Settings.PublicHttpsPort.Tip" xml:space="preserve"><value>Host port clients use for HTTPS when it differs from the HTTPS port, as a container maps it; empty: the HTTPS port</value></data>
|
||||||
<data name="Admin.Settings.Restart" xml:space="preserve"><value>Restart required</value></data>
|
<data name="Admin.Settings.Restart" xml:space="preserve"><value>Restart required</value></data>
|
||||||
<data name="Admin.Settings.Restart.Tip" xml:space="preserve"><value>Saved ports, TLS or chunk size apply after a restart</value></data>
|
<data name="Admin.Settings.Restart.Tip" xml:space="preserve"><value>Saved listening ports, TLS or chunk size apply after a restart</value></data>
|
||||||
<data name="Admin.Settings.Rotation.Daily" xml:space="preserve"><value>Daily</value></data>
|
<data name="Admin.Settings.Rotation.Daily" xml:space="preserve"><value>Daily</value></data>
|
||||||
<data name="Admin.Settings.Rotation.Hourly" xml:space="preserve"><value>Hourly</value></data>
|
<data name="Admin.Settings.Rotation.Hourly" xml:space="preserve"><value>Hourly</value></data>
|
||||||
<data name="Admin.Settings.Server" xml:space="preserve"><value>Server</value></data>
|
<data name="Admin.Settings.Server" xml:space="preserve"><value>Server</value></data>
|
||||||
@@ -860,6 +876,8 @@
|
|||||||
<data name="Admin.Settings.TokenLifetimeDays.Tip" xml:space="preserve"><value>Days a client stays signed in without being used</value></data>
|
<data name="Admin.Settings.TokenLifetimeDays.Tip" xml:space="preserve"><value>Days a client stays signed in without being used</value></data>
|
||||||
<data name="Admin.Settings.UploadRetentionHours" xml:space="preserve"><value>Abandoned after (h)</value></data>
|
<data name="Admin.Settings.UploadRetentionHours" xml:space="preserve"><value>Abandoned after (h)</value></data>
|
||||||
<data name="Admin.Settings.UploadRetentionHours.Tip" xml:space="preserve"><value>Hours after which unfinished uploads are discarded</value></data>
|
<data name="Admin.Settings.UploadRetentionHours.Tip" xml:space="preserve"><value>Hours after which unfinished uploads are discarded</value></data>
|
||||||
|
<data name="Admin.Settings.UsePagePort" xml:space="preserve"><value>Use {0}</value></data>
|
||||||
|
<data name="Admin.Settings.UsePagePort.Tip" xml:space="preserve"><value>This page came through port {0}, so clients reach the server there: fill it in as the Public HTTPS port, then save, and discovery and the HTTPS redirect follow</value></data>
|
||||||
<data name="Admin.SignOut" xml:space="preserve"><value>Sign out</value></data>
|
<data name="Admin.SignOut" xml:space="preserve"><value>Sign out</value></data>
|
||||||
<data name="Admin.SignOut.Tip" xml:space="preserve"><value>Sign out of the admin panel</value></data>
|
<data name="Admin.SignOut.Tip" xml:space="preserve"><value>Sign out of the admin panel</value></data>
|
||||||
<data name="Admin.Theme.Tip" xml:space="preserve"><value>Switch between light and dark</value></data>
|
<data name="Admin.Theme.Tip" xml:space="preserve"><value>Switch between light and dark</value></data>
|
||||||
|
|||||||
@@ -75,6 +75,7 @@
|
|||||||
<data name="Server.Error.LastAdmin" xml:space="preserve"><value>The last administrator cannot be removed or disabled.</value><comment>long</comment></data>
|
<data name="Server.Error.LastAdmin" xml:space="preserve"><value>The last administrator cannot be removed or disabled.</value><comment>long</comment></data>
|
||||||
<data name="Server.Error.MethodNotAllowed" xml:space="preserve"><value>This method is not allowed here.</value><comment>long</comment></data>
|
<data name="Server.Error.MethodNotAllowed" xml:space="preserve"><value>This method is not allowed here.</value><comment>long</comment></data>
|
||||||
<data name="Server.Error.NestedTarget" xml:space="preserve"><value>A new folder would lie inside the folder of another sequence.</value><comment>long</comment></data>
|
<data name="Server.Error.NestedTarget" xml:space="preserve"><value>A new folder would lie inside the folder of another sequence.</value><comment>long</comment></data>
|
||||||
|
<data name="Server.Error.NotChronosAt" xml:space="preserve"><value>No Chronos server answers at {0}; check the port (the admin panel's Settings › Network and TLS shows the client address).</value><comment>long</comment></data>
|
||||||
<data name="Server.Error.NotEnoughSpace" xml:space="preserve"><value>The archive's volume lacks the space the conversion needs.</value><comment>long</comment></data>
|
<data name="Server.Error.NotEnoughSpace" xml:space="preserve"><value>The archive's volume lacks the space the conversion needs.</value><comment>long</comment></data>
|
||||||
<data name="Server.Error.NotFound" xml:space="preserve"><value>Not found.</value><comment>long</comment></data>
|
<data name="Server.Error.NotFound" xml:space="preserve"><value>Not found.</value><comment>long</comment></data>
|
||||||
<data name="Server.Error.NotChronos" xml:space="preserve"><value>That address is not a Chronos Server.</value><comment>long</comment></data>
|
<data name="Server.Error.NotChronos" xml:space="preserve"><value>That address is not a Chronos Server.</value><comment>long</comment></data>
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
<data name="Uploader.Connect.Error.Failed" xml:space="preserve"><value>The server reported an error.</value><comment>long</comment></data>
|
<data name="Uploader.Connect.Error.Failed" xml:space="preserve"><value>The server reported an error.</value><comment>long</comment></data>
|
||||||
<data name="Uploader.Connect.Error.InvalidAddress" xml:space="preserve"><value>Enter an address such as https://nas.local:8443.</value><comment>long</comment></data>
|
<data name="Uploader.Connect.Error.InvalidAddress" xml:space="preserve"><value>Enter an address such as https://nas.local:8443.</value><comment>long</comment></data>
|
||||||
<data name="Uploader.Connect.Error.NotChronos" xml:space="preserve"><value>This address is not a Chronos Server.</value><comment>long</comment></data>
|
<data name="Uploader.Connect.Error.NotChronos" xml:space="preserve"><value>This address is not a Chronos Server.</value><comment>long</comment></data>
|
||||||
|
<data name="Uploader.Connect.Error.NotChronosAt" xml:space="preserve"><value>No Chronos server answers at {0}; check the port (the admin panel's Settings › Network and TLS shows the client address).</value><comment>long</comment></data>
|
||||||
<data name="Uploader.Connect.Error.Unreachable" xml:space="preserve"><value>The server did not answer.</value><comment>long</comment></data>
|
<data name="Uploader.Connect.Error.Unreachable" xml:space="preserve"><value>The server did not answer.</value><comment>long</comment></data>
|
||||||
<data name="Uploader.Connect.Error.Untrusted" xml:space="preserve"><value>The server certificate was not trusted.</value><comment>long</comment></data>
|
<data name="Uploader.Connect.Error.Untrusted" xml:space="preserve"><value>The server certificate was not trusted.</value><comment>long</comment></data>
|
||||||
<data name="Uploader.Connect.Found" xml:space="preserve"><value>Found</value></data>
|
<data name="Uploader.Connect.Found" xml:space="preserve"><value>Found</value></data>
|
||||||
|
|||||||
+20
-2
@@ -779,16 +779,23 @@
|
|||||||
<data name="Admin.Sequence.TooManyTags" xml:space="preserve"><value>Una sequenza ha al massimo 50 tag.</value><comment>long</comment></data>
|
<data name="Admin.Sequence.TooManyTags" xml:space="preserve"><value>Una sequenza ha al massimo 50 tag.</value><comment>long</comment></data>
|
||||||
<data name="Admin.Sequence.Unrate.Tip" xml:space="preserve"><value>Voto {0} su 5; sceglilo di nuovo per togliere il voto</value></data>
|
<data name="Admin.Sequence.Unrate.Tip" xml:space="preserve"><value>Voto {0} su 5; sceglilo di nuovo per togliere il voto</value></data>
|
||||||
<data name="Admin.Settings.About" xml:space="preserve"><value>Informazioni</value></data>
|
<data name="Admin.Settings.About" xml:space="preserve"><value>Informazioni</value></data>
|
||||||
|
<data name="Admin.Settings.AddressCopied" xml:space="preserve"><value>Indirizzo copiato.</value></data>
|
||||||
<data name="Admin.Settings.AuditRetentionDays" xml:space="preserve"><value>Conserva controllo (giorni)</value></data>
|
<data name="Admin.Settings.AuditRetentionDays" xml:space="preserve"><value>Conserva controllo (giorni)</value></data>
|
||||||
<data name="Admin.Settings.AuditRetentionDays.Tip" xml:space="preserve"><value>Limite di età della pianificazione Pulizia registro controllo: le voci più vecchie vengono eliminate; 0: conservate per sempre</value></data>
|
<data name="Admin.Settings.AuditRetentionDays.Tip" xml:space="preserve"><value>Limite di età della pianificazione Pulizia registro controllo: le voci più vecchie vengono eliminate; 0: conservate per sempre</value></data>
|
||||||
<data name="Admin.Settings.ChunkSizeMib" xml:space="preserve"><value>Dimensione blocco (MiB)</value></data>
|
<data name="Admin.Settings.ChunkSizeMib" xml:space="preserve"><value>Dimensione blocco (MiB)</value></data>
|
||||||
<data name="Admin.Settings.ChunkSizeMib.Tip" xml:space="preserve"><value>Dimensione di ogni blocco di caricamento; blocchi piccoli riprendono prima su linee lente</value></data>
|
<data name="Admin.Settings.ChunkSizeMib.Tip" xml:space="preserve"><value>Dimensione di ogni blocco di caricamento; blocchi piccoli riprendono prima su linee lente</value></data>
|
||||||
|
<data name="Admin.Settings.ClientAddress" xml:space="preserve"><value>Indirizzo client</value></data>
|
||||||
|
<data name="Admin.Settings.ClientAddress.Tip" xml:space="preserve"><value>Da inserire in Chronos e nell'Uploader per collegarsi a questo server</value></data>
|
||||||
<data name="Admin.Settings.ConsoleLogLevel" xml:space="preserve"><value>Livello console</value></data>
|
<data name="Admin.Settings.ConsoleLogLevel" xml:space="preserve"><value>Livello console</value></data>
|
||||||
<data name="Admin.Settings.ConsoleLogLevel.Tip" xml:space="preserve"><value>Livello minimo scritto nella console, il log del container</value></data>
|
<data name="Admin.Settings.ConsoleLogLevel.Tip" xml:space="preserve"><value>Livello minimo scritto nella console, il log del container</value></data>
|
||||||
|
<data name="Admin.Settings.ContainerHttpPort" xml:space="preserve"><value>Porta HTTP interna</value></data>
|
||||||
|
<data name="Admin.Settings.ContainerHttpsPort" xml:space="preserve"><value>Porta HTTPS interna</value></data>
|
||||||
|
<data name="Admin.Settings.ContainerPort.Tip" xml:space="preserve"><value>Porta dentro il container, fissata dal suo template; l'host la mappa sulla porta usata dai client, da inserire come porta pubblica qui sotto</value></data>
|
||||||
|
<data name="Admin.Settings.CopyAddress.Tip" xml:space="preserve"><value>Copia l'indirizzo client</value></data>
|
||||||
<data name="Admin.Settings.DiagnosticsLogMb" xml:space="preserve"><value>Log diagnostica (MB)</value></data>
|
<data name="Admin.Settings.DiagnosticsLogMb" xml:space="preserve"><value>Log diagnostica (MB)</value></data>
|
||||||
<data name="Admin.Settings.DiagnosticsLogMb.Tip" xml:space="preserve"><value>Quanta parte finale di ogni file di log include lo zip di diagnostica</value></data>
|
<data name="Admin.Settings.DiagnosticsLogMb.Tip" xml:space="preserve"><value>Quanta parte finale di ogni file di log include lo zip di diagnostica</value></data>
|
||||||
<data name="Admin.Settings.Discovery" xml:space="preserve"><value>Rilevamento LAN</value></data>
|
<data name="Admin.Settings.Discovery" xml:space="preserve"><value>Rilevamento LAN</value></data>
|
||||||
<data name="Admin.Settings.Discovery.Tip" xml:space="preserve"><value>Annuncia questo server nella rete locale così che i client lo trovino</value></data>
|
<data name="Admin.Settings.Discovery.Tip" xml:space="preserve"><value>Annuncia questo server nella rete locale così che i client lo trovino; in un container serve il tipo di rete Host (in Bridge gli annunci restano dentro Docker: inserisci l'indirizzo client)</value></data>
|
||||||
<data name="Admin.Settings.Fingerprint" xml:space="preserve"><value>Impronta</value></data>
|
<data name="Admin.Settings.Fingerprint" xml:space="preserve"><value>Impronta</value></data>
|
||||||
<data name="Admin.Settings.Fingerprint.Tip" xml:space="preserve"><value>SHA-256 del certificato; i client chiedono all'utente di confrontarlo una volta</value></data>
|
<data name="Admin.Settings.Fingerprint.Tip" xml:space="preserve"><value>SHA-256 del certificato; i client chiedono all'utente di confrontarlo una volta</value></data>
|
||||||
<data name="Admin.Settings.HttpPort" xml:space="preserve"><value>Porta HTTP</value></data>
|
<data name="Admin.Settings.HttpPort" xml:space="preserve"><value>Porta HTTP</value></data>
|
||||||
@@ -826,6 +833,11 @@
|
|||||||
<data name="Admin.Settings.Parallelism.Tip" xml:space="preserve"><value>Foto che l'attività in corso elabora insieme; le attività girano una alla volta</value></data>
|
<data name="Admin.Settings.Parallelism.Tip" xml:space="preserve"><value>Foto che l'attività in corso elabora insieme; le attività girano una alla volta</value></data>
|
||||||
<data name="Admin.Settings.PemMissing" xml:space="preserve"><value>File PEM non trovato; inserisci il percorso completo sul server.</value></data>
|
<data name="Admin.Settings.PemMissing" xml:space="preserve"><value>File PEM non trovato; inserisci il percorso completo sul server.</value></data>
|
||||||
<data name="Admin.Settings.PemOnly.Tip" xml:space="preserve"><value>Usato solo in modalità Certificato proprio</value></data>
|
<data name="Admin.Settings.PemOnly.Tip" xml:space="preserve"><value>Usato solo in modalità Certificato proprio</value></data>
|
||||||
|
<data name="Admin.Settings.PortChangeBody" xml:space="preserve"><value>Questa pagina è arrivata dalla porta {0}. Il collegamento al pannello e il rilevamento LAN passano subito alla nuova porta; se è sbagliata, apri il pannello sulla porta {0} per correggerla.</value></data>
|
||||||
|
<data name="Admin.Settings.PortChangeConfirm" xml:space="preserve"><value>Salva porta</value></data>
|
||||||
|
<data name="Admin.Settings.PortChangeConfirm.Tip" xml:space="preserve"><value>Salva {0} come porta HTTPS pubblica; i client e il reindirizzamento HTTPS la usano subito</value></data>
|
||||||
|
<data name="Admin.Settings.PortChangeKeep.Tip" xml:space="preserve"><value>Torna al modulo senza salvare</value></data>
|
||||||
|
<data name="Admin.Settings.PortChangeTitle" xml:space="preserve"><value>Mandare i client alla porta {0}?</value></data>
|
||||||
<data name="Admin.Settings.Priority.High" xml:space="preserve"><value>Alta</value></data>
|
<data name="Admin.Settings.Priority.High" xml:space="preserve"><value>Alta</value></data>
|
||||||
<data name="Admin.Settings.Priority.Low" xml:space="preserve"><value>Bassa</value></data>
|
<data name="Admin.Settings.Priority.Low" xml:space="preserve"><value>Bassa</value></data>
|
||||||
<data name="Admin.Settings.Priority.Normal" xml:space="preserve"><value>Normale</value></data>
|
<data name="Admin.Settings.Priority.Normal" xml:space="preserve"><value>Normale</value></data>
|
||||||
@@ -833,8 +845,12 @@
|
|||||||
<data name="Admin.Settings.PriorityQueue.Tip" xml:space="preserve"><value>Attiva: un'attività di livello più alto mette in pausa quella in corso senza chiedere, e quella riprende da sola dopo. Disattiva: le attività aspettano il loro turno</value></data>
|
<data name="Admin.Settings.PriorityQueue.Tip" xml:space="preserve"><value>Attiva: un'attività di livello più alto mette in pausa quella in corso senza chiedere, e quella riprende da sola dopo. Disattiva: le attività aspettano il loro turno</value></data>
|
||||||
<data name="Admin.Settings.ProxyBypassed" xml:space="preserve"><value>Senza proxy</value></data>
|
<data name="Admin.Settings.ProxyBypassed" xml:space="preserve"><value>Senza proxy</value></data>
|
||||||
<data name="Admin.Settings.ProxyBypassed.Tip" xml:space="preserve"><value>La modalità TLS è Reverse proxy, ma questa pagina non è arrivata da un proxy attendibile in HTTPS. Aprila tramite il proxy o aggiungi l'indirizzo del proxy a CHRONOS_TRUSTED_PROXIES.</value></data>
|
<data name="Admin.Settings.ProxyBypassed.Tip" xml:space="preserve"><value>La modalità TLS è Reverse proxy, ma questa pagina non è arrivata da un proxy attendibile in HTTPS. Aprila tramite il proxy o aggiungi l'indirizzo del proxy a CHRONOS_TRUSTED_PROXIES.</value></data>
|
||||||
|
<data name="Admin.Settings.PublicHttpPort" xml:space="preserve"><value>Porta HTTP pubblica</value></data>
|
||||||
|
<data name="Admin.Settings.PublicHttpPort.Tip" xml:space="preserve"><value>Porta dell'host che i client usano per HTTP quando è diversa dalla porta HTTP, come la mappa un container; vuota: la porta HTTP</value></data>
|
||||||
|
<data name="Admin.Settings.PublicHttpsPort" xml:space="preserve"><value>Porta HTTPS pubblica</value></data>
|
||||||
|
<data name="Admin.Settings.PublicHttpsPort.Tip" xml:space="preserve"><value>Porta dell'host che i client usano per HTTPS quando è diversa dalla porta HTTPS, come la mappa un container; vuota: la porta HTTPS</value></data>
|
||||||
<data name="Admin.Settings.Restart" xml:space="preserve"><value>Riavvio richiesto</value></data>
|
<data name="Admin.Settings.Restart" xml:space="preserve"><value>Riavvio richiesto</value></data>
|
||||||
<data name="Admin.Settings.Restart.Tip" xml:space="preserve"><value>Porte, TLS o dimensione blocchi salvati valgono dopo un riavvio</value></data>
|
<data name="Admin.Settings.Restart.Tip" xml:space="preserve"><value>Porte di ascolto, TLS o dimensione blocchi salvati valgono dopo un riavvio</value></data>
|
||||||
<data name="Admin.Settings.Rotation.Daily" xml:space="preserve"><value>Giornaliera</value></data>
|
<data name="Admin.Settings.Rotation.Daily" xml:space="preserve"><value>Giornaliera</value></data>
|
||||||
<data name="Admin.Settings.Rotation.Hourly" xml:space="preserve"><value>Oraria</value></data>
|
<data name="Admin.Settings.Rotation.Hourly" xml:space="preserve"><value>Oraria</value></data>
|
||||||
<data name="Admin.Settings.Server" xml:space="preserve"><value>Server</value></data>
|
<data name="Admin.Settings.Server" xml:space="preserve"><value>Server</value></data>
|
||||||
@@ -853,6 +869,8 @@
|
|||||||
<data name="Admin.Settings.TokenLifetimeDays.Tip" xml:space="preserve"><value>Giorni in cui un client resta connesso senza essere usato</value></data>
|
<data name="Admin.Settings.TokenLifetimeDays.Tip" xml:space="preserve"><value>Giorni in cui un client resta connesso senza essere usato</value></data>
|
||||||
<data name="Admin.Settings.UploadRetentionHours" xml:space="preserve"><value>Abbandono dopo (h)</value></data>
|
<data name="Admin.Settings.UploadRetentionHours" xml:space="preserve"><value>Abbandono dopo (h)</value></data>
|
||||||
<data name="Admin.Settings.UploadRetentionHours.Tip" xml:space="preserve"><value>Ore dopo le quali i caricamenti incompleti vengono scartati</value></data>
|
<data name="Admin.Settings.UploadRetentionHours.Tip" xml:space="preserve"><value>Ore dopo le quali i caricamenti incompleti vengono scartati</value></data>
|
||||||
|
<data name="Admin.Settings.UsePagePort" xml:space="preserve"><value>Usa {0}</value></data>
|
||||||
|
<data name="Admin.Settings.UsePagePort.Tip" xml:space="preserve"><value>Questa pagina è arrivata dalla porta {0}, quindi i client raggiungono il server lì: inseriscila come porta HTTPS pubblica e salva, così il rilevamento LAN e il reindirizzamento HTTPS la seguono</value></data>
|
||||||
<data name="Admin.SignOut" xml:space="preserve"><value>Esci</value></data>
|
<data name="Admin.SignOut" xml:space="preserve"><value>Esci</value></data>
|
||||||
<data name="Admin.SignOut.Tip" xml:space="preserve"><value>Esci dal pannello di amministrazione</value></data>
|
<data name="Admin.SignOut.Tip" xml:space="preserve"><value>Esci dal pannello di amministrazione</value></data>
|
||||||
<data name="Admin.Theme.Tip" xml:space="preserve"><value>Alterna tema chiaro e scuro</value></data>
|
<data name="Admin.Theme.Tip" xml:space="preserve"><value>Alterna tema chiaro e scuro</value></data>
|
||||||
|
|||||||
@@ -73,6 +73,7 @@
|
|||||||
<data name="Server.Error.LastAdmin" xml:space="preserve"><value>L'ultimo amministratore non può essere rimosso o disattivato.</value></data>
|
<data name="Server.Error.LastAdmin" xml:space="preserve"><value>L'ultimo amministratore non può essere rimosso o disattivato.</value></data>
|
||||||
<data name="Server.Error.MethodNotAllowed" xml:space="preserve"><value>Metodo non consentito qui.</value></data>
|
<data name="Server.Error.MethodNotAllowed" xml:space="preserve"><value>Metodo non consentito qui.</value></data>
|
||||||
<data name="Server.Error.NestedTarget" xml:space="preserve"><value>Una nuova cartella finirebbe dentro la cartella di un'altra sequenza.</value></data>
|
<data name="Server.Error.NestedTarget" xml:space="preserve"><value>Una nuova cartella finirebbe dentro la cartella di un'altra sequenza.</value></data>
|
||||||
|
<data name="Server.Error.NotChronosAt" xml:space="preserve"><value>Nessun server Chronos risponde a {0}; controlla la porta (l'indirizzo client è nel pannello di amministrazione, Impostazioni › Rete e TLS).</value></data>
|
||||||
<data name="Server.Error.NotEnoughSpace" xml:space="preserve"><value>Il volume dell'archivio non ha lo spazio che serve alla conversione.</value></data>
|
<data name="Server.Error.NotEnoughSpace" xml:space="preserve"><value>Il volume dell'archivio non ha lo spazio che serve alla conversione.</value></data>
|
||||||
<data name="Server.Error.NotFound" xml:space="preserve"><value>Non trovato.</value></data>
|
<data name="Server.Error.NotFound" xml:space="preserve"><value>Non trovato.</value></data>
|
||||||
<data name="Server.Error.NotChronos" xml:space="preserve"><value>Questo indirizzo non è un Chronos Server.</value></data>
|
<data name="Server.Error.NotChronos" xml:space="preserve"><value>Questo indirizzo non è un Chronos Server.</value></data>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
<data name="Uploader.Connect.Error.Failed" xml:space="preserve"><value>Il server ha segnalato un errore.</value></data>
|
<data name="Uploader.Connect.Error.Failed" xml:space="preserve"><value>Il server ha segnalato un errore.</value></data>
|
||||||
<data name="Uploader.Connect.Error.InvalidAddress" xml:space="preserve"><value>Inserisci un indirizzo come https://nas.local:8443.</value></data>
|
<data name="Uploader.Connect.Error.InvalidAddress" xml:space="preserve"><value>Inserisci un indirizzo come https://nas.local:8443.</value></data>
|
||||||
<data name="Uploader.Connect.Error.NotChronos" xml:space="preserve"><value>Questo indirizzo non è un Chronos Server.</value></data>
|
<data name="Uploader.Connect.Error.NotChronos" xml:space="preserve"><value>Questo indirizzo non è un Chronos Server.</value></data>
|
||||||
|
<data name="Uploader.Connect.Error.NotChronosAt" xml:space="preserve"><value>Nessun server Chronos risponde a {0}; controlla la porta (l'indirizzo client è nel pannello di amministrazione, Impostazioni › Rete e TLS).</value></data>
|
||||||
<data name="Uploader.Connect.Error.Unreachable" xml:space="preserve"><value>Il server non ha risposto.</value></data>
|
<data name="Uploader.Connect.Error.Unreachable" xml:space="preserve"><value>Il server non ha risposto.</value></data>
|
||||||
<data name="Uploader.Connect.Error.Untrusted" xml:space="preserve"><value>Il certificato del server non è stato accettato.</value></data>
|
<data name="Uploader.Connect.Error.Untrusted" xml:space="preserve"><value>Il certificato del server non è stato accettato.</value></data>
|
||||||
<data name="Uploader.Connect.Found" xml:space="preserve"><value>Trovati</value></data>
|
<data name="Uploader.Connect.Found" xml:space="preserve"><value>Trovati</value></data>
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ public sealed class ServerViewModel : SectionViewModel
|
|||||||
Shell.Settings.Encoders.CollectionChanged += OnEncodersChanged;
|
Shell.Settings.Encoders.CollectionChanged += OnEncodersChanged;
|
||||||
Sync.Attach();
|
Sync.Attach();
|
||||||
await _session.RestoreAsync();
|
await _session.RestoreAsync();
|
||||||
if (_session.Flow.Error is not ConnectError.None and var error && !_session.IsConnected) ErrorText = ServerSession.ErrorText(error);
|
if (_session.Flow.Error is not ConnectError.None and var error && !_session.IsConnected) ErrorText = ServerSession.ErrorText(error, _session.Flow.Address);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
@@ -253,7 +253,7 @@ public sealed class ServerViewModel : SectionViewModel
|
|||||||
Address = ServerAddress.Display(Session.SavedAddress);
|
Address = ServerAddress.Display(Session.SavedAddress);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Session.Flow.Error is not ConnectError.None and var error) ErrorText = ServerSession.ErrorText(error);
|
if (Session.Flow.Error is not ConnectError.None and var error) ErrorText = ServerSession.ErrorText(error, Session.Flow.Address);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SignOutAsync()
|
private async Task SignOutAsync()
|
||||||
|
|||||||
@@ -269,6 +269,7 @@ public sealed class ConnectFlow(IServerApiFactory factory, ITrustStore trust) :
|
|||||||
internal static ConnectError? Classify(Exception ex, CancellationToken ct) => ex switch
|
internal static ConnectError? Classify(Exception ex, CancellationToken ct) => ex switch
|
||||||
{
|
{
|
||||||
UntrustedCertificateException => ConnectError.Untrusted,
|
UntrustedCertificateException => ConnectError.Untrusted,
|
||||||
|
NotChronosServerException => ConnectError.NotChronos,
|
||||||
ChronosApiException { Status: HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden } => ConnectError.BadCredentials,
|
ChronosApiException { Status: HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden } => ConnectError.BadCredentials,
|
||||||
ChronosApiException { Status: HttpStatusCode.NotFound } => ConnectError.NotChronos,
|
ChronosApiException { Status: HttpStatusCode.NotFound } => ConnectError.NotChronos,
|
||||||
ChronosApiException api when api.IsTransient => ConnectError.Unreachable,
|
ChronosApiException api when api.IsTransient => ConnectError.Unreachable,
|
||||||
@@ -283,19 +284,11 @@ public sealed class ConnectFlow(IServerApiFactory factory, ITrustStore trust) :
|
|||||||
/// <summary>Server addresses as typed in the address field.</summary>
|
/// <summary>Server addresses as typed in the address field.</summary>
|
||||||
public static class ServerAddress
|
public static class ServerAddress
|
||||||
{
|
{
|
||||||
/// <summary>Accepts "nas.local:8443" (https assumed) or a full http(s) URL; the result is the API base, ending with "/".</summary>
|
/// <summary>
|
||||||
public static bool TryParse(string? text, out Uri uri)
|
/// Accepts "nas.local" (https on port 8443 assumed), "nas.local:9443" or a full http(s) URL, which keeps its scheme's
|
||||||
{
|
/// port; the result is the API base, ending with "/" (<see cref="ChronosAddress"/>, shared with the uploader).
|
||||||
uri = null!;
|
/// </summary>
|
||||||
if (string.IsNullOrWhiteSpace(text)) return false;
|
public static bool TryParse(string? text, out Uri uri) => ChronosAddress.TryParse(text, out uri);
|
||||||
var trimmed = text.Trim();
|
|
||||||
if (!trimmed.Contains("://", StringComparison.Ordinal)) trimmed = "https://" + trimmed;
|
|
||||||
if (!Uri.TryCreate(trimmed, UriKind.Absolute, out var parsed) || parsed.Scheme is not ("https" or "http") || parsed.Host.Length == 0) return false;
|
|
||||||
var builder = new UriBuilder(parsed) { Query = string.Empty, Fragment = string.Empty };
|
|
||||||
if (!builder.Path.EndsWith('/')) builder.Path += "/";
|
|
||||||
uri = builder.Uri;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>The address as shown in the field: the base URL without its trailing slash.</summary>
|
/// <summary>The address as shown in the field: the base URL without its trailing slash.</summary>
|
||||||
public static string Display(Uri uri) => uri.ToString().TrimEnd('/');
|
public static string Display(Uri uri) => uri.ToString().TrimEnd('/');
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ public sealed class ServerSession : ObservableObject, ITrustStore, IDisposable
|
|||||||
{
|
{
|
||||||
var result = await _flow.SignInAsync(user, password, attempt.Token);
|
var result = await _flow.SignInAsync(user, password, attempt.Token);
|
||||||
// An answer the flow dropped (the form was cancelled meanwhile) carries no error of its own.
|
// An answer the flow dropped (the form was cancelled meanwhile) carries no error of its own.
|
||||||
return result == ConnectStep.Connected ? null : ErrorText(_flow.Error is ConnectError.None ? ConnectError.Failed : _flow.Error);
|
return result == ConnectStep.Connected ? null : ErrorText(_flow.Error is ConnectError.None ? ConnectError.Failed : _flow.Error, _flow.Address);
|
||||||
});
|
});
|
||||||
if (signedIn && IsConnected)
|
if (signedIn && IsConnected)
|
||||||
{
|
{
|
||||||
@@ -198,8 +198,13 @@ public sealed class ServerSession : ObservableObject, ITrustStore, IDisposable
|
|||||||
_flow.Dispose();
|
_flow.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>One sentence for a failed step (BRIEF §0.2 rule 6).</summary>
|
/// <summary>
|
||||||
public static string ErrorText(ConnectError error) => Loc.L("Server.Error." + error);
|
/// One sentence for a failed step (BRIEF §0.2 rule 6). An address that answers as something else is named, with where
|
||||||
|
/// to read the right one (owner review 3).
|
||||||
|
/// </summary>
|
||||||
|
public static string ErrorText(ConnectError error, Uri? address = null) => error == ConnectError.NotChronos && address is not null
|
||||||
|
? Loc.L("Server.Error.NotChronosAt", Formatting.LeftToRight(ServerAddress.Display(address)))
|
||||||
|
: Loc.L("Server.Error." + error);
|
||||||
|
|
||||||
/// <summary>The trust-on-first-use question with the fingerprint split over two lines.</summary>
|
/// <summary>The trust-on-first-use question with the fingerprint split over two lines.</summary>
|
||||||
public static ConfirmRequest TrustRequest(string server, string fingerprint) => new()
|
public static ConfirmRequest TrustRequest(string server, string fingerprint) => new()
|
||||||
|
|||||||
@@ -10,6 +10,13 @@ namespace Chronos.Protocol;
|
|||||||
/// <see cref="Parallelism"/> is how many photos the running job processes at once (jobs run one at a time), and
|
/// <see cref="Parallelism"/> is how many photos the running job processes at once (jobs run one at a time), and
|
||||||
/// <see cref="PriorityQueue"/> with <see cref="JobPriorities"/> the priority queue (owner review 1); both apply at once, as
|
/// <see cref="PriorityQueue"/> with <see cref="JobPriorities"/> the priority queue (owner review 1); both apply at once, as
|
||||||
/// do <see cref="Logs"/> (owner review 2, R11; a request without them keeps them as they are).
|
/// do <see cref="Logs"/> (owner review 2, R11; a request without them keeps them as they are).
|
||||||
|
/// <see cref="PublicHttpPort"/> and <see cref="PublicHttpsPort"/> (owner review 3) are the ports clients reach the server
|
||||||
|
/// on when the host publishes the listening ports as others (a container): null in a response when they are the
|
||||||
|
/// listening ports; in a request, null keeps them as they are (a client that predates them) and 0 clears them. They
|
||||||
|
/// apply at once (LAN discovery, the admin panel's HTTPS redirect). <see cref="InContainer"/> (responses only) says the
|
||||||
|
/// server runs in a container, whose listening ports the template fixes: they are then locked, named in
|
||||||
|
/// <see cref="Locked"/> with the variable <c>DOTNET_RUNNING_IN_CONTAINER</c> unless one of their own fixes them. The
|
||||||
|
/// members added since are last and optional, so clients and panels of the shape before them keep working.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed record ServerSettingsDto(
|
public sealed record ServerSettingsDto(
|
||||||
string ServerName,
|
string ServerName,
|
||||||
@@ -32,7 +39,10 @@ public sealed record ServerSettingsDto(
|
|||||||
IReadOnlyList<string> Locked,
|
IReadOnlyList<string> Locked,
|
||||||
IReadOnlyDictionary<string, string> LockedBy,
|
IReadOnlyDictionary<string, string> LockedBy,
|
||||||
bool RestartRequired,
|
bool RestartRequired,
|
||||||
bool ProxyWarning);
|
bool ProxyWarning,
|
||||||
|
int? PublicHttpPort = null,
|
||||||
|
int? PublicHttpsPort = null,
|
||||||
|
bool InContainer = false);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The log settings of <see cref="ServerSettingsDto"/> (owner review 2, R11): the least severe level of the files and of the
|
/// The log settings of <see cref="ServerSettingsDto"/> (owner review 2, R11): the least severe level of the files and of the
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
|
||||||
|
namespace Chronos.Protocol.Client;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Server addresses as a user types them, shared by the desktop client and the uploader (owner review 3). An address
|
||||||
|
/// without a scheme is HTTPS and, without a port, on <see cref="DefaultPort"/>, the port Chronos Server listens on, as
|
||||||
|
/// the placeholder "nas.local:8443" shows; one typed with its scheme keeps that scheme's port ("https://chronos.example.com"
|
||||||
|
/// is 443, a reverse proxy); a port typed is always kept. A bare IPv6 address gets its brackets; one with a zone index
|
||||||
|
/// ("fe80::1%12") is refused, as the request could not keep the zone.
|
||||||
|
/// </summary>
|
||||||
|
public static class ChronosAddress
|
||||||
|
{
|
||||||
|
/// <summary>The HTTPS port of Chronos Server (<c>CHRONOS_HTTPS_PORT</c>'s default).</summary>
|
||||||
|
public const int DefaultPort = 8443;
|
||||||
|
|
||||||
|
/// <summary>The API base for <paramref name="text"/>, ending with "/", without query or fragment; false when it is not an http(s) address.</summary>
|
||||||
|
public static bool TryParse(string? text, out Uri uri)
|
||||||
|
{
|
||||||
|
uri = null!;
|
||||||
|
if (string.IsNullOrWhiteSpace(text)) return false;
|
||||||
|
var trimmed = text.Trim();
|
||||||
|
var schemeTyped = trimmed.Contains("://", StringComparison.Ordinal);
|
||||||
|
if (!schemeTyped)
|
||||||
|
{
|
||||||
|
// "fd00::5" alone: an address cannot hold its colons unbracketed ("[fd00::5]:9443" parses as an IP too, already bracketed).
|
||||||
|
if (!trimmed.StartsWith('[') && IPAddress.TryParse(trimmed, out var ip) && ip.AddressFamily == AddressFamily.InterNetworkV6)
|
||||||
|
{
|
||||||
|
if (ip.ScopeId != 0) return false;
|
||||||
|
trimmed = "[" + trimmed + "]";
|
||||||
|
}
|
||||||
|
trimmed = "https://" + trimmed;
|
||||||
|
}
|
||||||
|
if (!Uri.TryCreate(trimmed, UriKind.Absolute, out var parsed) || parsed.Scheme is not ("https" or "http") || parsed.Host.Length == 0) return false;
|
||||||
|
// A link-local address with its zone ("fe80::1%12"): the zone would not survive into the request, so it is refused.
|
||||||
|
if (parsed.HostNameType == UriHostNameType.IPv6 && (parsed.DnsSafeHost.Contains('%', StringComparison.Ordinal)
|
||||||
|
|| IPAddress.TryParse(parsed.DnsSafeHost, out var host) && host.ScopeId != 0)) return false;
|
||||||
|
var builder = new UriBuilder(parsed) { Query = string.Empty, Fragment = string.Empty };
|
||||||
|
if (!schemeTyped && !HasPort(trimmed)) builder.Port = DefaultPort;
|
||||||
|
if (!builder.Path.EndsWith('/')) builder.Path += "/";
|
||||||
|
uri = builder.Uri;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>True when the authority of <paramref name="url"/> (scheme included) names a port, the scheme's default too.</summary>
|
||||||
|
private static bool HasPort(string url)
|
||||||
|
{
|
||||||
|
var start = url.IndexOf("://", StringComparison.Ordinal) + 3;
|
||||||
|
var end = url.IndexOfAny(['/', '?', '#'], start);
|
||||||
|
var authority = end < 0 ? url[start..] : url[start..end];
|
||||||
|
authority = authority[(authority.LastIndexOf('@') + 1)..];
|
||||||
|
// "[fd00::5]:9443": the colons inside the brackets belong to the address.
|
||||||
|
var host = authority.StartsWith('[') ? authority.IndexOf(']', StringComparison.Ordinal) : -1;
|
||||||
|
return authority.IndexOf(':', host + 1) >= 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,10 +10,25 @@ public sealed class ChronosApiException(HttpStatusCode status, ApiError error)
|
|||||||
public ApiError Error { get; } = error;
|
public ApiError Error { get; } = error;
|
||||||
|
|
||||||
/// <summary>True for errors worth retrying (server busy, gateway, timeout).</summary>
|
/// <summary>True for errors worth retrying (server busy, gateway, timeout).</summary>
|
||||||
public bool IsTransient => Status is HttpStatusCode.RequestTimeout or HttpStatusCode.TooManyRequests
|
public bool IsTransient => IsTransientStatus(Status);
|
||||||
|
|
||||||
|
/// <summary>Statuses worth retrying (server busy, gateway, timeout).</summary>
|
||||||
|
public static bool IsTransientStatus(HttpStatusCode status) => status is HttpStatusCode.RequestTimeout or HttpStatusCode.TooManyRequests
|
||||||
or HttpStatusCode.BadGateway or HttpStatusCode.ServiceUnavailable or HttpStatusCode.GatewayTimeout;
|
or HttpStatusCode.BadGateway or HttpStatusCode.ServiceUnavailable or HttpStatusCode.GatewayTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The address answers, but not as a Chronos Server (owner review 3): its <c>server/info</c> is an HTML page, a redirect
|
||||||
|
/// to a sign-in page, a 4xx that is not a Chronos error, JSON of another shape, or, behind a certificate nobody trusted
|
||||||
|
/// yet, any of those. Usually the wrong port of a host that runs other services.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class NotChronosServerException(Uri address, Exception? inner = null)
|
||||||
|
: Exception($"No Chronos server answers at {address}", inner)
|
||||||
|
{
|
||||||
|
/// <summary>The API base that was asked.</summary>
|
||||||
|
public Uri Address { get; } = address;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>The server presented a certificate whose fingerprint is not trusted yet (trust-on-first-use, BRIEF §12.7).</summary>
|
/// <summary>The server presented a certificate whose fingerprint is not trusted yet (trust-on-first-use, BRIEF §12.7).</summary>
|
||||||
public sealed class UntrustedCertificateException(string fingerprint)
|
public sealed class UntrustedCertificateException(string fingerprint)
|
||||||
: Exception("Server certificate is not trusted: " + fingerprint)
|
: Exception("Server certificate is not trusted: " + fingerprint)
|
||||||
|
|||||||
@@ -20,11 +20,15 @@ public sealed class ChronosClient : IDisposable
|
|||||||
{
|
{
|
||||||
private readonly HttpClient _http;
|
private readonly HttpClient _http;
|
||||||
private readonly CertificatePinning _pinning;
|
private readonly CertificatePinning _pinning;
|
||||||
|
|
||||||
|
/// <summary>The client made its own handler, so TLS goes through <see cref="_pinning"/> (tests pass theirs).</summary>
|
||||||
|
private readonly bool _ownsHandler;
|
||||||
private string? _token;
|
private string? _token;
|
||||||
|
|
||||||
public ChronosClient(Uri baseAddress, CertificatePinning pinning, string clientName, HttpMessageHandler? handler = null)
|
public ChronosClient(Uri baseAddress, CertificatePinning pinning, string clientName, HttpMessageHandler? handler = null)
|
||||||
{
|
{
|
||||||
_pinning = pinning;
|
_pinning = pinning;
|
||||||
|
_ownsHandler = handler is null;
|
||||||
ClientName = clientName;
|
ClientName = clientName;
|
||||||
BaseAddress = baseAddress;
|
BaseAddress = baseAddress;
|
||||||
var socketsHandler = handler ?? new SocketsHttpHandler
|
var socketsHandler = handler ?? new SocketsHttpHandler
|
||||||
@@ -59,8 +63,121 @@ public sealed class ChronosClient : IDisposable
|
|||||||
|
|
||||||
// ---------------- Server ----------------
|
// ---------------- Server ----------------
|
||||||
|
|
||||||
/// <summary>Reads server info; throws <see cref="UntrustedCertificateException"/> when the TLS certificate needs confirmation.</summary>
|
/// <summary>
|
||||||
public Task<ServerInfo> GetInfoAsync(CancellationToken ct = default) => GetAsync("api/v1/server/info", ProtocolJson.Default.ServerInfo, ct);
|
/// Reads server info; throws <see cref="UntrustedCertificateException"/> when the TLS certificate of a Chronos Server
|
||||||
|
/// needs confirmation, and <see cref="NotChronosServerException"/> when the address answers as something else (owner
|
||||||
|
/// review 3): a redirect, a page that is not JSON, JSON of another shape, or an error Chronos did not write. Behind a
|
||||||
|
/// certificate that is not trusted yet, the info is first read once more without checking the certificate and without
|
||||||
|
/// credentials: only an answer that is Chronos's leads to the fingerprint question, so the certificate of another
|
||||||
|
/// service on the host is never offered for trust. An HTTPS address whose port answers plain HTTP (the HTTP port typed
|
||||||
|
/// without a scheme) is not Chronos either. Nothing is trusted here.
|
||||||
|
/// </summary>
|
||||||
|
public async Task<ServerInfo> GetInfoAsync(CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
HttpResponseMessage response;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
response = await SendRawAsync(new HttpRequestMessage(HttpMethod.Get, InfoPath), ct).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch (UntrustedCertificateException) when (_ownsHandler)
|
||||||
|
{
|
||||||
|
if (await ProbeAsync(BaseAddress, ct).ConfigureAwait(false) is { Chronos: false }) throw new NotChronosServerException(BaseAddress);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
catch (HttpRequestException tls) when (_ownsHandler && tls.HttpRequestError == HttpRequestError.SecureConnectionError
|
||||||
|
&& BaseAddress.Scheme == Uri.UriSchemeHttps)
|
||||||
|
{
|
||||||
|
// The same authority over plain HTTP: any answer means the port is not Chronos's HTTPS port.
|
||||||
|
var plain = new UriBuilder(BaseAddress) { Scheme = Uri.UriSchemeHttp, Port = BaseAddress.Port }.Uri;
|
||||||
|
if (await ProbeAsync(plain, ct).ConfigureAwait(false) is { Answered: true }) throw new NotChronosServerException(BaseAddress, tls);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
using (response)
|
||||||
|
{
|
||||||
|
var answer = await IdentifyAsync(response, ct).ConfigureAwait(false);
|
||||||
|
if (answer.Info is { } info) return info;
|
||||||
|
if (answer.Chronos == false) throw new NotChronosServerException(BaseAddress);
|
||||||
|
// Chronos's own error, already read (the body cannot be read twice), or busy: as any other request reports it.
|
||||||
|
if (answer.Error is { } error) throw new ChronosApiException(response.StatusCode, error);
|
||||||
|
await EnsureSuccessAsync(response, ct).ConfigureAwait(false);
|
||||||
|
throw new NotChronosServerException(BaseAddress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private const string InfoPath = "api/v1/server/info";
|
||||||
|
|
||||||
|
/// <summary>More than a server info ever holds: a larger answer is something else.</summary>
|
||||||
|
private const int MaxInfoBytes = 1 << 20;
|
||||||
|
|
||||||
|
/// <summary>What every Chronos Server's info holds; JSON of another shape reads as nulls and zeros.</summary>
|
||||||
|
private static bool IsChronos(ServerInfo? info) =>
|
||||||
|
info is { Name.Length: > 0, Version.Length: > 0, ApiVersion: > 0, Capabilities: not null, Formats: not null, Limits: not null };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// What a <c>server/info</c> answer is: Chronos's (with its info when it succeeded, or its error when it failed),
|
||||||
|
/// something else, or unknown (busy).
|
||||||
|
/// </summary>
|
||||||
|
private readonly record struct Identity(bool? Chronos, ServerInfo? Info = null, bool Answered = true, ApiError? Error = null);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tells a <c>server/info</c> answer of Chronos from any other. Chronos answers it anonymously with its JSON and never
|
||||||
|
/// redirects; every response of its carries <see cref="ApiVersion.Header"/>, so an error is Chronos's only with that
|
||||||
|
/// header and an error body of its own. A busy answer (408, 429, 502-504) with JSON or no body cannot tell; any answer
|
||||||
|
/// that is not JSON, or is larger than <see cref="MaxInfoBytes"/>, is something else.
|
||||||
|
/// </summary>
|
||||||
|
private static async Task<Identity> IdentifyAsync(HttpResponseMessage response, CancellationToken ct)
|
||||||
|
{
|
||||||
|
if ((int)response.StatusCode is >= 300 and < 400) return new(false);
|
||||||
|
var type = response.Content.Headers.ContentType?.MediaType;
|
||||||
|
var json = type is not null && (type.Equals("application/json", StringComparison.OrdinalIgnoreCase) || type.EndsWith("+json", StringComparison.OrdinalIgnoreCase));
|
||||||
|
if (ChronosApiException.IsTransientStatus(response.StatusCode)) return new(json || type is null ? null : false);
|
||||||
|
if (!json || response.Content.Headers.ContentLength > MaxInfoBytes) return new(false);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await response.Content.LoadIntoBufferAsync(MaxInfoBytes, ct).ConfigureAwait(false);
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var info = await response.Content.ReadFromJsonAsync(ProtocolJson.Default.ServerInfo, ct).ConfigureAwait(false);
|
||||||
|
return IsChronos(info) ? new(true, info) : new(false);
|
||||||
|
}
|
||||||
|
if (!response.Headers.Contains(ApiVersion.Header)) return new(false);
|
||||||
|
var error = await response.Content.ReadFromJsonAsync(ProtocolJson.Default.ApiError, ct).ConfigureAwait(false);
|
||||||
|
return error is { Code.Length: > 0 } && !error.Code.StartsWith("http_", StringComparison.Ordinal) ? new(true, Error: error) : new(false);
|
||||||
|
}
|
||||||
|
catch (Exception ex) when (ex is JsonException or NotSupportedException or HttpRequestException)
|
||||||
|
{
|
||||||
|
// Not JSON after all, or more than a server info.
|
||||||
|
return new(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The info at <paramref name="address"/> read without checking the certificate, by a client of its own that holds no
|
||||||
|
/// token and follows no redirect; <see cref="Identity.Answered"/> is false when nothing answered (no connection, TLS
|
||||||
|
/// refused, timeout).
|
||||||
|
/// </summary>
|
||||||
|
private static async Task<Identity> ProbeAsync(Uri address, CancellationToken ct)
|
||||||
|
{
|
||||||
|
using var handler = new SocketsHttpHandler
|
||||||
|
{
|
||||||
|
SslOptions = { RemoteCertificateValidationCallback = static (_, _, _, _) => true },
|
||||||
|
ConnectTimeout = TimeSpan.FromSeconds(10),
|
||||||
|
AutomaticDecompression = DecompressionMethods.None,
|
||||||
|
AllowAutoRedirect = false,
|
||||||
|
UseCookies = false,
|
||||||
|
};
|
||||||
|
using var http = new HttpClient(handler) { BaseAddress = address, Timeout = TimeSpan.FromSeconds(20) };
|
||||||
|
http.DefaultRequestHeaders.Add(ApiVersion.Header, ApiVersion.Current.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var response = await http.GetAsync(InfoPath, HttpCompletionOption.ResponseHeadersRead, ct).ConfigureAwait(false);
|
||||||
|
return await IdentifyAsync(response, ct).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch (Exception ex) when (ex is HttpRequestException or IOException || (ex is OperationCanceledException && !ct.IsCancellationRequested))
|
||||||
|
{
|
||||||
|
return new(null, Answered: false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------- Auth ----------------
|
// ---------------- Auth ----------------
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
// 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,
|
// (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,
|
// 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 { 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 { kindLabel } from "../jobs.js";
|
||||||
|
import { icons } from "../icons.js";
|
||||||
|
|
||||||
/** Levels of the priority queue, highest first. */
|
/** Levels of the priority queue, highest first. */
|
||||||
const LEVELS = ["high", "normal", "low"];
|
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])
|
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>`);
|
.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)}`);
|
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() {
|
function draw() {
|
||||||
root.innerHTML = `
|
root.innerHTML = `
|
||||||
@@ -75,8 +96,12 @@ export async function render(root, { api, info, setMeta, actions }) {
|
|||||||
<section class="panel" aria-labelledby="network-title">
|
<section class="panel" aria-labelledby="network-title">
|
||||||
<div class="panel-head"><h2 id="network-title" data-i18n="Admin.Settings.Network"></h2>
|
<div class="panel-head"><h2 id="network-title" data-i18n="Admin.Settings.Network"></h2>
|
||||||
${settings.proxyWarning ? PROXY_WARNING : ""}</div>
|
${settings.proxyWarning ? PROXY_WARNING : ""}</div>
|
||||||
${number("httpPort", settings.httpPort, 'min="1" max="65535"')}
|
${listening("httpPort", settings.httpPort)}
|
||||||
${number("httpsPort", settings.httpsPort, 'min="1" max="65535"')}
|
${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) =>
|
${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>`)}
|
`<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"')}
|
${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.addEventListener("submit", save);
|
||||||
form.elements.tlsMode.addEventListener("change", () => pemFiles(form));
|
form.elements.tlsMode.addEventListener("change", () => pemFiles(form));
|
||||||
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.
|
// The levels matter only while the priority queue is on.
|
||||||
form.elements.priorityQueue.addEventListener("change", () => { root.querySelector(".priorities").hidden = !form.elements.priorityQueue.checked; });
|
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) : "—";
|
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. */
|
/** The certificate and key files are used only in Own certificate mode; elsewhere they are off and say so. */
|
||||||
function pemFiles(form) {
|
function pemFiles(form) {
|
||||||
const pem = form.elements.tlsMode.value === "pem";
|
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);
|
form.querySelectorAll("[aria-invalid]").forEach(clearInvalid);
|
||||||
const data = new FormData(form);
|
const data = new FormData(form);
|
||||||
const value = (name, fallback) => (form.elements[name]?.disabled ? fallback : data.get(name));
|
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 = {
|
const request = {
|
||||||
...settings,
|
...settings,
|
||||||
serverName: String(value("serverName", settings.serverName)).trim(),
|
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,
|
discovery: form.elements.discovery.disabled ? settings.discovery : form.elements.discovery.checked,
|
||||||
httpPort: Number(value("httpPort", settings.httpPort)),
|
httpPort: Number(value("httpPort", settings.httpPort)),
|
||||||
httpsPort: Number(value("httpsPort", settings.httpsPort)),
|
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)),
|
tlsMode: String(value("tlsMode", settings.tlsMode)),
|
||||||
tlsCert: String(value("tlsCert", settings.tlsCert ?? "")).trim() || null,
|
tlsCert: String(value("tlsCert", settings.tlsCert ?? "")).trim() || null,
|
||||||
tlsKey: String(value("tlsKey", settings.tlsKey ?? "")).trim() || null,
|
tlsKey: String(value("tlsKey", settings.tlsKey ?? "")).trim() || null,
|
||||||
|
|||||||
@@ -125,13 +125,37 @@ public sealed class ServerOptions
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Port clients reach the HTTP listener on, when it differs from <see cref="HttpPort"/> (a container port published
|
/// Port clients reach the HTTP listener on, when it differs from <see cref="HttpPort"/> (a container port published
|
||||||
/// as another host port); advertised by LAN discovery. Null: <see cref="HttpPort"/>.
|
/// as another host port); advertised by LAN discovery. Null: <see cref="HttpPort"/>. Set in the admin panel or by
|
||||||
|
/// <c>CHRONOS_PUBLIC_HTTP_PORT</c>, which locks it (owner review 3); a saved value applies at once.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? PublicHttpPort { get; set; }
|
public int? PublicHttpPort { get; set; }
|
||||||
|
|
||||||
/// <summary>Port clients reach the HTTPS listener on (admin redirect, LAN discovery). Null: <see cref="HttpsPort"/>.</summary>
|
/// <summary>
|
||||||
|
/// Port clients reach the HTTPS listener on (admin redirect, LAN discovery, the client address the admin panel shows).
|
||||||
|
/// Null: <see cref="HttpsPort"/>. Set like <see cref="PublicHttpPort"/>, by <c>CHRONOS_PUBLIC_HTTPS_PORT</c>.
|
||||||
|
/// </summary>
|
||||||
public int? PublicHttpsPort { get; set; }
|
public int? PublicHttpsPort { get; set; }
|
||||||
|
|
||||||
|
/// <summary>The variable the .NET container images set to <c>true</c>: the server runs in a container.</summary>
|
||||||
|
public const string ContainerVariable = "DOTNET_RUNNING_IN_CONTAINER";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The server runs in a container (<see cref="ContainerVariable"/>; tests set it directly). Its listening ports are then
|
||||||
|
/// the container's, which the template publishes as host ports: the admin panel shows them read-only, a value
|
||||||
|
/// <c>server.json</c> holds for them is ignored (<see cref="IgnoredSavedPorts"/>), and only <c>CHRONOS_HTTP_PORT</c> /
|
||||||
|
/// <c>CHRONOS_HTTPS_PORT</c> change them (owner review 3). The ports clients use are <see cref="PublicHttpPort"/> and
|
||||||
|
/// <see cref="PublicHttpsPort"/>.
|
||||||
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
|
public bool InContainer { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// In a container, <c>server.json</c> held listening ports, which were ignored: the start says so, and the next save of
|
||||||
|
/// the settings removes them from the file (<see cref="ServerSettingsStore.Save"/>).
|
||||||
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
|
public bool IgnoredSavedPorts { get; internal set; }
|
||||||
|
|
||||||
public TlsMode TlsMode { get; set; } = TlsMode.Auto;
|
public TlsMode TlsMode { get; set; } = TlsMode.Auto;
|
||||||
public string? TlsCert { get; set; }
|
public string? TlsCert { get; set; }
|
||||||
public string? TlsKey { get; set; }
|
public string? TlsKey { get; set; }
|
||||||
@@ -301,6 +325,15 @@ public sealed class ServerOptions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
options.DataPath = dataPath;
|
options.DataPath = dataPath;
|
||||||
|
options.InContainer = string.Equals(Env(ContainerVariable), "true", StringComparison.OrdinalIgnoreCase);
|
||||||
|
if (options.InContainer)
|
||||||
|
{
|
||||||
|
// The template maps the default container ports; a port saved before owner review 3 would leave them unmapped.
|
||||||
|
var defaults = new ServerOptions();
|
||||||
|
options.IgnoredSavedPorts = options.HttpPort != defaults.HttpPort || options.HttpsPort != defaults.HttpsPort;
|
||||||
|
options.HttpPort = defaults.HttpPort;
|
||||||
|
options.HttpsPort = defaults.HttpsPort;
|
||||||
|
}
|
||||||
|
|
||||||
var locked = new List<string>();
|
var locked = new List<string>();
|
||||||
var lockedBy = new Dictionary<string, string>(StringComparer.Ordinal);
|
var lockedBy = new Dictionary<string, string>(StringComparer.Ordinal);
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ namespace Chronos.Server.Configuration;
|
|||||||
/// The admin panel's view of the configuration (BRIEF §14.8 Settings). Saving writes <c>/data/server.json</c> (only the
|
/// The admin panel's view of the configuration (BRIEF §14.8 Settings). Saving writes <c>/data/server.json</c> (only the
|
||||||
/// edited keys; secrets and environment values are never written) and applies what can change while running, the
|
/// edited keys; secrets and environment values are never written) and applies what can change while running, the
|
||||||
/// parallelism and the priority queue included (owner review 1), and the log settings through <see cref="ServerLogging"/>
|
/// parallelism and the priority queue included (owner review 1), and the log settings through <see cref="ServerLogging"/>
|
||||||
/// (owner review 2, R11); ports, TLS and chunk size wait for a restart. Job history is what the housekeeping system
|
/// (owner review 2, R11), and the public ports clients use (owner review 3); the listening ports, TLS and chunk size wait for
|
||||||
|
/// a restart. In a container the listening ports are locked: the template maps them. Job history is what the housekeeping system
|
||||||
/// schedule is reset to (owner review 2, R10): the schedule's own value applies. The audit retention kept here is what the
|
/// schedule is reset to (owner review 2, R10): the schedule's own value applies. The audit retention kept here is what the
|
||||||
/// audit clean-up schedule is reset to; the endpoint shows that schedule's age limit in its place and puts a new one there
|
/// audit clean-up schedule is reset to; the endpoint shows that schedule's age limit in its place and puts a new one there
|
||||||
/// (<c>SchedulerHost.AuditRetentionAsync</c>, <c>SchedulerHost.ApplyAuditRetentionAsync</c>).
|
/// (<c>SchedulerHost.AuditRetentionAsync</c>, <c>SchedulerHost.ApplyAuditRetentionAsync</c>).
|
||||||
@@ -43,22 +44,39 @@ public sealed class ServerSettingsStore(ServerOptions options, ServerLogging log
|
|||||||
/// <summary>Validates and saves; returns the error code and the offending setting, or null on success.</summary>
|
/// <summary>Validates and saves; returns the error code and the offending setting, or null on success.</summary>
|
||||||
public (string Code, string Setting)? Save(ServerSettingsDto request)
|
public (string Code, string Setting)? Save(ServerSettingsDto request)
|
||||||
{
|
{
|
||||||
// A panel without the log group keeps the log settings as they are.
|
var before = Current();
|
||||||
if (request.Logs is null) request = request with { Logs = Current().Logs };
|
// A panel without the log group keeps the log settings as they are, and a client without the public ports keeps
|
||||||
if (Validate(request) is { } invalid) return ("invalid_setting", invalid);
|
// them too (owner review 3: null keeps a public port, 0 clears it).
|
||||||
|
request = request with
|
||||||
|
{
|
||||||
|
Logs = request.Logs ?? before.Logs,
|
||||||
|
PublicHttpPort = Public(request.PublicHttpPort, before.PublicHttpPort),
|
||||||
|
PublicHttpsPort = Public(request.PublicHttpsPort, before.PublicHttpsPort),
|
||||||
|
};
|
||||||
|
if (Validate(request, before) is { } invalid) return ("invalid_setting", invalid);
|
||||||
lock (_gate)
|
lock (_gate)
|
||||||
{
|
{
|
||||||
var current = _saved ?? Snapshot(options, restartRequired: false);
|
var current = _saved ?? Snapshot(options, restartRequired: false);
|
||||||
var changes = Changes(current, request);
|
var changes = Changes(current, request);
|
||||||
if (changes.FirstOrDefault(c => options.Locked.Contains(c.Name)) is { Name: { } locked }) return ("setting_locked", locked);
|
var fixedSettings = LockedSettings(options);
|
||||||
if (changes.Count == 0) return null;
|
if (changes.FirstOrDefault(c => fixedSettings.Contains(c.Name)) is { Name: { } locked }) return ("setting_locked", locked);
|
||||||
|
// In a container the listening ports are the template's: ports an earlier version saved are dropped at the first
|
||||||
|
// save, so the start stops warning about them (owner review 3).
|
||||||
|
var dropPorts = options.InContainer && options.IgnoredSavedPorts;
|
||||||
|
if (changes.Count == 0 && !dropPorts) return null;
|
||||||
|
|
||||||
var file = File.Exists(options.SettingsFile) ? JsonNode.Parse(File.ReadAllText(options.SettingsFile)) as JsonObject ?? [] : [];
|
var file = File.Exists(options.SettingsFile) ? JsonNode.Parse(File.ReadAllText(options.SettingsFile)) as JsonObject ?? [] : [];
|
||||||
foreach (var (name, value) in changes) file[name] = value;
|
foreach (var (name, value) in changes) file[name] = value;
|
||||||
// The former name of the parallelism (jobs run at once before owner review 1) would set it again at the next start.
|
// The former name of the parallelism (jobs run at once before owner review 1) would set it again at the next start.
|
||||||
if (changes.Any(c => c.Name == nameof(ServerOptions.Parallelism))) file.Remove("Workers");
|
if (changes.Any(c => c.Name == nameof(ServerOptions.Parallelism))) file.Remove("Workers");
|
||||||
|
if (options.InContainer)
|
||||||
|
{
|
||||||
|
file.Remove(nameof(ServerOptions.HttpPort));
|
||||||
|
file.Remove(nameof(ServerOptions.HttpsPort));
|
||||||
|
}
|
||||||
Directory.CreateDirectory(options.DataPath);
|
Directory.CreateDirectory(options.DataPath);
|
||||||
AtomicFile.WriteAllText(options.SettingsFile, file.ToJsonString(new JsonSerializerOptions { WriteIndented = true }));
|
AtomicFile.WriteAllText(options.SettingsFile, file.ToJsonString(new JsonSerializerOptions { WriteIndented = true }));
|
||||||
|
if (dropPorts) options.IgnoredSavedPorts = false;
|
||||||
|
|
||||||
options.ServerName = request.ServerName.Trim();
|
options.ServerName = request.ServerName.Trim();
|
||||||
options.Discovery = request.Discovery;
|
options.Discovery = request.Discovery;
|
||||||
@@ -79,6 +97,9 @@ public sealed class ServerSettingsStore(ServerOptions options, ServerLogging log
|
|||||||
options.LogRotation = Rotation(logs.Rotation);
|
options.LogRotation = Rotation(logs.Rotation);
|
||||||
options.AuditRetentionDays = logs.AuditRetentionDays;
|
options.AuditRetentionDays = logs.AuditRetentionDays;
|
||||||
options.DiagnosticsLogMb = logs.DiagnosticsLogMb;
|
options.DiagnosticsLogMb = logs.DiagnosticsLogMb;
|
||||||
|
// Read by LAN discovery and the admin redirect at every use: they apply at once.
|
||||||
|
options.PublicHttpPort = request.PublicHttpPort;
|
||||||
|
options.PublicHttpsPort = request.PublicHttpsPort;
|
||||||
logging.Apply(options);
|
logging.Apply(options);
|
||||||
var restart = request.HttpPort != options.HttpPort || request.HttpsPort != options.HttpsPort
|
var restart = request.HttpPort != options.HttpPort || request.HttpsPort != options.HttpsPort
|
||||||
|| !string.Equals(request.TlsMode, options.TlsMode.ToString(), StringComparison.OrdinalIgnoreCase)
|
|| !string.Equals(request.TlsMode, options.TlsMode.ToString(), StringComparison.OrdinalIgnoreCase)
|
||||||
@@ -89,10 +110,11 @@ public sealed class ServerSettingsStore(ServerOptions options, ServerLogging log
|
|||||||
ServerName = request.ServerName.Trim(),
|
ServerName = request.ServerName.Trim(),
|
||||||
JobPriorities = Priorities(PriorityQueue(options)),
|
JobPriorities = Priorities(PriorityQueue(options)),
|
||||||
Logs = Logs(options),
|
Logs = Logs(options),
|
||||||
Locked = [.. options.Locked],
|
Locked = fixedSettings,
|
||||||
LockedBy = LockedBy(options),
|
LockedBy = LockedBy(options),
|
||||||
RestartRequired = restart,
|
RestartRequired = restart,
|
||||||
ProxyWarning = false,
|
ProxyWarning = false,
|
||||||
|
InContainer = options.InContainer,
|
||||||
};
|
};
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -101,11 +123,31 @@ public sealed class ServerSettingsStore(ServerOptions options, ServerLogging log
|
|||||||
private static ServerSettingsDto Snapshot(ServerOptions o, bool restartRequired) => new(
|
private static ServerSettingsDto Snapshot(ServerOptions o, bool restartRequired) => new(
|
||||||
o.ServerName, o.HttpPort, o.HttpsPort, o.TlsMode.ToString().ToLowerInvariant(), o.TlsCert, o.TlsKey, o.Language, o.Parallelism, o.PriorityQueue,
|
o.ServerName, o.HttpPort, o.HttpsPort, o.TlsMode.ToString().ToLowerInvariant(), o.TlsCert, o.TlsKey, o.Language, o.Parallelism, o.PriorityQueue,
|
||||||
Priorities(PriorityQueue(o)), o.Discovery, o.MaxUploadBytes, o.ChunkSizeBytes, o.JobHistoryDays, o.TokenLifetimeDays, o.UploadRetentionHours,
|
Priorities(PriorityQueue(o)), o.Discovery, o.MaxUploadBytes, o.ChunkSizeBytes, o.JobHistoryDays, o.TokenLifetimeDays, o.UploadRetentionHours,
|
||||||
Logs(o), [.. o.Locked], LockedBy(o), restartRequired, ProxyWarning: false);
|
Logs(o), LockedSettings(o), LockedBy(o), restartRequired, ProxyWarning: false, o.PublicHttpPort, o.PublicHttpsPort, o.InContainer);
|
||||||
|
|
||||||
/// <summary>The variable that fixes every locked setting (for one a test locks directly, the variable that would).</summary>
|
/// <summary>The listening ports, which a container's template maps (owner review 3).</summary>
|
||||||
private static Dictionary<string, string> LockedBy(ServerOptions o) => o.Locked.Distinct(StringComparer.Ordinal).ToDictionary(s => s,
|
private static readonly string[] ContainerPorts = [nameof(ServerOptions.HttpPort), nameof(ServerOptions.HttpsPort)];
|
||||||
s => o.LockedBy.TryGetValue(s, out var variable) ? variable : ServerOptions.VariableOf(s) ?? s, StringComparer.Ordinal);
|
|
||||||
|
/// <summary>Settings the panel cannot change: those environment variables fix and, in a container, its listening ports.</summary>
|
||||||
|
private static List<string> LockedSettings(ServerOptions o) =>
|
||||||
|
[.. o.Locked.Concat(o.InContainer ? ContainerPorts : []).Distinct(StringComparer.Ordinal)];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The variable that fixes every locked setting (for one a test locks directly, the variable that would); a container's
|
||||||
|
/// port that no variable of its own sets is fixed by <see cref="ServerOptions.ContainerVariable"/>.
|
||||||
|
/// </summary>
|
||||||
|
private static Dictionary<string, string> LockedBy(ServerOptions o) => LockedSettings(o).ToDictionary(s => s,
|
||||||
|
s => o.LockedBy.TryGetValue(s, out var variable) ? variable
|
||||||
|
: o.InContainer && ContainerPorts.Contains(s) ? ServerOptions.ContainerVariable
|
||||||
|
: ServerOptions.VariableOf(s) ?? s, StringComparer.Ordinal);
|
||||||
|
|
||||||
|
/// <summary>A public port as a request sets it: null keeps <paramref name="current"/>, 0 clears it (the listening port applies).</summary>
|
||||||
|
private static int? Public(int? requested, int? current) => requested switch
|
||||||
|
{
|
||||||
|
null => current,
|
||||||
|
0 => null,
|
||||||
|
_ => requested,
|
||||||
|
};
|
||||||
|
|
||||||
private static LogSettingsDto Logs(ServerOptions o) => new(ServerLogging.Wire(o.LogLevel), ServerLogging.Wire(o.ConsoleLogLevel), o.LogRetentionDays,
|
private static LogSettingsDto Logs(ServerOptions o) => new(ServerLogging.Wire(o.LogLevel), ServerLogging.Wire(o.ConsoleLogLevel), o.LogRetentionDays,
|
||||||
o.LogMaxFileMb, o.LogMaxTotalMb, ServerLogging.Wire(o.LogRotation), o.AuditRetentionDays, o.DiagnosticsLogMb);
|
o.LogMaxFileMb, o.LogMaxTotalMb, ServerLogging.Wire(o.LogRotation), o.AuditRetentionDays, o.DiagnosticsLogMb);
|
||||||
@@ -131,11 +173,18 @@ public sealed class ServerSettingsStore(ServerOptions options, ServerLogging log
|
|||||||
return levels;
|
return levels;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string? Validate(ServerSettingsDto r)
|
/// <summary>
|
||||||
|
/// The first setting of <paramref name="r"/> out of range, or null. Listening ports are checked only when they change,
|
||||||
|
/// so a value the panel cannot change (a container's, the test server's 0) never blocks saving the others.
|
||||||
|
/// </summary>
|
||||||
|
private static string? Validate(ServerSettingsDto r, ServerSettingsDto current)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(r.ServerName) || r.ServerName.Trim().Length > 60) return nameof(ServerOptions.ServerName);
|
if (string.IsNullOrWhiteSpace(r.ServerName) || r.ServerName.Trim().Length > 60) return nameof(ServerOptions.ServerName);
|
||||||
if (r.HttpPort is < 1 or > 65535) return nameof(ServerOptions.HttpPort);
|
var portsChanged = r.HttpPort != current.HttpPort || r.HttpsPort != current.HttpsPort;
|
||||||
if (r.HttpsPort is < 1 or > 65535 || r.HttpsPort == r.HttpPort) return nameof(ServerOptions.HttpsPort);
|
if (portsChanged && r.HttpPort is < 1 or > 65535) return nameof(ServerOptions.HttpPort);
|
||||||
|
if (portsChanged && (r.HttpsPort is < 1 or > 65535 || r.HttpsPort == r.HttpPort)) return nameof(ServerOptions.HttpsPort);
|
||||||
|
if (r.PublicHttpPort is < 1 or > 65535) return nameof(ServerOptions.PublicHttpPort);
|
||||||
|
if (r.PublicHttpsPort is < 1 or > 65535) return nameof(ServerOptions.PublicHttpsPort);
|
||||||
if (!Enum.TryParse<TlsMode>(r.TlsMode, ignoreCase: true, out var tls) || !Enum.IsDefined(tls)) return nameof(ServerOptions.TlsMode);
|
if (!Enum.TryParse<TlsMode>(r.TlsMode, ignoreCase: true, out var tls) || !Enum.IsDefined(tls)) return nameof(ServerOptions.TlsMode);
|
||||||
if (tls == TlsMode.Pem && (string.IsNullOrWhiteSpace(r.TlsCert) || !File.Exists(r.TlsCert))) return nameof(ServerOptions.TlsCert);
|
if (tls == TlsMode.Pem && (string.IsNullOrWhiteSpace(r.TlsCert) || !File.Exists(r.TlsCert))) return nameof(ServerOptions.TlsCert);
|
||||||
if (tls == TlsMode.Pem && (string.IsNullOrWhiteSpace(r.TlsKey) || !File.Exists(r.TlsKey))) return nameof(ServerOptions.TlsKey);
|
if (tls == TlsMode.Pem && (string.IsNullOrWhiteSpace(r.TlsKey) || !File.Exists(r.TlsKey))) return nameof(ServerOptions.TlsKey);
|
||||||
@@ -166,6 +215,9 @@ public sealed class ServerSettingsStore(ServerOptions options, ServerLogging log
|
|||||||
Add(nameof(ServerOptions.ServerName), a.ServerName, b.ServerName.Trim(), v => JsonValue.Create(v));
|
Add(nameof(ServerOptions.ServerName), a.ServerName, b.ServerName.Trim(), v => JsonValue.Create(v));
|
||||||
Add(nameof(ServerOptions.HttpPort), a.HttpPort, b.HttpPort, v => JsonValue.Create(v));
|
Add(nameof(ServerOptions.HttpPort), a.HttpPort, b.HttpPort, v => JsonValue.Create(v));
|
||||||
Add(nameof(ServerOptions.HttpsPort), a.HttpsPort, b.HttpsPort, v => JsonValue.Create(v));
|
Add(nameof(ServerOptions.HttpsPort), a.HttpsPort, b.HttpsPort, v => JsonValue.Create(v));
|
||||||
|
// A cleared public port is stored as null, so server.json no longer sets it.
|
||||||
|
Add(nameof(ServerOptions.PublicHttpPort), a.PublicHttpPort, b.PublicHttpPort, v => v is { } port ? JsonValue.Create(port) : null);
|
||||||
|
Add(nameof(ServerOptions.PublicHttpsPort), a.PublicHttpsPort, b.PublicHttpsPort, v => v is { } port ? JsonValue.Create(port) : null);
|
||||||
Add(nameof(ServerOptions.TlsMode), a.TlsMode.ToLowerInvariant(), b.TlsMode.ToLowerInvariant(), v => JsonValue.Create(v));
|
Add(nameof(ServerOptions.TlsMode), a.TlsMode.ToLowerInvariant(), b.TlsMode.ToLowerInvariant(), v => JsonValue.Create(v));
|
||||||
Add(nameof(ServerOptions.TlsCert), a.TlsCert, b.TlsCert, v => v is null ? null : JsonValue.Create(v));
|
Add(nameof(ServerOptions.TlsCert), a.TlsCert, b.TlsCert, v => v is null ? null : JsonValue.Create(v));
|
||||||
Add(nameof(ServerOptions.TlsKey), a.TlsKey, b.TlsKey, v => v is null ? null : JsonValue.Create(v));
|
Add(nameof(ServerOptions.TlsKey), a.TlsKey, b.TlsKey, v => v is null ? null : JsonValue.Create(v));
|
||||||
|
|||||||
@@ -94,6 +94,13 @@ public static class ServerHost
|
|||||||
app.Logger.LogWarning("CHRONOS_WORKERS is the former name of CHRONOS_PARALLELISM: jobs now run one at a time, and the value is how many "
|
app.Logger.LogWarning("CHRONOS_WORKERS is the former name of CHRONOS_PARALLELISM: jobs now run one at a time, and the value is how many "
|
||||||
+ "photos the running job processes at once. Rename the variable.");
|
+ "photos the running job processes at once. Rename the variable.");
|
||||||
}
|
}
|
||||||
|
if (options.IgnoredSavedPorts)
|
||||||
|
{
|
||||||
|
app.Logger.LogWarning("server.json sets HttpPort or HttpsPort, which a container ignores: it listens on {Http} and {Https}, the ports the "
|
||||||
|
+ "template maps. Saving the settings in the admin panel removes the saved values. Set the Public HTTP and HTTPS ports to the host "
|
||||||
|
+ "ports clients use; with network type Host, add the variable CHRONOS_HTTP_PORT or CHRONOS_HTTPS_PORT to listen on other ports.",
|
||||||
|
options.HttpPort, options.HttpsPort);
|
||||||
|
}
|
||||||
app.Lifetime.ApplicationStopping.Register(() => app.Logger.LogInformation("Chronos Server stopping"));
|
app.Lifetime.ApplicationStopping.Register(() => app.Logger.LogInformation("Chronos Server stopping"));
|
||||||
app.Lifetime.ApplicationStopped.Register(() => database.DisposeAsync().AsTask().GetAwaiter().GetResult());
|
app.Lifetime.ApplicationStopped.Register(() => database.DisposeAsync().AsTask().GetAwaiter().GetResult());
|
||||||
return app;
|
return app;
|
||||||
|
|||||||
@@ -1,21 +1,13 @@
|
|||||||
|
using Chronos.Protocol.Client;
|
||||||
|
|
||||||
namespace Chronos.Uploader.Server;
|
namespace Chronos.Uploader.Server;
|
||||||
|
|
||||||
/// <summary>Server addresses as typed in the sign-in form.</summary>
|
/// <summary>Server addresses as typed in the sign-in form.</summary>
|
||||||
public static class ServerAddress
|
public static class ServerAddress
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Accepts "nas.local:8443" (https assumed) or a full http(s) URL; the result is the API base, ending with "/".
|
/// Accepts "nas.local" (https on port 8443 assumed), "nas.local:9443" or a full http(s) URL, which keeps its scheme's
|
||||||
|
/// port; the result is the API base, ending with "/" (<see cref="ChronosAddress"/>, shared with the desktop client).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool TryParse(string? text, out Uri uri)
|
public static bool TryParse(string? text, out Uri uri) => ChronosAddress.TryParse(text, out uri);
|
||||||
{
|
|
||||||
uri = null!;
|
|
||||||
if (string.IsNullOrWhiteSpace(text)) return false;
|
|
||||||
var trimmed = text.Trim();
|
|
||||||
if (!trimmed.Contains("://", StringComparison.Ordinal)) trimmed = "https://" + trimmed;
|
|
||||||
if (!Uri.TryCreate(trimmed, UriKind.Absolute, out var parsed) || parsed.Scheme is not ("https" or "http") || parsed.Host.Length == 0) return false;
|
|
||||||
var builder = new UriBuilder(parsed) { Query = string.Empty, Fragment = string.Empty };
|
|
||||||
if (!builder.Path.EndsWith('/')) builder.Path += "/";
|
|
||||||
uri = builder.Uri;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -439,6 +439,7 @@ public sealed class ServerSession : IServerSession, IUploadTransport, IDisposabl
|
|||||||
private static SignInResult Classify(Exception ex, CancellationToken ct) => ex switch
|
private static SignInResult Classify(Exception ex, CancellationToken ct) => ex switch
|
||||||
{
|
{
|
||||||
UntrustedCertificateException => SignInResult.Untrusted,
|
UntrustedCertificateException => SignInResult.Untrusted,
|
||||||
|
NotChronosServerException => SignInResult.NotChronos,
|
||||||
ChronosApiException { Status: HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden } => SignInResult.BadCredentials,
|
ChronosApiException { Status: HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden } => SignInResult.BadCredentials,
|
||||||
ChronosApiException { Status: HttpStatusCode.NotFound } => SignInResult.NotChronos,
|
ChronosApiException { Status: HttpStatusCode.NotFound } => SignInResult.NotChronos,
|
||||||
ChronosApiException api when api.IsTransient => SignInResult.Unreachable,
|
ChronosApiException api when api.IsTransient => SignInResult.Unreachable,
|
||||||
|
|||||||
@@ -161,19 +161,25 @@ public sealed class ConnectViewModel : ObservableObject, INotifyDataErrorInfo
|
|||||||
{
|
{
|
||||||
var (result, fingerprint) = await _session.SignInAsync(Address, Username.Trim(), Password, CancellationToken.None);
|
var (result, fingerprint) = await _session.SignInAsync(Address, Username.Trim(), Password, CancellationToken.None);
|
||||||
if (result != SignInResult.Untrusted || fingerprint is null) return result;
|
if (result != SignInResult.Untrusted || fingerprint is null) return result;
|
||||||
if (!_dialogs.ConfirmTrust(Display(Address), fingerprint)) return SignInResult.Untrusted;
|
if (!_dialogs.ConfirmTrust(Asked(), fingerprint)) return SignInResult.Untrusted;
|
||||||
_session.Trust(fingerprint);
|
_session.Trust(fingerprint);
|
||||||
(result, _) = await _session.SignInAsync(Address, Username.Trim(), Password, CancellationToken.None);
|
(result, _) = await _session.SignInAsync(Address, Username.Trim(), Password, CancellationToken.None);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The address as it is asked, port included: "192.168.1.20" goes to port 8443 (owner review 3), which the trust question
|
||||||
|
/// and the not-Chronos error both name.
|
||||||
|
/// </summary>
|
||||||
|
private string Asked() => ServerAddress.TryParse(Address, out var asked) ? Display(asked.ToString()) : Address.Trim();
|
||||||
|
|
||||||
/// <summary>Puts each failure where it belongs: on the field it is about, or in the sentence under the form.</summary>
|
/// <summary>Puts each failure where it belongs: on the field it is about, or in the sentence under the form.</summary>
|
||||||
private void ShowResult(SignInResult? result)
|
private void ShowResult(SignInResult? result)
|
||||||
{
|
{
|
||||||
AddressError = result switch
|
AddressError = result switch
|
||||||
{
|
{
|
||||||
SignInResult.InvalidAddress => Loc.L("Uploader.Connect.Error.InvalidAddress"),
|
SignInResult.InvalidAddress => Loc.L("Uploader.Connect.Error.InvalidAddress"),
|
||||||
SignInResult.NotChronos => Loc.L("Uploader.Connect.Error.NotChronos"),
|
SignInResult.NotChronos => Loc.L("Uploader.Connect.Error.NotChronosAt", "" + Asked() + ""),
|
||||||
_ => null,
|
_ => null,
|
||||||
};
|
};
|
||||||
PasswordError = result == SignInResult.BadCredentials ? Loc.L("Uploader.Connect.Error.BadCredentials") : null;
|
PasswordError = result == SignInResult.BadCredentials ? Loc.L("Uploader.Connect.Error.BadCredentials") : null;
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ public sealed class ConnectFlowTests
|
|||||||
[Case("ftp://nas.local", ConnectError.InvalidAddress)]
|
[Case("ftp://nas.local", ConnectError.InvalidAddress)]
|
||||||
[Case("down.local", ConnectError.Unreachable)]
|
[Case("down.local", ConnectError.Unreachable)]
|
||||||
[Case("web.local", ConnectError.NotChronos)]
|
[Case("web.local", ConnectError.NotChronos)]
|
||||||
|
[Case("other.local", ConnectError.NotChronos)]
|
||||||
public async Task ProbeFailuresAreClassified(string address, ConnectError error)
|
public async Task ProbeFailuresAreClassified(string address, ConnectError error)
|
||||||
{
|
{
|
||||||
using var flow = new ConnectFlow(new FakeServer(), new MemoryTrust());
|
using var flow = new ConnectFlow(new FakeServer(), new MemoryTrust());
|
||||||
@@ -141,9 +142,32 @@ public sealed class ConnectFlowTests
|
|||||||
Assert.Equal(1, changes);
|
Assert.Equal(1, changes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task AnotherServiceOnThePortIsNamedWithTheAddressAsked()
|
||||||
|
{
|
||||||
|
// Owner review 3: "192.168.30.23" goes to port 8443, where the owner's NAS runs another service.
|
||||||
|
var server = new FakeServer { SelfSigned = true };
|
||||||
|
var trust = new MemoryTrust();
|
||||||
|
using var flow = new ConnectFlow(server, trust);
|
||||||
|
Assert.Equal(ConnectStep.Failed, await flow.ProbeAsync("other.local"));
|
||||||
|
Assert.Equal(ConnectError.NotChronos, flow.Error);
|
||||||
|
Assert.Null(flow.PendingFingerprint);
|
||||||
|
Assert.Empty(trust.Fingerprints);
|
||||||
|
Assert.Equal(Chronos.Core.Localization.Loc.L("Server.Error.NotChronosAt", Chronos.App.Infrastructure.Formatting.LeftToRight("https://other.local:8443")),
|
||||||
|
ServerSession.ErrorText(flow.Error, flow.Address));
|
||||||
|
Assert.Contains("https://other.local:8443", ServerSession.ErrorText(flow.Error, flow.Address));
|
||||||
|
// Without the address, and for other errors, the sentence stays as it was.
|
||||||
|
Assert.Equal(Chronos.Core.Localization.Loc.L("Server.Error.NotChronos"), ServerSession.ErrorText(ConnectError.NotChronos));
|
||||||
|
Assert.Equal(Chronos.Core.Localization.Loc.L("Server.Error.Unreachable"), ServerSession.ErrorText(ConnectError.Unreachable, flow.Address));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void AddressesAreNormalised()
|
public void AddressesAreNormalised()
|
||||||
{
|
{
|
||||||
|
Assert.True(ServerAddress.TryParse("nas.local", out var bare));
|
||||||
|
Assert.Equal("https://nas.local:8443/", bare.ToString());
|
||||||
|
Assert.True(ServerAddress.TryParse("https://chronos.example.com", out var proxied));
|
||||||
|
Assert.Equal("https://chronos.example.com/", proxied.ToString());
|
||||||
Assert.True(ServerAddress.TryParse("nas.local:8443", out var a));
|
Assert.True(ServerAddress.TryParse("nas.local:8443", out var a));
|
||||||
Assert.Equal("https://nas.local:8443/", a.ToString());
|
Assert.Equal("https://nas.local:8443/", a.ToString());
|
||||||
Assert.True(ServerAddress.TryParse(" http://10.0.0.5:8080/chronos?x=1 ", out var b));
|
Assert.True(ServerAddress.TryParse(" http://10.0.0.5:8080/chronos?x=1 ", out var b));
|
||||||
@@ -228,6 +252,8 @@ public sealed class ConnectFlowTests
|
|||||||
{
|
{
|
||||||
if (BaseAddress.Host == "down.local") throw new HttpRequestException("No such host");
|
if (BaseAddress.Host == "down.local") throw new HttpRequestException("No such host");
|
||||||
if (BaseAddress.Host == "web.local") throw new ChronosApiException(HttpStatusCode.NotFound, new ApiError("http_404", "Not Found"));
|
if (BaseAddress.Host == "web.local") throw new ChronosApiException(HttpStatusCode.NotFound, new ApiError("http_404", "Not Found"));
|
||||||
|
// What ChronosClient reports for another service on the port: its page, its sign-in redirect, its certificate.
|
||||||
|
if (BaseAddress.Host == "other.local") throw new NotChronosServerException(BaseAddress);
|
||||||
if (server.SelfSigned && !trusted.Contains(Fingerprint)) throw new UntrustedCertificateException(Fingerprint);
|
if (server.SelfSigned && !trusted.Contains(Fingerprint)) throw new UntrustedCertificateException(Fingerprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,10 +56,13 @@ public sealed class ConnectViewModelTests
|
|||||||
public void AServerThatIsNotChronosMarksTheServerField()
|
public void AServerThatIsNotChronosMarksTheServerField()
|
||||||
{
|
{
|
||||||
var form = Form(new FakeSession(SignInResult.NotChronos));
|
var form = Form(new FakeSession(SignInResult.NotChronos));
|
||||||
|
// Owner review 3: the address as it was asked, port included, so the user sees which port answered.
|
||||||
|
form.Address = "192.168.30.23";
|
||||||
|
|
||||||
form.SignInCommand.Execute(null);
|
form.SignInCommand.Execute(null);
|
||||||
|
|
||||||
Assert.Equal(Loc.L("Uploader.Connect.Error.NotChronos"), form.AddressError);
|
Assert.Equal(Loc.L("Uploader.Connect.Error.NotChronosAt", "https://192.168.30.23:8443"), form.AddressError);
|
||||||
|
Assert.Contains("https://192.168.30.23:8443", form.AddressToolTip);
|
||||||
Assert.Null(form.ErrorText);
|
Assert.Null(form.ErrorText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,18 @@ public sealed class ServerAddressTests
|
|||||||
[Case("https://nas.local:8443", "https://nas.local:8443/")]
|
[Case("https://nas.local:8443", "https://nas.local:8443/")]
|
||||||
[Case(" http://192.168.1.20:8080/chronos ", "http://192.168.1.20:8080/chronos/")]
|
[Case(" http://192.168.1.20:8080/chronos ", "http://192.168.1.20:8080/chronos/")]
|
||||||
[Case("https://nas.local/?x=1#y", "https://nas.local/")]
|
[Case("https://nas.local/?x=1#y", "https://nas.local/")]
|
||||||
|
// Owner review 3: no scheme and no port is Chronos's HTTPS port, as the placeholder shows.
|
||||||
|
[Case("192.168.30.23", "https://192.168.30.23:8443/")]
|
||||||
|
[Case("nas.local", "https://nas.local:8443/")]
|
||||||
|
[Case("nas.local/chronos", "https://nas.local:8443/chronos/")]
|
||||||
|
[Case("192.168.30.23:8444", "https://192.168.30.23:8444/")]
|
||||||
|
[Case("nas.local:443", "https://nas.local/")]
|
||||||
|
[Case("https://chronos.example.com", "https://chronos.example.com/")]
|
||||||
|
[Case("http://nas.local", "http://nas.local/")]
|
||||||
|
[Case("fd00::5", "https://[fd00::5]:8443/")]
|
||||||
|
[Case("[fd00::5]", "https://[fd00::5]:8443/")]
|
||||||
|
[Case("[fd00::5]:9443", "https://[fd00::5]:9443/")]
|
||||||
|
[Case("https://[fd00::5]", "https://[fd00::5]/")]
|
||||||
public void ServerAddressesBecomeApiBases(string typed, string expected)
|
public void ServerAddressesBecomeApiBases(string typed, string expected)
|
||||||
{
|
{
|
||||||
Assert.True(ServerAddress.TryParse(typed, out var uri));
|
Assert.True(ServerAddress.TryParse(typed, out var uri));
|
||||||
@@ -21,5 +33,9 @@ public sealed class ServerAddressTests
|
|||||||
[Case(" ")]
|
[Case(" ")]
|
||||||
[Case("ftp://nas.local")]
|
[Case("ftp://nas.local")]
|
||||||
[Case("https://")]
|
[Case("https://")]
|
||||||
|
// A zone index cannot reach the request: refused rather than dropped.
|
||||||
|
[Case("fe80::1%12")]
|
||||||
|
[Case("[fe80::1%12]:8443")]
|
||||||
|
[Case("https://[fe80::1%2512]")]
|
||||||
public void InvalidServerAddressesAreRejected(string typed) => Assert.False(ServerAddress.TryParse(typed, out _));
|
public void InvalidServerAddressesAreRejected(string typed) => Assert.False(ServerAddress.TryParse(typed, out _));
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,191 @@
|
|||||||
|
using System.Net;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Hosting.Server;
|
||||||
|
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Chronos.Protocol;
|
||||||
|
using Chronos.Protocol.Client;
|
||||||
|
using Chronos.Testing;
|
||||||
|
|
||||||
|
namespace Chronos.Server.Tests.Api;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// What a client makes of the address it was given (owner review 3): the owner's NAS answers on 8443 with another service,
|
||||||
|
/// which redirects to its sign-in page behind a self-signed certificate of its own.
|
||||||
|
/// </summary>
|
||||||
|
[Category("server")]
|
||||||
|
public sealed class ServerIdentityTests(TestContext context)
|
||||||
|
{
|
||||||
|
/// <summary>Answers of another service, each under its own path.</summary>
|
||||||
|
private static readonly string[] OtherAnswers =
|
||||||
|
[
|
||||||
|
"html/", "redirect/", "away/", "empty/", "json/", "unauthorized/", "missing/", "text/", "failed/", "gateway/", "json401/", "json403/",
|
||||||
|
"json404/", "huge/", "hugejson/",
|
||||||
|
];
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task AnAddressThatAnswersAsSomethingElseIsNotAChronosServer()
|
||||||
|
{
|
||||||
|
await using var other = await OtherService.StartAsync(context);
|
||||||
|
// Over HTTP, and over HTTPS behind the service's own certificate, which nobody trusted.
|
||||||
|
foreach (var address in new[] { other.Http, other.Https }.SelectMany(root => OtherAnswers.Select(path => new Uri(root, path))))
|
||||||
|
{
|
||||||
|
using var client = new ChronosClient(address, new CertificatePinning([]), "tests");
|
||||||
|
var error = await Assert.ThrowsAsync<NotChronosServerException>(() => client.GetInfoAsync(context.Cancellation), address.ToString());
|
||||||
|
Assert.Equal(address, error.Address, address.ToString());
|
||||||
|
}
|
||||||
|
Assert.Equal(0, other.Authorized, "no request carried credentials");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task TheHttpPortTypedWithoutASchemeIsNotAChronosServer()
|
||||||
|
{
|
||||||
|
// "192.168.30.23:8087", the port of the panel's link: HTTPS to a port that answers plain HTTP.
|
||||||
|
await using var server = await TestServer.StartAsync(context);
|
||||||
|
Assert.True(ChronosAddress.TryParse($"127.0.0.1:{server.HttpBase.Port}", out var typed));
|
||||||
|
using var client = new ChronosClient(typed, new CertificatePinning([]), "tests");
|
||||||
|
var error = await Assert.ThrowsAsync<NotChronosServerException>(() => client.GetInfoAsync(context.Cancellation));
|
||||||
|
Assert.Equal(typed, error.Address);
|
||||||
|
|
||||||
|
await using var other = await OtherService.StartAsync(context);
|
||||||
|
using var otherClient = new ChronosClient(new UriBuilder(other.Http) { Scheme = "https", Port = other.Http.Port }.Uri, new CertificatePinning([]), "tests");
|
||||||
|
await Assert.ThrowsAsync<NotChronosServerException>(() => otherClient.GetInfoAsync(context.Cancellation));
|
||||||
|
|
||||||
|
// A port where nothing answers is still unreachable, not another service.
|
||||||
|
var listener = new System.Net.Sockets.TcpListener(IPAddress.Loopback, 0);
|
||||||
|
listener.Start();
|
||||||
|
var closed = ((IPEndPoint)listener.LocalEndpoint).Port;
|
||||||
|
listener.Stop();
|
||||||
|
using var nobody = new ChronosClient(new Uri($"https://127.0.0.1:{closed}/"), new CertificatePinning([]), "tests");
|
||||||
|
await Assert.ThrowsAsync<HttpRequestException>(() => nobody.GetInfoAsync(context.Cancellation));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task TheCertificateOfAnotherServiceIsNeverOfferedForTrust()
|
||||||
|
{
|
||||||
|
await using var other = await OtherService.StartAsync(context);
|
||||||
|
var pinning = new CertificatePinning([]);
|
||||||
|
using var client = new ChronosClient(new Uri(other.Https, "redirect/"), pinning, "tests");
|
||||||
|
await Assert.ThrowsAsync<NotChronosServerException>(() => client.GetInfoAsync(context.Cancellation));
|
||||||
|
// Nothing was trusted, and the next request still refuses the certificate.
|
||||||
|
await Assert.ThrowsAsync<UntrustedCertificateException>(() => client.MeAsync(context.Cancellation));
|
||||||
|
Assert.Equal(0, other.Authorized, "no request carried credentials");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task AChronosErrorFromTheInfoIsReportedAsThatError()
|
||||||
|
{
|
||||||
|
// Chronos's own error (its header and code) is read once to tell it from other services: it must still come back
|
||||||
|
// as the server's error, and an unknown certificate still asks for trust.
|
||||||
|
await using var other = await OtherService.StartAsync(context);
|
||||||
|
foreach (var (path, status, code) in new[] { ("chronos500/", HttpStatusCode.InternalServerError, "internal"), ("chronos400/", HttpStatusCode.BadRequest, "bad_request") })
|
||||||
|
{
|
||||||
|
using var plain = new ChronosClient(new Uri(other.Http, path), new CertificatePinning([]), "tests");
|
||||||
|
var error = await Assert.ThrowsAsync<ChronosApiException>(() => plain.GetInfoAsync(context.Cancellation), path);
|
||||||
|
Assert.Equal(status, error.Status, path);
|
||||||
|
Assert.Equal(code, error.Error.Code, path);
|
||||||
|
|
||||||
|
using var untrusted = new ChronosClient(new Uri(other.Https, path), new CertificatePinning([]), "tests");
|
||||||
|
await Assert.ThrowsAsync<UntrustedCertificateException>(() => untrusted.GetInfoAsync(context.Cancellation), path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task AChronosServerBehindAnUnknownCertificateStillAsksForTrust()
|
||||||
|
{
|
||||||
|
await using var server = await TestServer.StartAsync(context, o => o.ServerName = "Studio NAS");
|
||||||
|
var https = Assert.NotNull(server.HttpsBase);
|
||||||
|
using var unknown = new ChronosClient(https, new CertificatePinning([]), "tests");
|
||||||
|
var untrusted = await Assert.ThrowsAsync<UntrustedCertificateException>(() => unknown.GetInfoAsync(context.Cancellation));
|
||||||
|
using var info = await server.Client.GetAsync("/api/v1/server/info");
|
||||||
|
Assert.Equal((await info.ReadAsync(ProtocolJson.Default.ServerInfo)).TlsFingerprint, untrusted.Fingerprint);
|
||||||
|
|
||||||
|
using var trusted = new ChronosClient(https, new CertificatePinning([untrusted.Fingerprint]), "tests");
|
||||||
|
Assert.Equal("Studio NAS", (await trusted.GetInfoAsync(context.Cancellation)).Name);
|
||||||
|
// Plain HTTP to the same server is Chronos too.
|
||||||
|
using var plain = new ChronosClient(server.HttpBase, new CertificatePinning([]), "tests");
|
||||||
|
Assert.Equal("Studio NAS", (await plain.GetInfoAsync(context.Cancellation)).Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>A web service that is not Chronos, on HTTP and on HTTPS with a self-signed certificate of its own.</summary>
|
||||||
|
private sealed class OtherService : IAsyncDisposable
|
||||||
|
{
|
||||||
|
private readonly WebApplication _app;
|
||||||
|
private int _authorized;
|
||||||
|
|
||||||
|
private OtherService(WebApplication app)
|
||||||
|
{
|
||||||
|
_app = app;
|
||||||
|
var addresses = app.Services.GetRequiredService<IServer>().Features.Get<IServerAddressesFeature>()!.Addresses.Select(a => new Uri(a)).ToList();
|
||||||
|
Http = new Uri(addresses.First(a => a.Scheme == "http"), "/");
|
||||||
|
Https = new Uri(addresses.First(a => a.Scheme == "https"), "/");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Uri Http { get; }
|
||||||
|
public Uri Https { get; }
|
||||||
|
|
||||||
|
/// <summary>Requests that carried an Authorization header.</summary>
|
||||||
|
public int Authorized => Volatile.Read(ref _authorized);
|
||||||
|
|
||||||
|
public static async Task<OtherService> StartAsync(TestContext context)
|
||||||
|
{
|
||||||
|
using var key = RSA.Create(2048);
|
||||||
|
var request = new CertificateRequest("CN=other-service", key, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
|
||||||
|
using var created = request.CreateSelfSigned(DateTimeOffset.UtcNow.AddDays(-1), DateTimeOffset.UtcNow.AddDays(1));
|
||||||
|
var certificate = X509CertificateLoader.LoadPkcs12(created.Export(X509ContentType.Pfx), null);
|
||||||
|
|
||||||
|
var builder = WebApplication.CreateSlimBuilder();
|
||||||
|
builder.Logging.ClearProviders();
|
||||||
|
builder.WebHost.ConfigureKestrel(k =>
|
||||||
|
{
|
||||||
|
k.Listen(IPAddress.Loopback, 0);
|
||||||
|
k.Listen(IPAddress.Loopback, 0, l => l.UseHttps(certificate));
|
||||||
|
});
|
||||||
|
var app = builder.Build();
|
||||||
|
OtherService? service = null;
|
||||||
|
app.Use(async (http, next) =>
|
||||||
|
{
|
||||||
|
if (http.Request.Headers.Authorization.Count > 0 && service is not null) Interlocked.Increment(ref service._authorized);
|
||||||
|
await next(http);
|
||||||
|
});
|
||||||
|
app.MapGet("/html/api/v1/server/info", () => Results.Content("<!doctype html><title>NAS</title>", "text/html"));
|
||||||
|
app.MapGet("/redirect/api/v1/server/info", () => Results.Redirect("/login"));
|
||||||
|
app.MapGet("/login", () => Results.Content("<!doctype html><form>Sign in</form>", "text/html"));
|
||||||
|
app.MapGet("/empty/api/v1/server/info", () => Results.Content("{}", "application/json"));
|
||||||
|
app.MapGet("/json/api/v1/server/info", () => Results.Content("""{"status":"ok","name":"router"}""", "application/json"));
|
||||||
|
app.MapGet("/unauthorized/api/v1/server/info", () => Results.StatusCode(StatusCodes.Status401Unauthorized));
|
||||||
|
// An absolute redirect to plain HTTP, which a client never follows from HTTPS.
|
||||||
|
app.MapGet("/away/api/v1/server/info", (HttpContext http) => Results.Redirect($"http://{http.Request.Host}/login"));
|
||||||
|
app.MapGet("/text/api/v1/server/info", () => Results.Text("ok"));
|
||||||
|
app.MapGet("/failed/api/v1/server/info", () => Results.Content("<!doctype html><title>Error</title>", "text/html", statusCode: StatusCodes.Status500InternalServerError));
|
||||||
|
app.MapGet("/gateway/api/v1/server/info", () => Results.Content("<!doctype html><title>Bad gateway</title>", "text/html", statusCode: StatusCodes.Status502BadGateway));
|
||||||
|
// Errors in JSON with a code of their own, as many web services write them.
|
||||||
|
foreach (var (path, status) in new[] { ("json401", 401), ("json403", 403), ("json404", 404) })
|
||||||
|
app.MapGet($"/{path}/api/v1/server/info", () => Results.Content("""{"code":"denied","message":"Sign in"}""", "application/json", statusCode: status));
|
||||||
|
// Errors as Chronos writes them: its header and a code of its own.
|
||||||
|
foreach (var (path, status, code) in new[] { ("chronos500", 500, "internal"), ("chronos400", 400, "bad_request") })
|
||||||
|
app.MapGet($"/{path}/api/v1/server/info", (HttpContext http) =>
|
||||||
|
{
|
||||||
|
http.Response.Headers[ApiVersion.Header] = "1";
|
||||||
|
return Results.Content($$"""{"code":"{{code}}","message":"Failed"}""", "application/json", statusCode: status);
|
||||||
|
});
|
||||||
|
// More than a server info ever holds.
|
||||||
|
app.MapGet("/huge/api/v1/server/info", () => Results.Content("<!doctype html>" + new string('x', 2 << 20), "text/html"));
|
||||||
|
app.MapGet("/hugejson/api/v1/server/info", () => Results.Content("{\"name\":\"" + new string('x', 2 << 20) + "\"}", "application/json"));
|
||||||
|
await app.StartAsync(context.Cancellation);
|
||||||
|
service = new OtherService(app);
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask DisposeAsync()
|
||||||
|
{
|
||||||
|
await _app.StopAsync();
|
||||||
|
await _app.DisposeAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,268 @@
|
|||||||
|
using System.Net;
|
||||||
|
using System.Net.Http.Json;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
|
using Microsoft.AspNetCore.Hosting.Server;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Chronos.Protocol;
|
||||||
|
using Chronos.Server.Configuration;
|
||||||
|
using Chronos.Server.Hosting;
|
||||||
|
using Chronos.Testing;
|
||||||
|
|
||||||
|
namespace Chronos.Server.Tests.Hosting;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The ports clients use and the ports the server listens on (owner review 3): a container publishes 8080 and 8443 as
|
||||||
|
/// other host ports, and only the public ports tell clients, LAN discovery and the HTTPS redirect which ones.
|
||||||
|
/// </summary>
|
||||||
|
[Category("server")]
|
||||||
|
public sealed class PublicPortTests(TestContext context)
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public async Task PublicPortsAreSavedAndApplyWithoutARestart()
|
||||||
|
{
|
||||||
|
await using var server = await TestServer.StartAsync(context);
|
||||||
|
var admin = await server.AdminAsync();
|
||||||
|
var settings = await SettingsAsync(admin);
|
||||||
|
Assert.Equal(((int?)null, (int?)null, false), (settings.PublicHttpPort, settings.PublicHttpsPort, settings.InContainer));
|
||||||
|
|
||||||
|
// The test server listens on ports the system chose (0), which no request may set.
|
||||||
|
var edited = settings with { HttpPort = 18080, HttpsPort = 18443, PublicHttpPort = 8087, PublicHttpsPort = 8444 };
|
||||||
|
using (var saved = await admin.PutAsJsonAsync("/api/v1/server/settings", edited, ProtocolJson.Default.ServerSettingsDto))
|
||||||
|
{
|
||||||
|
var answer = await saved.ReadAsync(ProtocolJson.Default.ServerSettingsDto);
|
||||||
|
Assert.Equal(((int?)8087, (int?)8444), (answer.PublicHttpPort, answer.PublicHttpsPort));
|
||||||
|
}
|
||||||
|
Assert.Equal(((int?)8087, (int?)8444), (server.Options.PublicHttpPort, server.Options.PublicHttpsPort));
|
||||||
|
|
||||||
|
// At once: the beacon and the redirect to HTTPS name the host ports.
|
||||||
|
var beacon = server.Services.GetRequiredService<DiscoveryBeaconService>().CreateBeacon();
|
||||||
|
Assert.Equal((8087, 8444), (beacon.HttpPort, beacon.HttpsPort));
|
||||||
|
var kestrel = server.Services.GetRequiredService<IServer>();
|
||||||
|
Assert.Equal("https://192.168.30.23:8444/admin/", AdminPanel.HttpsLocation(AdminRequest(), server.Options, kestrel));
|
||||||
|
|
||||||
|
// Stored for the next start.
|
||||||
|
var file = JsonNode.Parse(await File.ReadAllTextAsync(server.Options.SettingsFile))!.AsObject();
|
||||||
|
Assert.Equal((8087, 8444), (file["PublicHttpPort"]!.GetValue<int>(), file["PublicHttpsPort"]!.GetValue<int>()));
|
||||||
|
var restarted = ServerOptions.Load(new Dictionary<string, string?> { ["CHRONOS_DATA_PATH"] = server.Options.DataPath, ["CHRONOS_DB"] = "postgres" });
|
||||||
|
Assert.Equal(((int?)8087, (int?)8444), (restarted.PublicHttpPort, restarted.PublicHttpsPort));
|
||||||
|
|
||||||
|
// A client of the shape before them sends no public ports: they stay as they are.
|
||||||
|
var older = JsonSerializer.SerializeToNode(edited with { ServerName = "Older client" }, ProtocolJson.Default.ServerSettingsDto)!.AsObject();
|
||||||
|
Assert.True(older.Remove("publicHttpPort") && older.Remove("publicHttpsPort") && older.Remove("inContainer"));
|
||||||
|
using (var content = new StringContent(older.ToJsonString(), Encoding.UTF8, "application/json"))
|
||||||
|
using (var saved = await admin.PutAsync("/api/v1/server/settings", content))
|
||||||
|
Assert.Equal(((int?)8087, (int?)8444), ((await saved.ReadAsync(ProtocolJson.Default.ServerSettingsDto)).PublicHttpPort, server.Options.PublicHttpsPort));
|
||||||
|
Assert.Equal("Older client", server.Options.ServerName);
|
||||||
|
|
||||||
|
// 0 clears one: the listening port applies again, at once.
|
||||||
|
using (var cleared = await admin.PutAsJsonAsync("/api/v1/server/settings", edited with { PublicHttpsPort = 0 }, ProtocolJson.Default.ServerSettingsDto))
|
||||||
|
Assert.Null((await cleared.ReadAsync(ProtocolJson.Default.ServerSettingsDto)).PublicHttpsPort);
|
||||||
|
Assert.Null(server.Options.PublicHttpsPort);
|
||||||
|
var listening = Assert.NotNull(server.HttpsBase).Port;
|
||||||
|
Assert.Equal(listening, server.Services.GetRequiredService<DiscoveryBeaconService>().CreateBeacon().HttpsPort);
|
||||||
|
Assert.Equal($"https://192.168.30.23:{listening}/admin/", AdminPanel.HttpsLocation(AdminRequest(), server.Options, kestrel));
|
||||||
|
file = JsonNode.Parse(await File.ReadAllTextAsync(server.Options.SettingsFile))!.AsObject();
|
||||||
|
Assert.True(file.ContainsKey("PublicHttpsPort") && file["PublicHttpsPort"] is null, "a cleared port no longer sets it");
|
||||||
|
Assert.Null(ServerOptions.Load(new Dictionary<string, string?> { ["CHRONOS_DATA_PATH"] = server.Options.DataPath, ["CHRONOS_DB"] = "postgres" }).PublicHttpsPort);
|
||||||
|
|
||||||
|
foreach (var (invalid, setting) in new (ServerSettingsDto, string)[]
|
||||||
|
{
|
||||||
|
(edited with { PublicHttpPort = 70000 }, "PublicHttpPort"),
|
||||||
|
(edited with { PublicHttpsPort = -1 }, "PublicHttpsPort"),
|
||||||
|
})
|
||||||
|
{
|
||||||
|
using var refused = await admin.PutAsJsonAsync("/api/v1/server/settings", invalid, ProtocolJson.Default.ServerSettingsDto);
|
||||||
|
Assert.Equal(setting, (await refused.ExpectErrorAsync(HttpStatusCode.BadRequest, "invalid_setting")).Details);
|
||||||
|
}
|
||||||
|
Assert.Equal((int?)8087, server.Options.PublicHttpPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task AVariableLocksItsPublicPort()
|
||||||
|
{
|
||||||
|
await using var server = await TestServer.StartAsync(context, o =>
|
||||||
|
{
|
||||||
|
o.PublicHttpsPort = 8444;
|
||||||
|
o.Locked = [nameof(ServerOptions.PublicHttpsPort)];
|
||||||
|
o.LockedBy = new Dictionary<string, string> { [nameof(ServerOptions.PublicHttpsPort)] = "CHRONOS_PUBLIC_HTTPS_PORT" };
|
||||||
|
});
|
||||||
|
var admin = await server.AdminAsync();
|
||||||
|
var settings = await SettingsAsync(admin);
|
||||||
|
Assert.Equal(((int?)8444, "CHRONOS_PUBLIC_HTTPS_PORT"), (settings.PublicHttpsPort, settings.LockedBy["PublicHttpsPort"]));
|
||||||
|
|
||||||
|
var edited = settings with { HttpPort = 18080, HttpsPort = 18443 };
|
||||||
|
using (var refused = await admin.PutAsJsonAsync("/api/v1/server/settings", edited with { PublicHttpsPort = 9444 }, ProtocolJson.Default.ServerSettingsDto))
|
||||||
|
Assert.Equal("PublicHttpsPort", (await refused.ExpectErrorAsync(HttpStatusCode.Conflict, "setting_locked")).Details);
|
||||||
|
using (var refused = await admin.PutAsJsonAsync("/api/v1/server/settings", edited with { PublicHttpsPort = 0 }, ProtocolJson.Default.ServerSettingsDto))
|
||||||
|
Assert.Equal("PublicHttpsPort", (await refused.ExpectErrorAsync(HttpStatusCode.Conflict, "setting_locked")).Details);
|
||||||
|
// The other public port, and a request that leaves the locked one as it is, still save.
|
||||||
|
using (var saved = await admin.PutAsJsonAsync("/api/v1/server/settings", edited with { PublicHttpPort = 8087 }, ProtocolJson.Default.ServerSettingsDto))
|
||||||
|
await saved.ExpectAsync(HttpStatusCode.OK);
|
||||||
|
Assert.Equal(((int?)8087, (int?)8444), (server.Options.PublicHttpPort, server.Options.PublicHttpsPort));
|
||||||
|
|
||||||
|
// The variables lock their settings at start, with an empty one taken as unset.
|
||||||
|
var root = context.CreateTempDirectory("public-locked");
|
||||||
|
var loaded = ServerOptions.Load(new Dictionary<string, string?>
|
||||||
|
{
|
||||||
|
["CHRONOS_DATA_PATH"] = root,
|
||||||
|
["CHRONOS_DB"] = "postgres",
|
||||||
|
["CHRONOS_PUBLIC_HTTPS_PORT"] = "8444",
|
||||||
|
["CHRONOS_PUBLIC_HTTP_PORT"] = "",
|
||||||
|
});
|
||||||
|
Assert.SequenceEqual(["Database", "PublicHttpsPort"], loaded.Locked);
|
||||||
|
Assert.Equal("CHRONOS_PUBLIC_HTTPS_PORT", loaded.LockedBy["PublicHttpsPort"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task InAContainerTheListeningPortsAreTheTemplates()
|
||||||
|
{
|
||||||
|
await using var server = await TestServer.StartAsync(context, o => o.InContainer = true);
|
||||||
|
var admin = await server.AdminAsync();
|
||||||
|
var settings = await SettingsAsync(admin);
|
||||||
|
Assert.True(settings.InContainer);
|
||||||
|
Assert.Contains("HttpPort", settings.Locked);
|
||||||
|
Assert.Contains("HttpsPort", settings.Locked);
|
||||||
|
Assert.Equal(("DOTNET_RUNNING_IN_CONTAINER", "DOTNET_RUNNING_IN_CONTAINER"), (settings.LockedBy["HttpPort"], settings.LockedBy["HttpsPort"]));
|
||||||
|
|
||||||
|
using (var refused = await admin.PutAsJsonAsync("/api/v1/server/settings", settings with { HttpPort = 8087, HttpsPort = 8444 }, ProtocolJson.Default.ServerSettingsDto))
|
||||||
|
Assert.Equal("HttpPort", (await refused.ExpectErrorAsync(HttpStatusCode.Conflict, "setting_locked")).Details);
|
||||||
|
// The ports stay as they are, which is valid whatever they are; the host ports go in the public ones.
|
||||||
|
using (var saved = await admin.PutAsJsonAsync("/api/v1/server/settings", settings with { PublicHttpPort = 8087, PublicHttpsPort = 8444 },
|
||||||
|
ProtocolJson.Default.ServerSettingsDto))
|
||||||
|
Assert.False((await saved.ReadAsync(ProtocolJson.Default.ServerSettingsDto)).RestartRequired);
|
||||||
|
Assert.Equal((8087, 8444), (server.Options.PublicHttpPort!.Value, server.Options.PublicHttpsPort!.Value));
|
||||||
|
var file = JsonNode.Parse(await File.ReadAllTextAsync(server.Options.SettingsFile))!.AsObject();
|
||||||
|
Assert.False(file.ContainsKey("HttpPort") || file.ContainsKey("HttpsPort"), "the container's ports are never written");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AContainerIgnoresListeningPortsSavedEarlier()
|
||||||
|
{
|
||||||
|
var root = context.CreateTempDirectory("container");
|
||||||
|
File.WriteAllText(Path.Combine(root, "server.json"), """{ "HttpPort": 8087, "HttpsPort": 8444, "PublicHttpsPort": 8444 }""");
|
||||||
|
Dictionary<string, string?> Env(params (string Name, string Value)[] more)
|
||||||
|
{
|
||||||
|
var env = new Dictionary<string, string?> { ["CHRONOS_DATA_PATH"] = root, ["CHRONOS_DB"] = "postgres" };
|
||||||
|
foreach (var (name, value) in more) env[name] = value;
|
||||||
|
return env;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Outside a container the saved ports apply, as before.
|
||||||
|
var host = ServerOptions.Load(Env());
|
||||||
|
Assert.Equal((8087, 8444, false, false), (host.HttpPort, host.HttpsPort, host.InContainer, host.IgnoredSavedPorts));
|
||||||
|
|
||||||
|
var container = ServerOptions.Load(Env((ServerOptions.ContainerVariable, "true")));
|
||||||
|
Assert.Equal((8080, 8443, true, true), (container.HttpPort, container.HttpsPort, container.InContainer, container.IgnoredSavedPorts));
|
||||||
|
Assert.Equal((int?)8444, container.PublicHttpsPort);
|
||||||
|
|
||||||
|
// A variable still sets a container's port.
|
||||||
|
var variable = ServerOptions.Load(Env((ServerOptions.ContainerVariable, "true"), ("CHRONOS_HTTPS_PORT", "9443")));
|
||||||
|
Assert.Equal((8080, 9443), (variable.HttpPort, variable.HttpsPort));
|
||||||
|
Assert.Equal("CHRONOS_HTTPS_PORT", variable.LockedBy["HttpsPort"]);
|
||||||
|
|
||||||
|
Assert.False(ServerOptions.Load(Env((ServerOptions.ContainerVariable, "false"))).InContainer);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task AContainerRemovesListeningPortsSavedEarlierAtTheNextSave()
|
||||||
|
{
|
||||||
|
await using var server = await TestServer.StartAsync(context, o =>
|
||||||
|
{
|
||||||
|
// As ServerOptions.Load leaves a container whose server.json held ports.
|
||||||
|
o.InContainer = true;
|
||||||
|
o.IgnoredSavedPorts = true;
|
||||||
|
Directory.CreateDirectory(o.DataPath);
|
||||||
|
File.WriteAllText(o.SettingsFile, """{ "HttpPort": 8087, "HttpsPort": 8444, "ServerName": "NAS" }""");
|
||||||
|
});
|
||||||
|
var admin = await server.AdminAsync();
|
||||||
|
// Nothing changed, and still the saved ports go: the panel cannot edit them, so it could never remove them otherwise.
|
||||||
|
using (var saved = await admin.PutAsJsonAsync("/api/v1/server/settings", await SettingsAsync(admin), ProtocolJson.Default.ServerSettingsDto))
|
||||||
|
await saved.ExpectAsync(HttpStatusCode.OK);
|
||||||
|
var file = JsonNode.Parse(await File.ReadAllTextAsync(server.Options.SettingsFile))!.AsObject();
|
||||||
|
Assert.False(file.ContainsKey("HttpPort") || file.ContainsKey("HttpsPort"), "the saved listening ports are removed");
|
||||||
|
Assert.Equal("NAS", file["ServerName"]!.GetValue<string>());
|
||||||
|
Assert.False(server.Options.IgnoredSavedPorts);
|
||||||
|
var restarted = ServerOptions.Load(new Dictionary<string, string?>
|
||||||
|
{
|
||||||
|
["CHRONOS_DATA_PATH"] = server.Options.DataPath,
|
||||||
|
["CHRONOS_DB"] = "postgres",
|
||||||
|
[ServerOptions.ContainerVariable] = "true",
|
||||||
|
});
|
||||||
|
Assert.False(restarted.IgnoredSavedPorts, "the next start no longer warns");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task ASettingsAnswerStaysReadableInTheShapeBeforePublicPorts()
|
||||||
|
{
|
||||||
|
await using var server = await TestServer.StartAsync(context, o => o.PublicHttpsPort = 8444);
|
||||||
|
var admin = await server.AdminAsync();
|
||||||
|
using var read = await admin.GetAsync("/api/v1/server/settings");
|
||||||
|
var json = await read.Content.ReadAsStringAsync();
|
||||||
|
var older = Assert.NotNull(JsonSerializer.Deserialize<SettingsBeforePublicPorts>(json, new JsonSerializerOptions(JsonSerializerDefaults.Web)));
|
||||||
|
var current = Assert.NotNull(JsonSerializer.Deserialize(json, ProtocolJson.Default.ServerSettingsDto));
|
||||||
|
Assert.Equal((current.ServerName, current.HttpsPort, current.Parallelism, current.Logs.FileLevel), (older.ServerName, older.HttpsPort, older.Parallelism, older.Logs.FileLevel));
|
||||||
|
Assert.Equal((int?)8444, current.PublicHttpsPort);
|
||||||
|
|
||||||
|
// And the shape before them deserialises into the current one, the new members at their defaults.
|
||||||
|
var old = JsonSerializer.Serialize(older, new JsonSerializerOptions(JsonSerializerDefaults.Web));
|
||||||
|
var parsed = Assert.NotNull(JsonSerializer.Deserialize(old, ProtocolJson.Default.ServerSettingsDto));
|
||||||
|
Assert.Equal(((int?)null, (int?)null, false), (parsed.PublicHttpPort, parsed.PublicHttpsPort, parsed.InContainer));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task ThePanelShowsThePublicPortsAndTheClientAddress()
|
||||||
|
{
|
||||||
|
await using var server = await TestServer.StartAsync(context);
|
||||||
|
var page = await server.Client.GetStringAsync("/admin/pages/settings.js");
|
||||||
|
foreach (var part in new[] { "publicPort(\"publicHttpPort\"", "publicPort(\"publicHttpsPort\"", "field(\"clientAddress\"", "id=\"copy-address\"",
|
||||||
|
"Admin.Settings.ContainerPort.Tip", "settings.publicHttpsPort ?? settings.httpsPort", "location.origin", "navigator.clipboard.writeText",
|
||||||
|
// The port the page came through over HTTPS wins over a saved one, is offered for the Public HTTPS port,
|
||||||
|
// and saving another one asks first (the HTTPS redirect follows it at once).
|
||||||
|
"pagePort() ?? savedHttps()", "id=\"use-page-port\"", "Admin.Settings.UsePagePort", "Admin.Settings.PortChangeTitle", "confirmDialog({" })
|
||||||
|
Assert.Contains(part, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task<ServerSettingsDto> SettingsAsync(HttpClient admin)
|
||||||
|
{
|
||||||
|
using var read = await admin.GetAsync("/api/v1/server/settings");
|
||||||
|
return await read.ReadAsync(ProtocolJson.Default.ServerSettingsDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Plain HTTP to the panel from another machine, as the owner's browser sends it.</summary>
|
||||||
|
private static DefaultHttpContext AdminRequest()
|
||||||
|
{
|
||||||
|
var request = new DefaultHttpContext();
|
||||||
|
request.Connection.RemoteIpAddress = IPAddress.Parse("192.168.30.50");
|
||||||
|
request.Request.Scheme = "http";
|
||||||
|
request.Request.Host = new HostString("192.168.30.23", 8087);
|
||||||
|
request.Request.Path = "/admin/";
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary><see cref="ServerSettingsDto"/> as it was before owner review 3.</summary>
|
||||||
|
private sealed record SettingsBeforePublicPorts(
|
||||||
|
string ServerName,
|
||||||
|
int HttpPort,
|
||||||
|
int HttpsPort,
|
||||||
|
string TlsMode,
|
||||||
|
string? TlsCert,
|
||||||
|
string? TlsKey,
|
||||||
|
string Language,
|
||||||
|
int Parallelism,
|
||||||
|
bool PriorityQueue,
|
||||||
|
IReadOnlyList<JobPriorityDto> JobPriorities,
|
||||||
|
bool Discovery,
|
||||||
|
long MaxUploadBytes,
|
||||||
|
int ChunkSizeBytes,
|
||||||
|
int JobHistoryDays,
|
||||||
|
int TokenLifetimeDays,
|
||||||
|
int UploadRetentionHours,
|
||||||
|
LogSettingsDto Logs,
|
||||||
|
IReadOnlyList<string> Locked,
|
||||||
|
IReadOnlyDictionary<string, string> LockedBy,
|
||||||
|
bool RestartRequired,
|
||||||
|
bool ProxyWarning);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user