You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Revamp README.md with enhanced feature breakdown and detailed method mappings for clarity.
- Add `SendKeepAlive` and `ConfigureKeepAlive` methods to `SshSession` for connection keepalive configuration.
- Strengthen precondition checks in `SshSession` methods with `EnsureInitialized` and session state validation.
- Restrict `LibSshExtensions` methods visibility to `internal` for stricter encapsulation.
- Refactor XML documentation across `SshSession` to improve readability and ensure consistent formatting.
/// <param name="port">The port number of the SSH server (typically 22).</param>
81
81
/// <exception cref="SshException">Thrown when connection or SSH handshake fails.</exception>
82
82
/// <remarks>
83
-
/// This method establishes a TCP connection and performs the SSH protocol handshake.
84
-
/// After successful connection, the session will be in <see cref="SshConnectionStatus.Connected"/> status.
85
-
/// You must call <see cref="Authenticate"/> before executing commands.
83
+
/// <para>This method establishes a TCP connection and performs the SSH protocol handshake.</para>
84
+
/// <para>The session must be in <see cref="SshConnectionStatus.Disconnected"/> status before calling this method.</para>
85
+
/// <para>After successful connection, the session will be in <see cref="SshConnectionStatus.Connected"/> status.</para>
86
+
/// <para>You must call <see cref="Authenticate"/> before executing commands.</para>
86
87
/// </remarks>
87
88
publicunsafevoidConnect(stringhost,intport)
88
89
{
@@ -252,17 +253,25 @@ public void SetSecureMethodPreferences()
252
253
/// Disables the session timeout, allowing operations to wait indefinitely.
253
254
/// </summary>
254
255
/// <remarks>
255
-
/// By default, libssh2 has no timeout. Use this method to explicitly disable any previously set timeout.
256
+
/// <para>By default, libssh2 has no timeout. Use this method to explicitly disable any previously set timeout.</para>
257
+
/// <para>The session must be in <see cref="SshConnectionStatus.Connected"/> or <see cref="SshConnectionStatus.LoggedIn"/> status before calling this method.</para>
/// Sets the maximum time to wait for SSH operations to complete.
261
269
/// </summary>
262
270
/// <param name="timeout">The timeout duration. Must be greater than zero and less than <see cref="int.MaxValue"/> milliseconds.</param>
263
271
/// <exception cref="ArgumentOutOfRangeException">Thrown if the timeout is negative or exceeds the maximum allowed value.</exception>
264
272
/// <remarks>
265
-
/// This timeout applies to blocking libssh2 operations. If an operation does not complete within the specified time, it will return an error.
273
+
/// <para>This timeout applies to blocking libssh2 operations. If an operation does not complete within the specified time, it will return an error.</para>
274
+
/// <para>The session must be in <see cref="SshConnectionStatus.Connected"/> or <see cref="SshConnectionStatus.LoggedIn"/> status before calling this method.</para>
/// Sends a keepalive message to the remote SSH server.
292
+
/// </summary>
293
+
/// <returns>The number of seconds until the next keepalive should be sent, based on the configured interval.</returns>
294
+
/// <exception cref="SshException">Thrown if the keepalive message cannot be sent or the session is not in the correct state.</exception>
295
+
/// <remarks>
296
+
/// <para>This method sends an SSH protocol keepalive message to prevent the connection from timing out due to inactivity.</para>
297
+
/// <para>This method must be called after connecting to the server. The session must be in <see cref="SshConnectionStatus.Connected"/> or <see cref="SshConnectionStatus.LoggedIn"/> status.</para>
298
+
/// <para>Use <see cref="ConfigureKeepAlive"/> to set the keepalive interval and whether the server should reply.</para>
result.ThrowIfNotSuccessful(this,"Failed to send keepalive");
309
+
310
+
returnuntilNext;
311
+
}
312
+
313
+
/// <summary>
314
+
/// Configures the SSH session's keepalive behavior.
315
+
/// </summary>
316
+
/// <param name="wantReply">If true, the server will be requested to send a reply to keepalive messages. If false, keepalive messages are sent without expecting a reply.</param>
317
+
/// <param name="interval">The interval between keepalive messages. Must be greater than or equal to zero.</param>
318
+
/// <exception cref="ArgumentOutOfRangeException">Thrown if the interval is negative.</exception>
319
+
/// <exception cref="SshException">Thrown if the session is not in the correct state.</exception>
320
+
/// <remarks>
321
+
/// <para>This method configures the keepalive settings for the SSH session. Keepalive messages help maintain connections that might otherwise timeout due to inactivity or be terminated by firewalls.</para>
322
+
/// <para>This method must be called after connecting to the server. The session must be in <see cref="SshConnectionStatus.Connected"/> or <see cref="SshConnectionStatus.LoggedIn"/> status.</para>
323
+
/// <para>Use <see cref="SendKeepAlive"/> to manually send keepalive messages once configured.</para>
@@ -468,9 +528,10 @@ public unsafe SshCommandResult ExecuteCommand(string command, CommandExecutionOp
468
528
/// <param name="cancellationToken">Optional cancellation token to cancel the operation.</param>
469
529
/// <returns>A task that represents the asynchronous operation, containing the result of the command execution including stdout and stderr output.</returns>
470
530
/// <remarks>
471
-
/// This method offloads the blocking command execution to a thread pool thread.
472
-
/// When <see cref="CommandExecutionOptions.RequestPty"/> is true, a pseudo-terminal (PTY) will be requested
473
-
/// before executing the command. This enables terminal features like color output and interactive input.
531
+
/// <para>This method offloads the blocking command execution to a thread pool thread.</para>
532
+
/// <para>The session must be in <see cref="SshConnectionStatus.LoggedIn"/> status before calling this method.</para>
533
+
/// <para>When <see cref="CommandExecutionOptions.RequestPty"/> is true, a pseudo-terminal (PTY) will be requested
534
+
/// before executing the command. This enables terminal features like color output and interactive input.</para>
@@ -545,8 +607,9 @@ public unsafe bool ReadFile(string path, Stream destination, int bufferSize = 32
545
607
/// <returns>A task that represents the asynchronous operation, containing a boolean value indicating whether the entire file was successfully downloaded.</returns>
546
608
/// <exception cref="SshException">Thrown when the SCP channel cannot be created or other SSH errors occur.</exception>
547
609
/// <remarks>
548
-
/// This method offloads the blocking SCP file transfer to a thread pool thread.
549
-
/// The destination stream will not be closed by this method. The caller is responsible for managing the stream's lifecycle.
610
+
/// <para>This method offloads the blocking SCP file transfer to a thread pool thread.</para>
611
+
/// <para>The session must be in <see cref="SshConnectionStatus.LoggedIn"/> status before calling this method.</para>
612
+
/// <para>The destination stream will not be closed by this method. The caller is responsible for managing the stream's lifecycle.</para>
0 commit comments