Public Access
Add the SSH session layer and the terminal data plane
The throughput harness the plan requires before any UI, plus the SSH plumbing under it. 94 new tests, no WebView involved. Credit-based flow control is what makes `yes` survivable. A terminal renders at 60 Hz at best while a remote produces output as fast as the network allows, and the difference has to accumulate somewhere or be refused. Credit is reserved *before* reading, never after: because the pump cannot read more than the renderer has room for, the coalescing buffer is bounded by the window rather than by how fast the remote can talk. When credit runs out the pump stops reading, SSH's own receive window closes, and the remote sshd blocks -- backpressure to the source with no custom protocol. Verified by falsification, not just by passing: with the credit gate removed three tests fail, including the throughput harness's bounded-memory assertion. Acknowledgements are clamped because they cross into JavaScript, where a buggy or hostile page could otherwise claim to have rendered a gigabyte and talk the host into an unbounded read. Host key trust is enforced by *failing* the connection rather than prompting inside the handshake. SSH.NET raises verification synchronously, so consulting the user there would block the handshake on a UI round trip and deadlock the first time the prompt needed the UI thread. Unknown host and changed key become distinct exceptions the caller resolves asynchronously. A mismatch has no retry path at all: a dialog offering to continue is how users are trained to click through the one warning that actually indicates interception. A legitimately rebuilt server is handled by removing the pin in settings, away from the moment of connecting. The data plane serves the renderer page from the same loopback listener as the socket, which makes Origin predictable -- always http://127.0.0.1:{port} -- where a WebView virtual-host mapping would give a different origin per backend and nothing to validate. The token is substituted at serve time, so it never touches disk and never appears in a URL. Being clear about what that buys: not protection from a process running as this user, which can read our memory anyway, but from a page in the user's browser attempting WebSocket connections to loopback ports, which is a real and routine thing. Two bugs the tests caught. The accept loop handled connections serially, so an upgraded WebSocket parked it inside the receive loop and every later request went unanswered -- the page's own script among them. The suite hung rather than failed, which is how I found it. And SHA-1 is unavoidable here: RFC 6455 mandates it for Sec-WebSocket-Accept, where it authenticates nothing. Suppressed narrowly with that reasoning; the alternative, HttpListener.AcceptWebSocketAsync, throws PlatformNotSupportedException off Windows.
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
namespace DodoSSH.Client.Ssh;
|
||||
|
||||
/// <summary>A host key as the server presented it during the handshake.</summary>
|
||||
/// <param name="Host">Host as dialled.</param>
|
||||
/// <param name="Port">Port as dialled.</param>
|
||||
/// <param name="Algorithm">Key algorithm, e.g. <c>ssh-ed25519</c>.</param>
|
||||
/// <param name="Fingerprint">OpenSSH-style fingerprint, from <see cref="SshHostKeyFingerprint"/>.</param>
|
||||
public sealed record HostKeyPresentation(string Host, int Port, string Algorithm, string Fingerprint);
|
||||
|
||||
/// <summary>
|
||||
/// The trusted host keys a user has accumulated.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Known hosts live in the end-to-end encrypted vault as a synced entity, not in a local file. Trust
|
||||
/// then follows the user to every device, and the server cannot tamper with it — which matters,
|
||||
/// because a server that could silently drop a pin could downgrade every connection to first-use.
|
||||
/// </remarks>
|
||||
public interface IKnownHostStore
|
||||
{
|
||||
/// <summary>Returns the pinned fingerprint for a host and key algorithm, if there is one.</summary>
|
||||
/// <remarks>
|
||||
/// Keyed on algorithm as well as host, because a server legitimately offers several host keys and
|
||||
/// which one is negotiated can change between connections. Pinning only one and rejecting the
|
||||
/// others would make a normal server look hostile.
|
||||
/// </remarks>
|
||||
ValueTask<string?> FindAsync(string host, int port, string algorithm, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>Records a host key as trusted.</summary>
|
||||
ValueTask TrustAsync(HostKeyPresentation presentation, CancellationToken cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The host has never been seen, so there is nothing to compare against.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A distinct exception rather than a prompt inside the handshake, and that is a deliberate design
|
||||
/// choice. SSH.NET raises host key verification as a synchronous event, so consulting the user from
|
||||
/// inside it would mean blocking the handshake thread on a UI round trip — sync-over-async, and a
|
||||
/// deadlock the first time the prompt needs the UI thread. Failing the connection and letting the
|
||||
/// caller prompt keeps everything asynchronous, at the cost of a second TCP connection the first
|
||||
/// time a host is used.
|
||||
/// </remarks>
|
||||
public sealed class SshHostKeyUnknownException(HostKeyPresentation presentation)
|
||||
: Exception($"The host key for {presentation.Host}:{presentation.Port} is not trusted yet.")
|
||||
{
|
||||
/// <summary>The key the server offered, to show the user before they trust it.</summary>
|
||||
public HostKeyPresentation Presentation { get; } = presentation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The host presented a different key from the one pinned for it.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This must stay a hard block with no "continue anyway" in the connect path. A dialog offering to
|
||||
/// proceed is how users are trained to click through the one warning that actually indicates an
|
||||
/// interception. A legitimate key change — a rebuilt server — is handled by explicitly removing the
|
||||
/// pin in the host's settings, which is a deliberate act performed away from the moment of
|
||||
/// connecting.
|
||||
/// </remarks>
|
||||
public sealed class SshHostKeyMismatchException(HostKeyPresentation presentation, string pinnedFingerprint)
|
||||
: Exception(
|
||||
$"The host key for {presentation.Host}:{presentation.Port} has changed. "
|
||||
+ $"Pinned {pinnedFingerprint}, but the server offered {presentation.Fingerprint}.")
|
||||
{
|
||||
/// <summary>The key the server offered.</summary>
|
||||
public HostKeyPresentation Presentation { get; } = presentation;
|
||||
|
||||
/// <summary>The key previously trusted for this host.</summary>
|
||||
public string PinnedFingerprint { get; } = pinnedFingerprint;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A known-host store held in memory.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Stands in until the encrypted local cache lands. Trust is lost when the process exits, so a user
|
||||
/// is asked about every host on every launch — noisy, but the noise is the correct failure mode for a
|
||||
/// placeholder: it cannot be mistaken for working persistence.
|
||||
/// </remarks>
|
||||
public sealed class InMemoryKnownHostStore : IKnownHostStore
|
||||
{
|
||||
private readonly Dictionary<string, string> pins = new(StringComparer.Ordinal);
|
||||
private readonly Lock gate = new();
|
||||
|
||||
/// <inheritdoc />
|
||||
public ValueTask<string?> FindAsync(
|
||||
string host,
|
||||
int port,
|
||||
string algorithm,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
lock (gate)
|
||||
{
|
||||
return ValueTask.FromResult(pins.GetValueOrDefault(Key(host, port, algorithm)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ValueTask TrustAsync(HostKeyPresentation presentation, CancellationToken cancellationToken)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(presentation);
|
||||
|
||||
lock (gate)
|
||||
{
|
||||
pins[Key(presentation.Host, presentation.Port, presentation.Algorithm)] =
|
||||
presentation.Fingerprint;
|
||||
}
|
||||
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
|
||||
private static string Key(string host, int port, string algorithm) =>
|
||||
$"{host}:{port}/{algorithm}";
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
namespace DodoSSH.Client.Ssh;
|
||||
|
||||
/// <summary>How to authenticate to a host.</summary>
|
||||
/// <remarks>
|
||||
/// Always decrypted from the vault immediately before use and never persisted outside it. Because
|
||||
/// SSH terminates on the client, using a credential requires its plaintext here — which is exactly
|
||||
/// why the <c>Connect</c> permission is a UI hint and not an enforceable boundary. See ADR 0001.
|
||||
/// </remarks>
|
||||
public abstract record SshCredential;
|
||||
|
||||
/// <summary>Password authentication, and keyboard-interactive where the server prefers it.</summary>
|
||||
public sealed record SshPasswordCredential(string Password) : SshCredential;
|
||||
|
||||
/// <summary>Public-key authentication.</summary>
|
||||
/// <param name="PrivateKeyPem">The private key in PEM form, as stored in the vault.</param>
|
||||
/// <param name="Passphrase">Passphrase protecting the key, when it has one.</param>
|
||||
public sealed record SshPrivateKeyCredential(byte[] PrivateKeyPem, string? Passphrase) : SshCredential;
|
||||
|
||||
/// <summary>Everything needed to reach one host.</summary>
|
||||
/// <param name="Host">Hostname or address.</param>
|
||||
/// <param name="Port">Port.</param>
|
||||
/// <param name="Username">Remote account.</param>
|
||||
/// <param name="Credential">How to authenticate.</param>
|
||||
/// <param name="ConnectTimeout">How long to wait for the transport and handshake.</param>
|
||||
public sealed record SshConnectionRequest(
|
||||
string Host,
|
||||
int Port,
|
||||
string Username,
|
||||
SshCredential Credential,
|
||||
TimeSpan? ConnectTimeout = null);
|
||||
|
||||
/// <summary>An interactive shell over a pseudo-terminal.</summary>
|
||||
public interface ISshShellSession : IAsyncDisposable
|
||||
{
|
||||
/// <summary>Whether the channel is still usable.</summary>
|
||||
bool IsOpen { get; }
|
||||
|
||||
/// <summary>Reads whatever output is available, blocking until at least one byte arrives.</summary>
|
||||
/// <returns>Bytes read, or 0 once the remote closes the channel.</returns>
|
||||
ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>Sends keystrokes to the remote.</summary>
|
||||
ValueTask WriteAsync(ReadOnlyMemory<byte> data, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Tells the remote the terminal has been resized.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Verified to reach the remote against a real sshd; see <c>PtyAndResizeSpikeTests</c>. Sizes
|
||||
/// that are not <see cref="TerminalSize.IsUsable"/> are dropped rather than forwarded.
|
||||
/// </remarks>
|
||||
void Resize(TerminalSize size);
|
||||
}
|
||||
|
||||
/// <summary>An authenticated connection to one host.</summary>
|
||||
public interface ISshConnection : IAsyncDisposable
|
||||
{
|
||||
/// <summary>Whether the transport is still up.</summary>
|
||||
bool IsConnected { get; }
|
||||
|
||||
/// <summary>The host key that was accepted for this connection.</summary>
|
||||
HostKeyPresentation HostKey { get; }
|
||||
|
||||
/// <summary>Opens an interactive shell with a pseudo-terminal.</summary>
|
||||
Task<ISshShellSession> OpenShellAsync(TerminalSize size, CancellationToken cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>Opens connections, enforcing host key trust before authenticating.</summary>
|
||||
public interface ISshConnectionFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Connects and authenticates.
|
||||
/// </summary>
|
||||
/// <exception cref="SshHostKeyUnknownException">
|
||||
/// The host has no pinned key. The caller must show the fingerprint, and only on explicit
|
||||
/// confirmation record it via <see cref="IKnownHostStore.TrustAsync"/> and retry.
|
||||
/// </exception>
|
||||
/// <exception cref="SshHostKeyMismatchException">
|
||||
/// The presented key differs from the pin. There is no retry path: this is a hard block.
|
||||
/// </exception>
|
||||
Task<ISshConnection> ConnectAsync(SshConnectionRequest request, CancellationToken cancellationToken);
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
using System.Text;
|
||||
using Renci.SshNet;
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace DodoSSH.Client.Ssh;
|
||||
|
||||
/// <summary>
|
||||
/// Opens SSH connections with SSH.NET, checking host key trust during the handshake.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The pinned fingerprint is looked up <em>before</em> connecting, so the comparison inside SSH.NET's
|
||||
/// synchronous <c>HostKeyReceived</c> event is a pure equality check with no I/O and no chance of
|
||||
/// blocking the handshake on a UI round trip. Anything the comparison cannot settle becomes an
|
||||
/// exception the caller resolves asynchronously.
|
||||
/// </remarks>
|
||||
public sealed class SshNetConnectionFactory(IKnownHostStore knownHosts) : ISshConnectionFactory
|
||||
{
|
||||
private static readonly TimeSpan DefaultConnectTimeout = TimeSpan.FromSeconds(15);
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<ISshConnection> ConnectAsync(
|
||||
SshConnectionRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(request);
|
||||
|
||||
var client = new SshClient(BuildConnectionInfo(request));
|
||||
var gate = new HostKeyGate(knownHosts, request, cancellationToken);
|
||||
|
||||
client.HostKeyReceived += gate.OnHostKeyReceived;
|
||||
|
||||
try
|
||||
{
|
||||
await client.ConnectAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception exception) when (exception is SshConnectionException or SshAuthenticationException)
|
||||
{
|
||||
client.Dispose();
|
||||
|
||||
// Translate a refusal we caused ourselves into something the caller can act on. Without
|
||||
// this the user sees "connection lost" for what is really "do you trust this key?".
|
||||
throw gate.TranslateFailure() ?? exception;
|
||||
}
|
||||
catch
|
||||
{
|
||||
client.Dispose();
|
||||
throw;
|
||||
}
|
||||
|
||||
return new SshNetConnection(client, gate.Presented!);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decides host key trust during the handshake, and remembers enough to explain a refusal.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Separate from the connect method because the decision is the security-relevant part and reads
|
||||
/// better on its own: pinned and equal accepts, pinned and different refuses as a mismatch,
|
||||
/// unpinned refuses as unknown. There is no fourth branch, and there is no prompt.
|
||||
/// </remarks>
|
||||
private sealed class HostKeyGate(
|
||||
IKnownHostStore knownHosts,
|
||||
SshConnectionRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
/// <summary>What the server offered, once the handshake has reached that point.</summary>
|
||||
public HostKeyPresentation? Presented { get; private set; }
|
||||
|
||||
private string? pinned;
|
||||
private bool mismatch;
|
||||
|
||||
public void OnHostKeyReceived(object? sender, HostKeyEventArgs e)
|
||||
{
|
||||
var presentation = new HostKeyPresentation(
|
||||
request.Host,
|
||||
request.Port,
|
||||
e.HostKeyName,
|
||||
SshHostKeyFingerprint.Format(e.HostKey));
|
||||
|
||||
Presented = presentation;
|
||||
|
||||
// Looked up here rather than before connecting, because the negotiated algorithm is only
|
||||
// known now and a server may choose a different one than it did last time.
|
||||
//
|
||||
// This is the one place the design cannot stay asynchronous: SSH.NET raises host key
|
||||
// verification synchronously. It is a local store read rather than a UI round trip, and
|
||||
// making the store synchronous instead would rule out a vault-backed implementation.
|
||||
pinned = knownHosts
|
||||
.FindAsync(request.Host, request.Port, e.HostKeyName, cancellationToken)
|
||||
.AsTask()
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
|
||||
if (pinned is null)
|
||||
{
|
||||
// Refused, not prompted. The caller decides, off the handshake thread.
|
||||
e.CanTrust = false;
|
||||
return;
|
||||
}
|
||||
|
||||
var matches = SshHostKeyFingerprint.Equal(pinned, presentation.Fingerprint);
|
||||
mismatch = !matches;
|
||||
e.CanTrust = matches;
|
||||
}
|
||||
|
||||
/// <summary>The specific exception for a refusal this gate caused, or null if it did not.</summary>
|
||||
public Exception? TranslateFailure()
|
||||
{
|
||||
if (Presented is not { } presentation)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (mismatch && pinned is { } pin)
|
||||
{
|
||||
return new SshHostKeyMismatchException(presentation, pin);
|
||||
}
|
||||
|
||||
return pinned is null ? new SshHostKeyUnknownException(presentation) : null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// The known-host lookup inside the synchronous event is the one place this design cannot avoid
|
||||
/// blocking. It is a local store read rather than a UI round trip, and the alternative — making
|
||||
/// the store synchronous — would rule out the encrypted vault-backed implementation entirely.
|
||||
/// </remarks>
|
||||
private static ConnectionInfo BuildConnectionInfo(SshConnectionRequest request)
|
||||
{
|
||||
AuthenticationMethod method = request.Credential switch
|
||||
{
|
||||
SshPasswordCredential password =>
|
||||
new PasswordAuthenticationMethod(request.Username, password.Password),
|
||||
|
||||
SshPrivateKeyCredential key => new PrivateKeyAuthenticationMethod(
|
||||
request.Username,
|
||||
CreatePrivateKeyFile(key)),
|
||||
|
||||
_ => throw new NotSupportedException(
|
||||
$"Credential type {request.Credential.GetType().Name} is not supported."),
|
||||
};
|
||||
|
||||
return new ConnectionInfo(request.Host, request.Port, request.Username, method)
|
||||
{
|
||||
Timeout = request.ConnectTimeout ?? DefaultConnectTimeout,
|
||||
};
|
||||
}
|
||||
|
||||
private static PrivateKeyFile CreatePrivateKeyFile(SshPrivateKeyCredential credential)
|
||||
{
|
||||
using var stream = new MemoryStream(credential.PrivateKeyPem, writable: false);
|
||||
|
||||
return credential.Passphrase is null
|
||||
? new PrivateKeyFile(stream)
|
||||
: new PrivateKeyFile(stream, credential.Passphrase);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>An SSH.NET-backed connection.</summary>
|
||||
internal sealed class SshNetConnection(SshClient client, HostKeyPresentation hostKey) : ISshConnection
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public bool IsConnected => client.IsConnected;
|
||||
|
||||
/// <inheritdoc />
|
||||
public HostKeyPresentation HostKey { get; } = hostKey;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<ISshShellSession> OpenShellAsync(TerminalSize size, CancellationToken cancellationToken)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var effective = size.IsUsable ? size : TerminalSize.Default;
|
||||
|
||||
// 4 KiB read buffer inside SSH.NET. Output is coalesced a layer up, so a larger buffer here
|
||||
// only delays the first byte reaching the screen.
|
||||
var shell = client.CreateShellStream(
|
||||
"xterm-256color",
|
||||
effective.Columns,
|
||||
effective.Rows,
|
||||
effective.PixelWidth,
|
||||
effective.PixelHeight,
|
||||
4096);
|
||||
|
||||
return Task.FromResult<ISshShellSession>(new SshNetShellSession(shell));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ValueTask DisposeAsync()
|
||||
{
|
||||
client.Dispose();
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>An SSH.NET-backed shell session.</summary>
|
||||
internal sealed class SshNetShellSession(ShellStream shell) : ISshShellSession
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public bool IsOpen => shell.CanRead;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <remarks>
|
||||
/// <c>ShellStream</c> does not override <c>ReadAsync</c>, so the base <see cref="Stream"/>
|
||||
/// implementation runs the blocking read on a thread-pool thread. Every idle session therefore
|
||||
/// parks one thread; see docs/platform-flags.md.
|
||||
/// </remarks>
|
||||
public ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken) =>
|
||||
shell.ReadAsync(buffer, cancellationToken);
|
||||
|
||||
/// <inheritdoc />
|
||||
public ValueTask WriteAsync(ReadOnlyMemory<byte> data, CancellationToken cancellationToken) =>
|
||||
shell.WriteAsync(data, cancellationToken);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Resize(TerminalSize size)
|
||||
{
|
||||
if (!size.IsUsable)
|
||||
{
|
||||
// A collapsed pane or a minimised window produces these. Forwarding one leaves the
|
||||
// remote's idea of the terminal nonsensical until the next resize arrives.
|
||||
return;
|
||||
}
|
||||
|
||||
shell.ChangeWindowSize(size.Columns, size.Rows, size.PixelWidth, size.PixelHeight);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
await shell.DisposeAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Convenience helpers over a shell session.</summary>
|
||||
public static class SshShellSessionExtensions
|
||||
{
|
||||
/// <summary>Writes UTF-8 text to the remote.</summary>
|
||||
public static ValueTask WriteTextAsync(
|
||||
this ISshShellSession session,
|
||||
string text,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(session);
|
||||
|
||||
return session.WriteAsync(Encoding.UTF8.GetBytes(text), cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DodoSSH.Client.Ssh;
|
||||
|
||||
/// <summary>
|
||||
/// A pseudo-terminal's dimensions.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Both the character grid and the pixel extent, because the SSH <c>pty-req</c> and
|
||||
/// <c>window-change</c> requests carry both. Pixel dimensions are what let a remote program draw
|
||||
/// sixel graphics or size an image correctly; sending zeroes is legal and tells the remote there is
|
||||
/// no pixel information, which is not the same as telling it the terminal is zero pixels wide.
|
||||
/// </remarks>
|
||||
/// <param name="Columns">Character columns.</param>
|
||||
/// <param name="Rows">Character rows.</param>
|
||||
/// <param name="PixelWidth">Width in pixels, or 0 when unknown.</param>
|
||||
/// <param name="PixelHeight">Height in pixels, or 0 when unknown.</param>
|
||||
[StructLayout(LayoutKind.Auto)]
|
||||
public readonly record struct TerminalSize(
|
||||
ushort Columns,
|
||||
ushort Rows,
|
||||
ushort PixelWidth = 0,
|
||||
ushort PixelHeight = 0)
|
||||
{
|
||||
/// <summary>The conventional default, for a session opened before the UI has measured itself.</summary>
|
||||
public static TerminalSize Default => new(80, 24);
|
||||
|
||||
/// <summary>Whether the size is usable as a terminal.</summary>
|
||||
/// <remarks>
|
||||
/// A zero dimension is worth rejecting rather than forwarding: a resize to 0×0 arrives naturally
|
||||
/// when a pane is collapsed or a window minimised, and passing it on makes the remote's idea of
|
||||
/// the terminal nonsensical until the next resize.
|
||||
/// </remarks>
|
||||
public bool IsUsable => Columns > 0 && Rows > 0;
|
||||
}
|
||||
Reference in New Issue
Block a user