Skip to content
Open
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
53 changes: 30 additions & 23 deletions src/Renci.SshNet/ConnectionInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
Expand Down Expand Up @@ -79,7 +80,7 @@ public class ConnectionInfo : IConnectionInfoInternal
/// <summary>
/// Gets supported compression algorithms for this connection.
/// </summary>
public IOrderedDictionary<string, Func<Compressor>> CompressionAlgorithms { get; }
public IOrderedDictionary<string, Func<Compressor>?> CompressionAlgorithms { get; }

/// <summary>
/// Gets the supported channel requests for this connection.
Expand Down Expand Up @@ -129,7 +130,7 @@ public class ConnectionInfo : IConnectionInfoInternal
/// <summary>
/// Gets proxy connection host.
/// </summary>
public string ProxyHost { get; }
public string? ProxyHost { get; }

/// <summary>
/// Gets proxy connection port.
Expand All @@ -139,12 +140,12 @@ public class ConnectionInfo : IConnectionInfoInternal
/// <summary>
/// Gets proxy connection username.
/// </summary>
public string ProxyUsername { get; }
public string? ProxyUsername { get; }

/// <summary>
/// Gets proxy connection password.
/// </summary>
public string ProxyPassword { get; }
public string? ProxyPassword { get; }

/// <summary>
/// Gets or sets connection timeout.
Expand Down Expand Up @@ -219,57 +220,63 @@ public TimeSpan ChannelCloseTimeout
/// <summary>
/// Occurs when authentication banner is sent by the server.
/// </summary>
public event EventHandler<AuthenticationBannerEventArgs> AuthenticationBanner;
public event EventHandler<AuthenticationBannerEventArgs>? AuthenticationBanner;

/// <summary>
/// Gets the current key exchange algorithm.
/// </summary>
public string CurrentKeyExchangeAlgorithm { get; internal set; }
public string? CurrentKeyExchangeAlgorithm { get; internal set; }

/// <summary>
/// Gets the current server encryption.
/// </summary>
public string CurrentServerEncryption { get; internal set; }
public string? CurrentServerEncryption { get; internal set; }

/// <summary>
/// Gets the current client encryption.
/// </summary>
public string CurrentClientEncryption { get; internal set; }
public string? CurrentClientEncryption { get; internal set; }

/// <summary>
/// Gets the current server hash algorithm.
/// </summary>
public string CurrentServerHmacAlgorithm { get; internal set; }
public string? CurrentServerHmacAlgorithm { get; internal set; }

/// <summary>
/// Gets the current client hash algorithm.
/// </summary>
public string CurrentClientHmacAlgorithm { get; internal set; }
public string? CurrentClientHmacAlgorithm { get; internal set; }

/// <summary>
/// Gets the current host key algorithm.
/// </summary>
public string CurrentHostKeyAlgorithm { get; internal set; }
public string? CurrentHostKeyAlgorithm { get; internal set; }

/// <summary>
/// Gets the current server compression algorithm.
/// </summary>
public string CurrentServerCompressionAlgorithm { get; internal set; }
public string? CurrentServerCompressionAlgorithm { get; internal set; }

/// <summary>
/// Gets the server version.
/// Gets the current client compression algorithm.
/// </summary>
public string ServerVersion { get; internal set; }
public string? CurrentClientCompressionAlgorithm { get; internal set; }

/// <summary>
/// Gets the client version.
/// Gets the server version.
/// </summary>
public string ClientVersion { get; internal set; }
public string? ServerVersion { get; internal set; }

/// <summary>
/// Gets the current client compression algorithm.
/// Gets the client version.
/// </summary>
public string CurrentClientCompressionAlgorithm { get; internal set; }
public string ClientVersion
{
get
{
return Session.ClientVersionString;
}
}

