Skip to content

Make ZlibOpenSsh public #1433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docfx/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
}
],
"outputFormat": "apiPage",
"output": "api"
"output": "api",
"properties": {
"TargetFramework": "net8.0"
}
}
],
"build": {
Expand Down
4 changes: 2 additions & 2 deletions src/Renci.SshNet/Compression/Compressor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public abstract class Compressor : Algorithm, IDisposable
/// </summary>
/// <param name="delayedCompression">
/// <see langword="false"/> to start compression after receiving SSH_MSG_NEWKEYS.
/// <see langword="true"/> to delay compression util receiving SSH_MSG_USERAUTH_SUCCESS.
/// <see href="https://www.openssh.com/txt/draft-miller-secsh-compression-delayed-00.txt"/>.
/// <see langword="true"/> to delay compression until SSH_MSG_USERAUTH_SUCCESS is received.
/// See <see href="https://www.openssh.com/txt/draft-miller-secsh-compression-delayed-00.txt"/>.
/// </param>
protected Compressor(bool delayedCompression)
{
Expand Down
19 changes: 14 additions & 5 deletions src/Renci.SshNet/Compression/Zlib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,30 @@
namespace Renci.SshNet.Compression
{
/// <summary>
/// Represents "zlib" compression implementation.
/// Represents the "zlib" compression algorithm.
/// </summary>
internal class Zlib : Compressor
public class Zlib : Compressor
{
private readonly ZLibStream _compressor;
private readonly ZLibStream _decompressor;
private MemoryStream _compressorStream;
private MemoryStream _decompressorStream;
private bool _isDisposed;

/// <summary>
/// Initializes a new instance of the <see cref="Zlib"/> class.
/// </summary>
public Zlib()
: this(delayedCompression: false)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="Zlib"/> class.
/// </summary>
/// <param name="delayedCompression">
/// <inheritdoc cref="Compressor(bool)" path="/param[@name='delayedCompression']"/>
/// </param>
protected Zlib(bool delayedCompression)
: base(delayedCompression)
{
Expand All @@ -30,14 +39,13 @@ protected Zlib(bool delayedCompression)
_decompressor = new ZLibStream(_decompressorStream, CompressionMode.Decompress);
}

/// <summary>
/// Gets algorithm name.
/// </summary>
/// <inheritdoc/>
public override string Name
{
get { return "zlib"; }
}

/// <inheritdoc/>
protected override byte[] CompressCore(byte[] data, int offset, int length)
{
_compressorStream.SetLength(0);
Expand All @@ -48,6 +56,7 @@ protected override byte[] CompressCore(byte[] data, int offset, int length)
return _compressorStream.ToArray();
}

/// <inheritdoc/>
protected override byte[] DecompressCore(byte[] data, int offset, int length)
{
_decompressorStream.Write(data, offset, length);
Expand Down
9 changes: 8 additions & 1 deletion src/Renci.SshNet/Compression/ZlibOpenSsh.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
#if NET6_0_OR_GREATER
namespace Renci.SshNet.Compression
{
internal sealed class ZlibOpenSsh : Zlib
/// <summary>
/// Represents the "zlib@openssh.com" compression algorithm.
/// </summary>
public class ZlibOpenSsh : Zlib
{
/// <summary>
/// Initializes a new instance of the <see cref="ZlibOpenSsh"/> class.
/// </summary>
public ZlibOpenSsh()
: base(delayedCompression: true)
{
}

/// <inheritdoc/>
public override string Name
{
get { return "zlib@openssh.com"; }
Expand Down
2 changes: 1 addition & 1 deletion src/Renci.SshNet/Security/Algorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public abstract class Algorithm
{
/// <summary>
/// Gets algorithm name.
/// Gets the algorithm name.
/// </summary>
public abstract string Name { get; }
}
Expand Down