|
|
@@ -19,6 +19,7 @@ using Renci.SshNet.Security;
|
|
|
using System.Globalization;
|
|
|
using Renci.SshNet.Security.Cryptography.Ciphers;
|
|
|
using Renci.SshNet.Security.Cryptography;
|
|
|
+using System.Diagnostics;
|
|
|
|
|
|
namespace Renci.SshNet
|
|
|
{
|
|
|
@@ -27,6 +28,14 @@ namespace Renci.SshNet
|
|
|
/// </summary>
|
|
|
public partial class Session : IDisposable
|
|
|
{
|
|
|
+
|
|
|
+ internal TraceSource log =
|
|
|
+#if DEBUG
|
|
|
+ new TraceSource("SshNet.Logging", SourceLevels.All);
|
|
|
+#else
|
|
|
+ new TraceSource("SshNet.Logging");
|
|
|
+#endif
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Specifies maximum packet size defined by the protocol.
|
|
|
/// </summary>
|
|
|
@@ -463,6 +472,10 @@ namespace Renci.SshNet
|
|
|
// Get server SSH version
|
|
|
var version = versionMatch.Result("${protoversion}");
|
|
|
|
|
|
+ var softwareName = versionMatch.Result("${softwareversion}");
|
|
|
+
|
|
|
+ this.log.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 1, string.Format("Server version '{0}' on '{1}'.", version, softwareName));
|
|
|
+
|
|
|
if (!(version.Equals("2.0") || version.Equals("1.99")))
|
|
|
{
|
|
|
throw new SshConnectionException(string.Format(CultureInfo.CurrentCulture, "Server version '{0}' is not supported.", version), DisconnectReason.ProtocolVersionNotSupported);
|
|
|
@@ -636,6 +649,8 @@ namespace Renci.SshNet
|
|
|
if (this._socket == null || !this._socket.Connected)
|
|
|
return;
|
|
|
|
|
|
+ this.log.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 1, string.Format("SendMessage to server '{0}': '{1}'.", message.GetType().Name, message.ToString()));
|
|
|
+
|
|
|
// Messages can be sent by different thread so we need to synchronize it
|
|
|
var paddingMultiplier = this._clientCipher == null ? (byte)8 : (byte)this._clientCipher.BlockSize; // Should be recalculate base on cipher min length if cipher specified
|
|
|
|
|
|
@@ -1010,6 +1025,8 @@ namespace Renci.SshNet
|
|
|
/// <param name="message"><see cref="DisconnectMessage"/> message.</param>
|
|
|
protected virtual void OnDisconnectReceived(DisconnectMessage message)
|
|
|
{
|
|
|
+
|
|
|
+ log.TraceInformation("Disconnect received.");
|
|
|
if (this.DisconnectReceived != null)
|
|
|
{
|
|
|
this.DisconnectReceived(this, new MessageEventArgs<DisconnectMessage>(message));
|
|
|
@@ -1455,6 +1472,8 @@ namespace Renci.SshNet
|
|
|
|
|
|
message.Load(data);
|
|
|
|
|
|
+ this.log.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 1, "ReceiveMessage from server: '{0}': '{1}'.", message.GetType().Name, message.ToString());
|
|
|
+
|
|
|
return message;
|
|
|
}
|
|
|
|