/// <summary>
/// Initializes a new instance of the <see cref="ConnectionInfo"/> class.
Expand Down Expand Up @@ -323,7 +330,7 @@ public ConnectionInfo(string host, int port, string username, params Authenticat
/// <exception cref="ArgumentOutOfRangeException"><paramref name="proxyType"/> is not <see cref="ProxyTypes.None"/> and <paramref name="proxyPort" /> is not within <see cref="IPEndPoint.MinPort" /> and <see cref="IPEndPoint.MaxPort" />.</exception>
/// <exception cref="ArgumentNullException"><paramref name="authenticationMethods"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">No <paramref name="authenticationMethods"/> specified.</exception>
public ConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword, params AuthenticationMethod[] authenticationMethods)
public ConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string? proxyHost, int proxyPort, string? proxyUsername, string? proxyPassword, params AuthenticationMethod[] authenticationMethods)
{
ThrowHelper.ThrowIfNull(host);
port.ValidatePort();
Expand Down Expand Up @@ -413,7 +420,7 @@ public ConnectionInfo(string host, int port, string username, ProxyTypes proxyTy
#pragma warning restore SA1107 // Code should not contain multiple statements on one line
HostKeyAlgorithms = hostAlgs;

CompressionAlgorithms = new OrderedDictionary<string, Func<Compressor>>
CompressionAlgorithms = new OrderedDictionary<string, Func<Compressor>?>
{
{ "none", null },
{ "zlib@openssh.com", () => new ZlibOpenSsh() },
Expand Down Expand Up @@ -472,7 +479,7 @@ internal void Authenticate(ISession session, IServiceFactory serviceFactory)
/// </summary>
/// <param name="sender">The session in which the banner message was received.</param>
/// <param name="e">The banner message.</param>
void IConnectionInfoInternal.UserAuthenticationBannerReceived(object sender, MessageEventArgs<BannerMessage> e)
void IConnectionInfoInternal.UserAuthenticationBannerReceived(object? sender, MessageEventArgs<BannerMessage> e)
{
AuthenticationBanner?.Invoke(this, new AuthenticationBannerEventArgs(Username, e.Message.Message, e.Message.Language));
}
Expand Down Expand Up @@ -507,6 +514,6 @@ IList<IAuthenticationMethod> IConnectionInfoInternal.AuthenticationMethods
/// <value>
/// The logger factory for this connection. If <see langword="null"/> then <see cref="SshNetLoggingConfiguration.LoggerFactory"/> is used.
/// </value>
public ILoggerFactory LoggerFactory { get; set; }
public ILoggerFactory? LoggerFactory { get; set; }
}
}
13 changes: 7 additions & 6 deletions src/Renci.SshNet/IConnectionInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#nullable enable
using System;
using System.Collections.Generic;
using System.Text;

Expand All @@ -20,7 +21,7 @@ internal interface IConnectionInfo
/// <value>
/// The logger factory for this connection. If <see langword="null"/> then <see cref="SshNetLoggingConfiguration.LoggerFactory"/> is used.
/// </value>
public ILoggerFactory LoggerFactory { get; }
public ILoggerFactory? LoggerFactory { get; }

/// <summary>
/// Gets the timeout to used when waiting for a server to acknowledge closing a channel.
Expand Down Expand Up @@ -77,7 +78,7 @@ internal interface IConnectionInfo
/// <summary>
/// Gets proxy connection host.
/// </summary>
string ProxyHost { get; }
string? ProxyHost { get; }

/// <summary>
/// Gets proxy connection port.
Expand All @@ -87,12 +88,12 @@ internal interface IConnectionInfo
/// <summary>
/// Gets proxy connection username.
/// </summary>
string ProxyUsername { get; }
string? ProxyUsername { get; }

/// <summary>
/// Gets proxy connection password.
/// </summary>
string ProxyPassword { get; }
string? ProxyPassword { get; }

/// <summary>
/// Gets the number of retry attempts when session channel creation failed.
Expand All @@ -113,6 +114,6 @@ internal interface IConnectionInfo
/// <summary>
/// Occurs when authentication banner is sent by the server.
/// </summary>
event EventHandler<AuthenticationBannerEventArgs> AuthenticationBanner;
event EventHandler<AuthenticationBannerEventArgs>? AuthenticationBanner;
}
}
5 changes: 3 additions & 2 deletions src/Renci.SshNet/IConnectionInfoInternal.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
#nullable enable
using System.Collections.Generic;

using Renci.SshNet.Messages.Authentication;

Expand All @@ -14,7 +15,7 @@ internal interface IConnectionInfoInternal : IConnectionInfo
/// </summary>
/// <param name="sender">The session in which the banner message was received.</param>
/// <param name="e">The banner message.</param>
void UserAuthenticationBannerReceived(object sender, MessageEventArgs<BannerMessage> e);
void UserAuthenticationBannerReceived(object? sender, MessageEventArgs<BannerMessage> e);

/// <summary>
/// Gets the supported authentication methods for this connection.
Expand Down
19 changes: 10 additions & 9 deletions src/Renci.SshNet/KeyboardInteractiveConnectionInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#nullable enable
using System;

