fix(server): public ports as settings, container port lock and client address; clients default to 8443 and name non-Chronos servers
The owner's Uploader could not connect: the panel showed the container's listening ports (8080/8443) as if clients used them, the public ports were only environment variables (CHRONOS_PUBLIC_HTTP_PORT not even in the Unraid template), and the clients mapped a bare host to 443, where another service answered. - Public HTTP/HTTPS ports are settings (server.json, or locked by CHRONOS_PUBLIC_*) and apply at once; ServerSettingsDto gains appended PublicHttpPort, PublicHttpsPort and InContainer members. - In a container the listening ports are fixed by the template: locked in the panel, and saved values from earlier versions are ignored with a warning. - Settings > Network and TLS shows the client address with a Copy button; the discovery tooltip says a container needs network type Host. - ChronosAddress (shared by Chronos and the Uploader): no scheme and no port is https on 8443, https:// keeps 443, a typed port is kept, IPv6 is bracketed. - GetInfoAsync throws NotChronosServerException for answers that are not a Chronos server; another service's certificate is never offered for trust and no credentials are sent to it. Both clients name the address asked. - Unraid template, compose file, user guide, README, BRIEF, DECISIONS, CHANGELOG (with an Unraid upgrade note) and ARCHITECTURE updated; en/it strings added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9b24cf74fc
commit
369e754bec
33 files changed
+862
-82
No files matched your search
@@ -212,7 +212,7 @@ public sealed class ServerViewModel : SectionViewModel
|
||||
Shell.Settings.Encoders.CollectionChanged += OnEncodersChanged;
|
||||
Sync.Attach();
|
||||
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()
|
||||
@@ -253,7 +253,7 @@ public sealed class ServerViewModel : SectionViewModel
|
||||
Address = ServerAddress.Display(Session.SavedAddress);
|
||||
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()
|
||||
|
||||
@@ -269,6 +269,7 @@ public sealed class ConnectFlow(IServerApiFactory factory, ITrustStore trust) :
|
||||
internal static ConnectError? Classify(Exception ex, CancellationToken ct) => ex switch
|
||||
{
|
||||
UntrustedCertificateException => ConnectError.Untrusted,
|
||||
NotChronosServerException => ConnectError.NotChronos,
|
||||
ChronosApiException { Status: HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden } => ConnectError.BadCredentials,
|
||||
ChronosApiException { Status: HttpStatusCode.NotFound } => ConnectError.NotChronos,
|
||||
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>
|
||||
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>
|
||||
public static bool TryParse(string? text, out Uri 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;
|
||||
}
|
||||
/// <summary>
|
||||
/// 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).
|
||||
/// </summary>
|
||||
public static bool TryParse(string? text, out Uri uri) => ChronosAddress.TryParse(text, out uri);
|
||||
|
||||
/// <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('/');
|
||||
|
||||
@@ -150,7 +150,7 @@ public sealed class ServerSession : ObservableObject, ITrustStore, IDisposable
|
||||
{
|
||||
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.
|
||||
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)
|
||||
{
|
||||
@@ -198,8 +198,13 @@ public sealed class ServerSession : ObservableObject, ITrustStore, IDisposable
|
||||
_flow.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>One sentence for a failed step (BRIEF §0.2 rule 6).</summary>
|
||||
public static string ErrorText(ConnectError error) => Loc.L("Server.Error." + error);
|
||||
/// <summary>
|
||||
/// 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>
|
||||
public static ConfirmRequest TrustRequest(string server, string fingerprint) => new()
|
||||
|
||||
Reference in new issue
Block a user