Skip to content

Commit 1a7905a

Browse files
authored
Merge branch 'develop' into nbgvprops
2 parents dab149f + 021ee99 commit 1a7905a

File tree

54 files changed

+1037
-230
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1037
-230
lines changed

.editorconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ dotnet_diagnostic.S2971.severity = none
195195
# This is rather harmless.
196196
dotnet_diagnostic.S3218.severity = none
197197

198+
# S3236: Remove this argument from the method call; it hides the caller information.
199+
dotnet_diagnostic.S3236.severity = none
200+
198201
# S3267: Loops should be simplified with "LINQ" expressions
199202
# https://rules.sonarsource.com/csharp/RSPEC-3267
200203
#
@@ -701,6 +704,9 @@ dotnet_code_quality.CA1828.api_surface = all
701704
# Similar to MA0053, but does not support public types and types that define (new) virtual members.
702705
dotnet_diagnostic.CA1852.severity = none
703706

707+
# CA1848: don't enforce LoggerMessage pattern
708+
dotnet_diagnostic.CA1848.severity = suggestion
709+
704710
# CA1859: Change return type for improved performance
705711
#
706712
# By default, this diagnostic is only reported for private members.

.github/workflows/build.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,39 @@ jobs:
1717
- name: Setup .NET
1818
uses: actions/setup-dotnet@v4
1919
with:
20-
dotnet-version: 8.0.x
20+
dotnet-version: 9.0.x
2121

2222
- name: Build Unit Tests .NET
23-
run: dotnet build -f net8.0 test/Renci.SshNet.Tests/
23+
run: dotnet build -f net9.0 test/Renci.SshNet.Tests/
2424

2525
- name: Build IntegrationTests .NET
26-
run: dotnet build -f net8.0 test/Renci.SshNet.IntegrationTests/
26+
run: dotnet build -f net9.0 test/Renci.SshNet.IntegrationTests/
2727

2828
- name: Build IntegrationTests .NET Framework
2929
run: dotnet build -f net48 test/Renci.SshNet.IntegrationTests/
3030

3131
- name: Run Unit Tests .NET
3232
run: |
3333
dotnet test \
34-
-f net8.0 \
34+
-f net9.0 \
3535
--no-build \
3636
--logger "console;verbosity=normal" \
3737
--logger GitHubActions \
3838
-p:CollectCoverage=true \
3939
-p:CoverletOutputFormat=cobertura \
40-
-p:CoverletOutput=../../coverlet/linux_unit_test_net_8_coverage.xml \
40+
-p:CoverletOutput=../../coverlet/linux_unit_test_net_9_coverage.xml \
4141
test/Renci.SshNet.Tests/
4242
4343
- name: Run Integration Tests .NET
4444
run: |
4545
dotnet test \
46-
-f net8.0 \
46+
-f net9.0 \
4747
--no-build \
4848
--logger "console;verbosity=normal" \
4949
--logger GitHubActions \
5050
-p:CollectCoverage=true \
5151
-p:CoverletOutputFormat=cobertura \
52-
-p:CoverletOutput=../../coverlet/linux_integration_test_net_8_coverage.xml \
52+
-p:CoverletOutput=../../coverlet/linux_integration_test_net_9_coverage.xml \
5353
test/Renci.SshNet.IntegrationTests/
5454
5555
# Also run a subset of the integration tests targeting netfx using mono. This is a temporary measure to get
@@ -111,13 +111,13 @@ jobs:
111111
- name: Run Unit Tests .NET
112112
run: |
113113
dotnet test `
114-
-f net8.0 `
114+
-f net9.0 `
115115
--no-build `
116116
--logger "console;verbosity=normal" `
117117
--logger GitHubActions `
118118
-p:CollectCoverage=true `
119119
-p:CoverletOutputFormat=cobertura `
120-
-p:CoverletOutput=../../coverlet/windows_unit_test_net_8_coverage.xml `
120+
-p:CoverletOutput=../../coverlet/windows_unit_test_net_9_coverage.xml `
121121
test/Renci.SshNet.Tests/
122122
123123
- name: Run Unit Tests .NET Framework

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ The repository makes use of continuous integration (CI) with GitHub Actions to v
3434

