Public Access
Free the terminal from the Hosts screen, and fill the room it left
The WebView sat inside the Hosts grid, so navigating to Files or the keychain hid every open terminal and the strip that named them. A connection you had opened was invisible from four of the five screens. The window now has two surfaces rather than one: a nav rail that says which page you are on, and a terminal strip that is always there and switches the whole content area to a shell. Screen keeps meaning "which page" and never becomes a sixth kind of page, which is why this is two properties instead of one enum with a terminal member in it. Every screen lives inside one wrapper panel that collapses when a terminal is showing. That is not tidiness — the WebView hosts a Win32 child window that composites above everything Avalonia draws, so a screen left visible over its rectangle is a screen sliced in half, and this window has shipped that defect once already. One decision point, IsTerminalShowing, and a nested panel rather than five compound bindings nobody would remember to extend. The focus choreography is the part no test in this repo can see. Every reveal path now focuses in the same turn the WebView appeared, so all three of them post at DispatcherPriority.Loaded and let the native control re-push its bounds first. Going the other way had a real bug: the screen-changed branch called a bare Focus() where it had to release the keyboard from the native child, so switching from a terminal to Files silently ate the first keystrokes. Rare before this commit and the primary gesture after it. The tab strip grew a cross inside each tab, a plus that opens the quick-connect palette, and middle-click close. Nested buttons are correct here: Avalonia handles a left press on the cross and deliberately does not handle other buttons, which is exactly what lets middle-click bubble up from the cross as well as the tab. The test is PointerUpdateKind rather than IsMiddleButtonPressed, because the latter reports button state and is also true for a left press made while the middle button happens to be held. The handler is on the tab and not the strip, so the background closes nothing by construction. Plus opens the palette rather than a flyout, since a menu dropping into the WebView's rectangle may or may not composite above a child HWND and this repo does not make rendering claims it has not photographed. Everything a user reads now says keychain. The wire, the database and the cryptographic spec still say vault, deliberately: renaming those is a migration and a protocol change for a word. That split is written down rather than left to be rediscovered as an inconsistency. Four things that were squeezed into the keychain's category rail, or into nothing at all, now have screens. Pinned host keys get one, with fingerprints never truncated and a filter that matches them, because comparing what you have against what the operator published is the whole workflow; the approved date is read out of the item's UUIDv7 rather than added as a column, and says so, since it means first approval and not last use. Keys can be generated in the client, which needed the openssh-key-v1 container written by hand — there is no BCL or NSec helper, and the PKCS#8 route is unverified in the SSH library this uses. The armour carries no passphrase: encrypting it needs bcrypt_pbkdf, which is Blowfish with a swizzle, in a project whose crypto is otherwise entirely libsodium, for a protection the key's own remarks argue is redundant inside a vault. Generation fills the existing editor and stops, so SAVE stays the one thing that writes. ~/.ssh/config can be imported behind a preview that is ticked per row and writes nothing until the button; IdentityFile records the path and imports the key material only on an explicit opt-in, because reading somebody's private key into a vault is precisely the act this product exists to make deliberate. Match blocks and ProxyJump are reported rather than obeyed — one cannot be evaluated statically and the other has nothing behind it to route with, and a preview that implied otherwise would be worse than one that admits it. Files can be dragged in all four directions that are honestly available. Remote to Explorer does not ship and is not pretended to: the shell wants the bytes during the drop, which needs a virtual file and a native COM data object, outside what Avalonia offers. Note for the next person that Avalonia 12 replaced the drag model outright — DataObject and DataFormats are no-op stubs and IDataObject is not in the reference assembly, so every tutorial written for 11 does not compile here. Hosts can be grouped, flat and never nested. A parent id merged as a scalar lets two offline clients each re-parent A under B and B under A, producing a cycle inside an encrypted payload that no server can police and every reader would have to detect for ever. Membership lives in that payload rather than in the one plaintext concession ADR 0001 allows, whose test is that the relay cannot function without it — nothing on the server reads a group, so what plaintext would hand over is a clustering of the estate for nothing. The plaintext column reserved for it is dropped, provably always null, and the server now refuses a client that sends one; it was never populated, was copied on apply, and was not cleared on delete, so a group id would have outlived the host it described. Snippets insert through xterm rather than through the pump, because xterm is the only thing that knows whether the remote has bracketed paste on, and that is what makes a shell treat embedded newlines as text instead of as execute. The host process moves opaque bytes and never parses output, so it would have to guess, and guessing wrong runs every line. Running is off by default and the copy says the text goes into whatever is there — the terminal has no notion of being at a prompt, and may be in vi or at a password prompt with echo off, so the Enter the user presses themselves is the entire safety property. Connections and keychain changes are recorded as synced encrypted items, which is what makes them auditable by a team later and costs the server knowledge of connection rate and timing from row counts alone. ADR 0001 already concedes it cannot hide that class of metadata; the trade is now written into it rather than left implicit. A connection entry is written once, at close, which is what makes a synced log tractable: nothing to merge, one outbox row, no chance of colliding with itself. Live sessions come from memory, not from the log. The write is void by contract and posts to a bounded channel, because putting an encrypt-and-write on the teardown path of every session is how closing the application comes to take four seconds. A ticket opened before a lock still closes afterwards, since a shell outlives the vault. The activity log hooks the one generic repository every kind writes through, so it cannot miss a caller — which is also why the log kinds themselves declare they are not audited, or the first entry would write an entry about writing an entry. It records the names of the fields that changed and never their values; a log with an old password in it would be a plaintext credential store with no vault around it. Retention is 90 days or 5,000 entries, whichever bites first, pruned on the sync loop rather than on a second timer. That log traffic then broke the status line, which is worth recording because the fix is a shape and not a patch: background sync counted its own log rows as pushed items, so the quiet rule stopped being quiet and every action's message was overwritten a second later by a sync report. The report now separates log rows from user items and the rule reads the latter. S3 buckets appear as a remote in the file browser, behind the same interface an SFTP session implements, so the queue and both panes did not have to learn what they are talking to. Uploads go through a pipe, because the queue wants to write and the SDK wants to read; memory is then bounded by the part size instead of buffering a file to disk twice. Finally, the Windows device key store moved out of the session project, which was the one thing keeping it from being portable — everything else in it is platform-neutral, and a Windows CNG dependency in the middle of the vault code meant a second head could not reference it without dragging Windows along. The seam that made the move free was already there. docs/android-port.md is the audit behind that: what ports, what does not, in order of cost, the four decisions taken, and an inventory of every screen and state the interface has to carry, written so a design can be made from it directly. dotnet build, dotnet test and dotnet format --verify-no-changes are all clean: 1240 tests at zero warnings, including the end-to-end suite against real containers. The manual checks that headless Avalonia cannot make — the drag from Explorer, a generated key against a real host, twelve tabs at the minimum window width — are listed in docs/manual-checks.md and are still outstanding.
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
namespace DodoSSH.Client.Terminal;
|
||||
|
||||
/// <summary>
|
||||
/// Somewhere to record that a connection happened, and how long it lasted.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// <b>Declared here and implemented two layers up.</b> <c>DodoSSH.Client.Terminal</c> references only
|
||||
/// <c>DodoSSH.Client.Ssh</c> and cannot see the sync layer at all — which is deliberate, because the
|
||||
/// workspace has to keep running with the vault locked and a direct dependency would invite the opposite.
|
||||
/// So this is the shape of the hole, and <c>ConnectionRecorder</c> in <c>DodoSSH.Client.Session</c> is what
|
||||
/// fills it.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <b>Both methods return <see langword="void"/> by contract.</b> <see cref="Closed"/>'s only caller is a
|
||||
/// <c>finally</c> unwinding on a thread-pool thread as a session tears down — including inside the loop that
|
||||
/// runs when the application is closing — and an encrypt-and-write there is how shutting down comes to take
|
||||
/// four seconds per open tab. An implementation must hand the work to something else and return.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// A null sink is a workspace that records nothing, which is what every test and every not-yet-unlocked
|
||||
/// process has.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public interface IConnectionLogSink
|
||||
{
|
||||
/// <summary>
|
||||
/// Notes that a connection has opened.
|
||||
/// </summary>
|
||||
/// <param name="sessionId">The session, as the workspace knows it.</param>
|
||||
/// <param name="address">The address as dialled.</param>
|
||||
/// <param name="startedAt">When it opened.</param>
|
||||
/// <remarks>
|
||||
/// Called only after the connection has genuinely been made, so a host-key refusal never arrives here as
|
||||
/// a session that started. Those are recorded separately, by the code that holds the typed exception.
|
||||
/// </remarks>
|
||||
void Opened(uint sessionId, string address, DateTimeOffset startedAt);
|
||||
|
||||
/// <summary>
|
||||
/// Notes that the connection has ended, whatever ended it.
|
||||
/// </summary>
|
||||
/// <param name="sessionId">The session that has ended.</param>
|
||||
/// <param name="endedAt">When it ended.</param>
|
||||
/// <remarks>
|
||||
/// One method for a tab close, a remote hangup and a process shutdown, because all three funnel through
|
||||
/// the same <c>finally</c> — and because the difference between them is not something this client can
|
||||
/// establish honestly. A session id that was never opened, or has already been closed out, is ignored.
|
||||
/// </remarks>
|
||||
void Closed(uint sessionId, DateTimeOffset endedAt);
|
||||
}
|
||||
@@ -53,6 +53,29 @@ public enum TerminalServerOpcode : byte
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
SessionRemoved = 5,
|
||||
|
||||
/// <summary>
|
||||
/// Text to insert into this session, as if it had been pasted.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Payload is one flag byte — non-zero to press Enter after the text — followed by UTF-8.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <b>Through the renderer rather than straight into the input stream, and that is the whole reason this
|
||||
/// opcode exists.</b> Writing the bytes to the pump would have been fewer lines and is wrong: xterm.js
|
||||
/// watches the remote for <c>\e[?2004h</c> and wraps pasted text in bracketed-paste markers when the mode
|
||||
/// is on, which is what makes a shell treat embedded newlines as text instead of as "run this". The host
|
||||
/// process cannot do that — <c>TerminalDataPlane</c> moves opaque bytes and never parses output — so it
|
||||
/// would have to guess, and guessing wrong executes every line of a multi-line snippet.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The flag is separate from the text for the same reason. A trailing newline inside the payload would be
|
||||
/// wrapped along with everything else and arrive at the shell as a literal character; the Enter has to go
|
||||
/// through <c>term.input</c>, <em>outside</em> the wrapper, or nothing runs.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
Paste = 6,
|
||||
}
|
||||
|
||||
/// <summary>Frames the renderer sends to the host.</summary>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using DodoSSH.Client.Ssh;
|
||||
|
||||
namespace DodoSSH.Client.Terminal;
|
||||
@@ -96,6 +98,24 @@ public sealed class TerminalWorkspace : IAsyncDisposable
|
||||
dataPlane = new TerminalDataPlane(assets);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Where connections are recorded, or null to record none.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Settable rather than a constructor parameter, because the two objects have different lifetimes and
|
||||
/// the workspace's is the longer one: it is composed at startup and outlives every lock, while anything
|
||||
/// that can write to a vault exists only while one is open. Locking sets this back to null, and the
|
||||
/// sessions that were already running go on running with nothing recording them.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Which means an entry can be missed — a shell open across a lock and closed after it. The recorder
|
||||
/// holds its store for close-out past <c>Close()</c> precisely so that the common case does not, and the
|
||||
/// residue is stated here rather than papered over.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public IConnectionLogSink? ConnectionLog { get; set; }
|
||||
|
||||
/// <summary>Where the WebView should navigate.</summary>
|
||||
public Uri PageUrl => dataPlane.PageUrl;
|
||||
|
||||
@@ -224,6 +244,12 @@ public sealed class TerminalWorkspace : IAsyncDisposable
|
||||
|
||||
dataPlane.Register(sessionId, pump);
|
||||
|
||||
// After the connection succeeded and before the run begins. Ordered that way for two reasons: a
|
||||
// host-key refusal throws out of ConnectAsync above and must never be recorded as a session that
|
||||
// started, and a session whose shell ends immediately must already have a ticket open for the
|
||||
// finally below to close.
|
||||
ConnectionLog?.Opened(sessionId, Describe(request), clock.GetUtcNow());
|
||||
|
||||
// Registered before running, so an acknowledgement that arrives with the very first output
|
||||
// frame has somewhere to go.
|
||||
var run = RunSessionAsync(sessionId, pump);
|
||||
@@ -257,6 +283,58 @@ public sealed class TerminalWorkspace : IAsyncDisposable
|
||||
TerminalFrame.Create((byte)TerminalServerOpcode.SessionActivated, sessionId, []),
|
||||
cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Inserts text into one terminal, as if it had been pasted there.
|
||||
/// </summary>
|
||||
/// <param name="sessionId">The terminal to insert into.</param>
|
||||
/// <param name="text">What to insert. Sent verbatim.</param>
|
||||
/// <param name="execute">Whether to press Enter afterwards.</param>
|
||||
/// <param name="cancellationToken">Cancellation.</param>
|
||||
/// <returns>
|
||||
/// <see langword="false"/> when that session's shell is not running, which is an ordinary answer rather
|
||||
/// than an error: a tab whose remote hung up an hour ago is still on screen and still selectable, and
|
||||
/// somebody clicking a snippet at it has made a mistake worth a sentence, not an exception.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// <b>Refused for a dead session rather than sent and dropped.</b> The transport discards frames for a
|
||||
/// pane the page no longer has, so sending regardless would look exactly like success — and the one thing
|
||||
/// somebody inserting a command needs to know is whether it arrived.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The liveness check and the send are deliberately not atomic. A shell that ends between the two is a
|
||||
/// race no lock can close — the remote could hang up while the frame is in the socket — so the check is
|
||||
/// there to catch the ordinary case honestly, not to make a guarantee it cannot keep.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public async Task<bool> PasteAsync(
|
||||
uint sessionId,
|
||||
string text,
|
||||
bool execute,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(text);
|
||||
|
||||
if (!IsSessionLive(sessionId))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var utf8 = Encoding.UTF8.GetBytes(text);
|
||||
var payload = new byte[1 + utf8.Length];
|
||||
|
||||
payload[0] = execute ? (byte)1 : (byte)0;
|
||||
utf8.CopyTo(payload, 1);
|
||||
|
||||
await dataPlane
|
||||
.SendAsync(
|
||||
TerminalFrame.Create((byte)TerminalServerOpcode.Paste, sessionId, payload),
|
||||
cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes one terminal.
|
||||
/// </summary>
|
||||
@@ -363,6 +441,13 @@ public sealed class TerminalWorkspace : IAsyncDisposable
|
||||
{
|
||||
dataPlane.Unregister(sessionId);
|
||||
|
||||
// Unconditional, and this one hook covers all three ways a session ends: the user closing the
|
||||
// tab, the remote hanging up, and the process shutting down. Every one of them arrives here as
|
||||
// the pump unwinding, which is why CloseSessionAsync needs no call of its own — and why this
|
||||
// must not do any work: it is running on a thread-pool thread inside DisposeAsync's loop when
|
||||
// the application is closing.
|
||||
ConnectionLog?.Closed(sessionId, clock.GetUtcNow());
|
||||
|
||||
// Only when the session is still one this workspace knows about. CloseSessionAsync removes the
|
||||
// entry before it disposes the pump, so a tab the user closed does not come back as news.
|
||||
bool announce;
|
||||
@@ -379,5 +464,17 @@ public sealed class TerminalWorkspace : IAsyncDisposable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The address as dialled, for the log.</summary>
|
||||
/// <remarks>
|
||||
/// The username is in here because it is part of the address that was dialled, and an address without one
|
||||
/// does not identify the connection — two people reaching one machine as different accounts is the
|
||||
/// ordinary case. This is <em>not</em> the same as recording which account authenticated: nothing here
|
||||
/// reads the credential, and the payload has no field for one.
|
||||
/// </remarks>
|
||||
private static string Describe(SshConnectionRequest request) =>
|
||||
string.Create(
|
||||
CultureInfo.InvariantCulture,
|
||||
$"{request.Username}@{request.Host}:{request.Port}");
|
||||
|
||||
private sealed record LiveSession(ISshConnection Connection, TerminalSessionPump Pump, Task Run);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
"dodossh.client.ssh": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"NSec.Cryptography": "[26.4.0, )",
|
||||
"SSH.NET": "[2025.1.0, )"
|
||||
}
|
||||
},
|
||||
@@ -39,6 +40,21 @@
|
||||
"resolved": "2.6.2",
|
||||
"contentHash": "7oWOcvnntmMKNzDLsdxAYqApt+AjpRpP2CShjMfIa3umZ42UQMvH0tl1qAliYPNYO6vTdcGMqnRrCPmsfzTI1w=="
|
||||
},
|
||||
"libsodium": {
|
||||
"type": "CentralTransitive",
|
||||
"requested": "[1.0.22, )",
|
||||
"resolved": "1.0.22",
|
||||
"contentHash": "KPD9SloJFclrsjnhABu7dzWrcyYkwPbvx5l1gRSPAX/0n+OBtSiVCKtGFv4n+ecWUHU0tCG9LSSwoZZx673zBQ=="
|
||||
},
|
||||
"NSec.Cryptography": {
|
||||
"type": "CentralTransitive",
|
||||
"requested": "[26.4.0, )",
|
||||
"resolved": "26.4.0",
|
||||
"contentHash": "0vsCtY5f+YgQROiWNqzgWp+l2pddfk9FkWoGV/bEo0MuEYPKlJWuoA8aOfO6qp3f+EnObKE3zSJhn1PspJeJVg==",
|
||||
"dependencies": {
|
||||
"libsodium": "[1.0.22, 1.0.23)"
|
||||
}
|
||||
},
|
||||
"SSH.NET": {
|
||||
"type": "CentralTransitive",
|
||||
"requested": "[2025.1.0, )",
|
||||
|
||||
Reference in New Issue
Block a user