github sshnet/SSH.NET 2016.1.0-beta2

latest releases: 2024.2.0, 2024.1.0, 2024.0.0...
pre-release7 years ago

Changes

General

  • Increase initial window size for SSH channels from 2 MB to 2147483647 (2^31 - 1) bytes. This results in less protocol overhead when receiving data from a SSH server.

SftpClient

  • When the read buffer is empty, SftpFileStream.Read(byte[], int, int) only writes those bytes to the buffer that go beyond the number of bytes requested by the caller.
  • Reduced memory allocations in SftpFileStream by lazily allocating read and write buffer.
  • Improved compatibility of SftpFileStream.SetLength(long value) with System.IO.FileStream (PR #272):
    • Flush buffers before changing the length of stream.
    • Move the current position to the last byte of the stream if the current position is greater than the new length.
  • Eliminated extra read from server in SftpFileStream to determine EOF.
  • Greatly improved performance of SftpClient.(Begin)DownloadFile(...) by asynchronously reading ahead chunks (issue #145 and #100).

Breaking changes

SftpClient

  • The IsAsync property was removed from SftpFileStream. Previously this property always returned false.

  • The read and write position in SftpFileStream are no longer tracked separately. Reading from or seeking in the SftpFileStream will now also affect the position at which a subsequent write is performed, and vice versa (issue #253).

    For example, the following code snippet will now write "123456" to the console:

    var buffer = Encoding.UTF8.GetBytes("123456");

    using (var client = new SftpClient("host", "user", "pwd"))
    {
        client.Connect();

        using (var ws = client.OpenWrite(path))
        {
            ws.Write(buffer, 0, 3);
        }

        using (var ws = client.OpenWrite(path))
        {
            ws.Seek(3, SeekOrigin.Begin);
            ws.Write(buffer, 3, 3);
        }

        Console.WriteLine(client.ReadAllText(path, Encoding.UTF8));
    }
  • To improve compatibility of SftpFileStream with System.IO.FileStream, Append mode is now only allowed when combined with write-only access (issue #267). This only affects SftpClient.Open(string path, FileMode mode, FileAccess access).

    The following code snippet will now throw an ArgumentException:

      using (var client = new SftpClient("host", "user", "pwd"))
      {
          client.Connect();
    
          using (var fs = client.Open("/home/user/file.log", FileMode.Append, FileShare.Read))
          {
          }
      }

    Result:
    System.ArgumentException: Append mode can be requested only when combined with write-only access.

  • To improve compatibility of SftpClient with System.IO.File, the following methods now use UTF-8 encoding without a Byte-Order Mark (BOM):

    • void AppendAllLines(string path, IEnumerable<string> contents)
    • void AppendAllText(string path, string contents)
    • StreamWriter AppendText(string path)
    • StreamWriter CreateText(string path)
    • void WriteAllLines(string path, IEnumerable<string> contents)
    • void WriteAllLines(string path, string[] contents)
    • void WriteAllText(string path, string contents)

Fixes

General

  • ConnectSocks5() throws a ProxyException with a wrong message (issue #167).
  • Comments in ProxyException.cs are not relevant (issue #163).
  • SSH exception after client connect using .NET 3.5 version (issue #113).

SftpClient

  • SftpFileStream allows invalid combinations of FileMode and FileAccess (issue #191).
  • SftpFileStream.ReadByte() throws ArgumentException when no data is available in read buffer (issue #173).
  • SftpFileStream also sends SSH_FXP_FSTAT upon initialization when mode is not Append (issue #154).
  • In Append mode, SftpFileStream throws a SftpPathNotFoundException when the specified file does not exist (issue #266).

Don't miss a new SSH.NET release

NewReleases is sending notifications on new releases.