3535
## Good to know
3636

37-
### TraceSource logging
37+
### Logging
3838

39-
The Debug build of SSH.NET contains rudimentary logging functionality via `System.Diagnostics.TraceSource`. See `Renci.SshNet.Abstractions.DiagnosticAbstraction` for usage examples.
39+
The tests always log to the console. See the [Logging documentation](https://sshnet.github.io/SSH.NET/logging.html) on how to set a custom `ILoggerFactory`.
4040

4141
### Wireshark
4242

Directory.Packages.props

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66
<ItemGroup>
77
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
8-
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.4.0" />
8+
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.5.0" />
99
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
1010
<PackageVersion Include="coverlet.msbuild" Version="6.0.2" />
1111
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1">
@@ -15,6 +15,9 @@
1515
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.163" />
1616
<!-- Must be kept at version 1.0.0 or higher, see https://github.com/sshnet/SSH.NET/pull/1288 for details. -->
1717
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="1.0.0" />
18+
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
19+
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
20+
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
1821
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
1922
<PackageVersion Include="MSTest.TestAdapter" Version="3.6.2" />
2023
<PackageVersion Include="MSTest.TestFramework" Version="3.6.2" />

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ The main types provided by this library are:
6262
## Additional Documentation
6363

6464
* [Further examples](https://sshnet.github.io/SSH.NET/examples.html)
65+
* [Logging](https://sshnet.github.io/SSH.NET/logging.html)
6566
* [API browser](https://sshnet.github.io/SSH.NET/api/Renci.SshNet.html)
6667

6768
## Encryption Methods
@@ -101,17 +102,21 @@ The main types provided by this library are:
101102
* OpenSSL PKCS#8 PEM format ("BEGIN PRIVATE KEY", "BEGIN ENCRYPTED PRIVATE KEY")
102103
* ssh.com format ("BEGIN SSH2 ENCRYPTED PRIVATE KEY")
103104
* OpenSSH key format ("BEGIN OPENSSH PRIVATE KEY")
105+
* PuTTY private key format ("PuTTY-User-Key-File-2", "PuTTY-User-Key-File-3")
104106
* DSA in
105107
* OpenSSL traditional PEM format ("BEGIN DSA PRIVATE KEY")
106108
* OpenSSL PKCS#8 PEM format ("BEGIN PRIVATE KEY", "BEGIN ENCRYPTED PRIVATE KEY")
107109
* ssh.com format ("BEGIN SSH2 ENCRYPTED PRIVATE KEY")
110+
* PuTTY private key format ("PuTTY-User-Key-File-2", "PuTTY-User-Key-File-3")
108111
* ECDSA 256/384/521 in
109112
* OpenSSL traditional PEM format ("BEGIN EC PRIVATE KEY")
110113
* OpenSSL PKCS#8 PEM format ("BEGIN PRIVATE KEY", "BEGIN ENCRYPTED PRIVATE KEY")
111114
* OpenSSH key format ("BEGIN OPENSSH PRIVATE KEY")
115+
* PuTTY private key format ("PuTTY-User-Key-File-2", "PuTTY-User-Key-File-3")
112116
* ED25519 in
113117
* OpenSSL PKCS#8 PEM format ("BEGIN PRIVATE KEY", "BEGIN ENCRYPTED PRIVATE KEY")
114118
* OpenSSH key format ("BEGIN OPENSSH PRIVATE KEY")
119+
* PuTTY private key format ("PuTTY-User-Key-File-2", "PuTTY-User-Key-File-3")
115120

116121
Private keys in OpenSSL traditional PEM format can be encrypted using one of the following cipher methods:
117122
* DES-EDE3-CBC
@@ -123,7 +128,7 @@ Private keys in OpenSSL traditional PEM format can be encrypted using one of the
123128

124129
Private keys in OpenSSL PKCS#8 PEM format can be encrypted using any cipher method BouncyCastle supports.
125130

126-
Private keys in ssh.com format can be encrypted using one of the following cipher methods:
131+
Private keys in ssh.com format can be encrypted using the following cipher method:
127132
* 3des-cbc
128133

129134
Private keys in OpenSSH key format can be encrypted using one of the following cipher methods:
@@ -138,6 +143,9 @@ Private keys in OpenSSH key format can be encrypted using one of the following c
138143
* aes256-gcm<span></span>@openssh.com
139144
* chacha20-poly1305<span></span>@openssh.com
140145

146+
Private keys in PuTTY private key format can be encrypted using the following cipher method:
147+
* aes256-cbc
148+
141149
## Host Key Algorithms
142150

143151
**SSH.NET** supports the following host key algorithms:

appveyor.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

docfx/logging.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Logging
2+
=================
3+
4+
SSH.NET uses the [Microsoft.Extensions.Logging](https://learn.microsoft.com/dotnet/core/extensions/logging) API to log diagnostic messages. In order to access the log messages of SSH.NET in your own application for diagnosis, register your own `ILoggerFactory` before using the SSH.NET APIs, for example:
5+
6+
```cs
7+
ILoggerFactory loggerFactory = LoggerFactory.Create(builder =>
8+
{
9+
builder.SetMinimumLevel(LogLevel.Debug);
10+
builder.AddConsole();
11+
});
12+
13+
Renci.SshNet.SshNetLoggingConfiguration.InitializeLogging(loggerFactory);
14+
15+
All messages by SSH.NET are logged under the `Renci.SshNet` category.

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "8.0.100",
3+
"version": "9.0.100",
44
"rollForward": "latestMajor"
55
}
66
}

src/Renci.SshNet/Abstractions/DiagnosticAbstraction.cs

Lines changed: 0 additions & 69 deletions
This file was deleted.

src/Renci.SshNet/BaseClient.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
using System.Threading;
55
using System.Threading.Tasks;
66

7-
using Renci.SshNet.Abstractions;
7+
using Microsoft.Extensions.Logging;
8+
89
using Renci.SshNet.Common;
910
using Renci.SshNet.Messages.Transport;
1011

@@ -20,6 +21,7 @@ public abstract class BaseClient : IBaseClient
2021
/// </summary>
2122
private readonly bool _ownsConnectionInfo;
2223

24+
private readonly ILogger _logger;
2325
private readonly IServiceFactory _serviceFactory;
2426
private readonly object _keepAliveLock = new object();
2527
private TimeSpan _keepAliveInterval;
@@ -190,6 +192,7 @@ private protected BaseClient(ConnectionInfo connectionInfo, bool ownsConnectionI
190192
_connectionInfo = connectionInfo;
191193
_ownsConnectionInfo = ownsConnectionInfo;
192194
_serviceFactory = serviceFactory;
195+
_logger = SshNetLoggingConfiguration.LoggerFactory.CreateLogger(GetType());
193196
_keepAliveInterval = Timeout.InfiniteTimeSpan;
194197
}
195198

@@ -343,7 +346,7 @@ public async Task ConnectAsync(CancellationToken cancellationToken)
343346
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
344347
public void Disconnect()
345348
{
346-
DiagnosticAbstraction.Log("Disconnecting client.");
349+
_logger.LogInformation("Disconnecting client.");
347350

348351
CheckDisposed();
349352

@@ -442,7 +445,7 @@ protected virtual void Dispose(bool disposing)
442445

443446
if (disposing)
444447
{
445-
DiagnosticAbstraction.Log("Disposing client.");
448+
_logger.LogDebug("Disposing client.");
446449

447450
Disconnect();
448451

0 commit comments

Comments
 (0)