using Renci.SshNet.Common;

Expand All @@ -14,7 +15,7 @@ public class KeyboardInteractiveConnectionInfo : ConnectionInfo, IDisposable
/// <summary>
/// Occurs when server prompts for more authentication information.
/// </summary>
public event EventHandler<AuthenticationPromptEventArgs> AuthenticationPrompt;
public event EventHandler<AuthenticationPromptEventArgs>? AuthenticationPrompt;

/// <summary>
/// Initializes a new instance of the <see cref="KeyboardInteractiveConnectionInfo"/> class.
Expand Down Expand Up @@ -46,7 +47,7 @@ public KeyboardInteractiveConnectionInfo(string host, int port, string username)
/// <param name="proxyType">Type of the proxy.</param>
/// <param name="proxyHost">The proxy host.</param>
/// <param name="proxyPort">The proxy port.</param>
public KeyboardInteractiveConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, int proxyPort)
public KeyboardInteractiveConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string? proxyHost, int proxyPort)
: this(host, port, username, proxyType, proxyHost, proxyPort, string.Empty, string.Empty)
{
}
Expand All @@ -61,7 +62,7 @@ public KeyboardInteractiveConnectionInfo(string host, int port, string username,
/// <param name="proxyHost">The proxy host.</param>
/// <param name="proxyPort">The proxy port.</param>
/// <param name="proxyUsername">The proxy username.</param>
public KeyboardInteractiveConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername)
public KeyboardInteractiveConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string? proxyHost, int proxyPort, string? proxyUsername)
: this(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, string.Empty)
{
}
Expand All @@ -74,7 +75,7 @@ public KeyboardInteractiveConnectionInfo(string host, int port, string username,
/// <param name="proxyType">Type of the proxy.</param>
/// <param name="proxyHost">The proxy host.</param>
/// <param name="proxyPort">The proxy port.</param>
public KeyboardInteractiveConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyPort)
public KeyboardInteractiveConnectionInfo(string host, string username, ProxyTypes proxyType, string? proxyHost, int proxyPort)
: this(host, DefaultPort, username, proxyType, proxyHost, proxyPort, string.Empty, string.Empty)
{
}
Expand All @@ -88,7 +89,7 @@ public KeyboardInteractiveConnectionInfo(string host, string username, ProxyType
/// <param name="proxyHost">The proxy host.</param>
/// <param name="proxyPort">The proxy port.</param>
/// <param name="proxyUsername">The proxy username.</param>
public KeyboardInteractiveConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername)
public KeyboardInteractiveConnectionInfo(string host, string username, ProxyTypes proxyType, string? proxyHost, int proxyPort, string? proxyUsername)
: this(host, DefaultPort, username, proxyType, proxyHost, proxyPort, proxyUsername, string.Empty)
{
}
Expand All @@ -103,7 +104,7 @@ public KeyboardInteractiveConnectionInfo(string host, string username, ProxyType
/// <param name="proxyPort">The proxy port.</param>
/// <param name="proxyUsername">The proxy username.</param>
/// <param name="proxyPassword">The proxy password.</param>
public KeyboardInteractiveConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword)
public KeyboardInteractiveConnectionInfo(string host, string username, ProxyTypes proxyType, string? proxyHost, int proxyPort, string? proxyUsername, string? proxyPassword)
: this(host, DefaultPort, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword)
{
}
Expand All @@ -119,7 +120,7 @@ public KeyboardInteractiveConnectionInfo(string host, string username, ProxyType
/// <param name="proxyPort">The proxy port.</param>
/// <param name="proxyUsername">The proxy username.</param>
/// <param name="proxyPassword">The proxy password.</param>
public KeyboardInteractiveConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword)
public KeyboardInteractiveConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string? proxyHost, int proxyPort, string? proxyUsername, string? proxyPassword)
: base(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, new KeyboardInteractiveAuthenticationMethod(username))
{
foreach (var authenticationMethod in AuthenticationMethods)
Expand All @@ -131,7 +132,7 @@ public KeyboardInteractiveConnectionInfo(string host, int port, string username,
}
}

private void AuthenticationMethod_AuthenticationPrompt(object sender, AuthenticationPromptEventArgs e)
private void AuthenticationMethod_AuthenticationPrompt(object? sender, AuthenticationPromptEventArgs e)
{
#pragma warning disable MA0091 // Sender should be 'this' for instance events
AuthenticationPrompt?.Invoke(sender, e);
Expand Down
Loading