fix(server): client address from the page's port, stricter Chronos identity, Host networking notes
Review fixes on top of the public ports change (owner review 3): - Settings > Network and TLS: opened over HTTPS, the client address uses the port the page came through (a container's 8443 published as 8444 with Public HTTPS port still empty showed the wrong 8443), and a "Use <port>" button fills that port in. Saving a Public HTTPS port other than the page's asks first, since the HTTPS redirect follows it at once and a typo would lock the panel's link out. - GetInfoAsync tells Chronos from other services by stricter rules on both the trusted and the untrusted-certificate path: any redirect, any answer that is not JSON, more than 1 MB, or an error without the X-Chronos-Api header is not Chronos. Another service's certificate is no longer offered for trust after a cross-scheme redirect, an error page or a JSON 401/403/404, and a JSON 401 over HTTP no longer reads as a wrong password. - The HTTP port typed without a scheme (TLS to a plain HTTP port) now gives the not-Chronos error 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 index is refused instead of losing it. - In a container, the first save of the settings removes HttpPort/HttpsPort from server.json, so the start-up warning stops; the warning says so. - Guide, README, compose and template: with network type Host the mappings do nothing and CHRONOS_HTTP_PORT / CHRONOS_HTTPS_PORT move the listening ports off ones another service uses; the template overview is back to two sentences. - BRIEF, DECISIONS and CHANGELOG updated; en/it strings added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
369e754bec
commit
0aa2fb8135
19 files changed
+303
-67
No files matched your search
@@ -166,6 +166,34 @@ public sealed class PublicPortTests(TestContext context)
|
||||
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()
|
||||
{
|
||||
@@ -190,7 +218,10 @@ public sealed class PublicPortTests(TestContext context)
|
||||
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" })
|
||||
"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);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user