diff --git a/Renci.SshClient/Renci.SshClient.Tests/ConnectionData.cs b/Renci.SshClient/Renci.SshClient.Tests/ConnectionData.cs index 96567373..96930cbd 100644 --- a/Renci.SshClient/Renci.SshClient.Tests/ConnectionData.cs +++ b/Renci.SshClient/Renci.SshClient.Tests/ConnectionData.cs @@ -3,13 +3,13 @@ namespace Renci.SshClient.Tests { public static class ConnectionData { - public static string Host { get { return "server"; } } + public static string Host { get { return "152.54.8.155"; } } public static int Port { get { return 22; } } - public static string Username { get { return "username"; } } + public static string Username { get { return "oleg"; } } - public static string Password { get { return "password"; } } + public static string Password { get { return "Maya2kap#"; } } public static string RsaKeyFilePath { get { return @"RSA key path"; } } diff --git a/Renci.SshClient/Renci.SshClient.Tests/PortForwardingTest.cs b/Renci.SshClient/Renci.SshClient.Tests/PortForwardingTest.cs index b3f0e5b5..ca21c2cc 100644 --- a/Renci.SshClient/Renci.SshClient.Tests/PortForwardingTest.cs +++ b/Renci.SshClient/Renci.SshClient.Tests/PortForwardingTest.cs @@ -108,8 +108,9 @@ namespace Renci.SshClient.Tests Assert.Fail(e.Exception.ToString()); }; port1.Start(); + var boundport = port1.BoundPort; - System.Threading.Tasks.Parallel.For(0, 100, + System.Threading.Tasks.Parallel.For(0, 5, //new ParallelOptions //{ // MaxDegreeOfParallelism = 1, @@ -120,10 +121,10 @@ namespace Renci.SshClient.Tests try { - var cmd = client.CreateCommand("wget -O- http://localhost:8082"); + var cmd = client.CreateCommand(string.Format("wget -O- http://localhost:{0}", boundport)); var result = cmd.Execute(); var end = DateTime.Now; - Debug.Write(string.Format("Length: {0}", result.Length)); + Debug.WriteLine(string.Format("Length: {0}", result.Length)); } catch (Exception exp) { diff --git a/Renci.SshClient/Renci.SshClient/Compression/Compressor.cs b/Renci.SshClient/Renci.SshClient/Compression/Compressor.cs index 420ec2c5..ea52849c 100644 --- a/Renci.SshClient/Renci.SshClient/Compression/Compressor.cs +++ b/Renci.SshClient/Renci.SshClient/Compression/Compressor.cs @@ -2,7 +2,7 @@ using Renci.SshClient.Security; namespace Renci.SshClient.Compression { - internal abstract class Compressor : Algorithm + public abstract class Compressor : Algorithm { protected Session Session { get; private set; } diff --git a/Renci.SshClient/Renci.SshClient/Messages/Authentication/BannerMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Authentication/BannerMessage.cs index 25918387..fc26e6e7 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Authentication/BannerMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Authentication/BannerMessage.cs @@ -2,7 +2,7 @@ namespace Renci.SshClient.Messages.Authentication { - internal class BannerMessage : Message + public class BannerMessage : Message { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Messages/Authentication/FailureMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Authentication/FailureMessage.cs index d4293762..f8f98884 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Authentication/FailureMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Authentication/FailureMessage.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; namespace Renci.SshClient.Messages.Authentication { - internal class FailureMessage : Message + public class FailureMessage : Message { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Messages/Authentication/RequestMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Authentication/RequestMessage.cs index 35336bd5..78ddd468 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Authentication/RequestMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Authentication/RequestMessage.cs @@ -3,7 +3,7 @@ using System.Text; namespace Renci.SshClient.Messages.Authentication { - internal class RequestMessage : Message + public class RequestMessage : Message { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Messages/Authentication/SuccessMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Authentication/SuccessMessage.cs index a3dc29d5..48608ad6 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Authentication/SuccessMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Authentication/SuccessMessage.cs @@ -1,7 +1,7 @@  namespace Renci.SshClient.Messages.Authentication { - internal class SuccessMessage : Message + public class SuccessMessage : Message { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelCloseMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelCloseMessage.cs index b1ed8eb8..6730f6f4 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelCloseMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelCloseMessage.cs @@ -1,7 +1,7 @@  namespace Renci.SshClient.Messages.Connection { - internal class ChannelCloseMessage : ChannelMessage + public class ChannelCloseMessage : ChannelMessage { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelDataMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelDataMessage.cs index 3e642527..8eb8a20e 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelDataMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelDataMessage.cs @@ -1,6 +1,6 @@ namespace Renci.SshClient.Messages.Connection { - internal class ChannelDataMessage : ChannelMessage + public class ChannelDataMessage : ChannelMessage { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelEofMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelEofMessage.cs index 69c67805..d6922e0d 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelEofMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelEofMessage.cs @@ -1,6 +1,6 @@ namespace Renci.SshClient.Messages.Connection { - internal class ChannelEofMessage : ChannelMessage + public class ChannelEofMessage : ChannelMessage { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelExtendedDataMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelExtendedDataMessage.cs index d0e0c664..b3f1a951 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelExtendedDataMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelExtendedDataMessage.cs @@ -1,7 +1,7 @@  namespace Renci.SshClient.Messages.Connection { - internal class ChannelExtendedDataMessage : ChannelMessage + public class ChannelExtendedDataMessage : ChannelMessage { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelFailureMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelFailureMessage.cs index c9569529..3bb17e8b 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelFailureMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelFailureMessage.cs @@ -1,7 +1,7 @@  namespace Renci.SshClient.Messages.Connection { - internal class ChannelFailureMessage : ChannelMessage + public class ChannelFailureMessage : ChannelMessage { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelMessage.cs index af7348b3..e599086c 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelMessage.cs @@ -1,7 +1,7 @@  namespace Renci.SshClient.Messages.Connection { - internal abstract class ChannelMessage : Message + public abstract class ChannelMessage : Message { public uint LocalChannelNumber { get; set; } diff --git a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelOpen/ChannelOpenInfo.cs b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelOpen/ChannelOpenInfo.cs index 693c562f..5ad397d1 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelOpen/ChannelOpenInfo.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelOpen/ChannelOpenInfo.cs @@ -2,7 +2,7 @@ namespace Renci.SshClient.Messages.Connection { - internal abstract class ChannelOpenInfo : SshData + public abstract class ChannelOpenInfo : SshData { public abstract string ChannelType { get; } diff --git a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelOpen/ChannelOpenMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelOpen/ChannelOpenMessage.cs index a5ff955c..1d6cb9c2 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelOpen/ChannelOpenMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelOpen/ChannelOpenMessage.cs @@ -2,7 +2,7 @@ namespace Renci.SshClient.Messages.Connection { - internal class ChannelOpenMessage : ChannelMessage + public class ChannelOpenMessage : ChannelMessage { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelOpenConfirmationMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelOpenConfirmationMessage.cs index 9716dd53..bcb65e6e 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelOpenConfirmationMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelOpenConfirmationMessage.cs @@ -1,6 +1,6 @@ namespace Renci.SshClient.Messages.Connection { - internal class ChannelOpenConfirmationMessage : ChannelMessage + public class ChannelOpenConfirmationMessage : ChannelMessage { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelOpenFailureMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelOpenFailureMessage.cs index bff6c3f4..19a3415d 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelOpenFailureMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelOpenFailureMessage.cs @@ -1,6 +1,6 @@ namespace Renci.SshClient.Messages.Connection { - internal class ChannelOpenFailureMessage : ChannelMessage + public class ChannelOpenFailureMessage : ChannelMessage { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestMessage.cs index fa072fa6..62e32348 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestMessage.cs @@ -2,7 +2,7 @@ namespace Renci.SshClient.Messages.Connection { - internal class ChannelRequestMessage : ChannelMessage + public class ChannelRequestMessage : ChannelMessage { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelRequest/RequestInfo.cs b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelRequest/RequestInfo.cs index 760d1c12..910f1bcc 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelRequest/RequestInfo.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelRequest/RequestInfo.cs @@ -2,7 +2,7 @@ namespace Renci.SshClient.Messages.Connection { - internal abstract class RequestInfo : SshData + public abstract class RequestInfo : SshData { public abstract string RequestName { get; } diff --git a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelSuccessMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelSuccessMessage.cs index 9721179f..f56c27dc 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelSuccessMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelSuccessMessage.cs @@ -1,7 +1,7 @@  namespace Renci.SshClient.Messages.Connection { - internal class ChannelSuccessMessage : ChannelMessage + public class ChannelSuccessMessage : ChannelMessage { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelWindowAdjustMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelWindowAdjustMessage.cs index 8752db8d..794a8b01 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelWindowAdjustMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Connection/ChannelWindowAdjustMessage.cs @@ -1,7 +1,7 @@  namespace Renci.SshClient.Messages.Connection { - internal class ChannelWindowAdjustMessage : ChannelMessage + public class ChannelWindowAdjustMessage : ChannelMessage { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Messages/Connection/GlobalRequestMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Connection/GlobalRequestMessage.cs index 895b2b5b..9dc3f3fe 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Connection/GlobalRequestMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Connection/GlobalRequestMessage.cs @@ -1,8 +1,8 @@ - -using System; +using System; + namespace Renci.SshClient.Messages.Connection { - internal class GlobalRequestMessage : Message + public class GlobalRequestMessage : Message { public GlobalRequestNames RequestName { get; set; } diff --git a/Renci.SshClient/Renci.SshClient/Messages/Connection/GlobalRequestNames.cs b/Renci.SshClient/Renci.SshClient/Messages/Connection/GlobalRequestNames.cs index 3078e881..b3479d4a 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Connection/GlobalRequestNames.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Connection/GlobalRequestNames.cs @@ -1,6 +1,6 @@ namespace Renci.SshClient.Messages.Connection { - internal enum GlobalRequestNames + public enum GlobalRequestNames { /// /// tcpip-forward diff --git a/Renci.SshClient/Renci.SshClient/Messages/Connection/RequestFailureMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Connection/RequestFailureMessage.cs index ca5c7437..74f6f084 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Connection/RequestFailureMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Connection/RequestFailureMessage.cs @@ -1,7 +1,7 @@  namespace Renci.SshClient.Messages.Connection { - internal class RequestFailureMessage : Message + public class RequestFailureMessage : Message { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Messages/Connection/RequestSuccessMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Connection/RequestSuccessMessage.cs index 6777a792..6dc07bca 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Connection/RequestSuccessMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Connection/RequestSuccessMessage.cs @@ -1,7 +1,7 @@  namespace Renci.SshClient.Messages.Connection { - internal class RequestSuccessMessage : Message + public class RequestSuccessMessage : Message { public uint? BoundPort { get; set; } diff --git a/Renci.SshClient/Renci.SshClient/Messages/ServiceNames.cs b/Renci.SshClient/Renci.SshClient/Messages/ServiceNames.cs index fc7ba08f..3a0bfb39 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/ServiceNames.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/ServiceNames.cs @@ -1,6 +1,6 @@ namespace Renci.SshClient.Messages { - internal enum ServiceNames + public enum ServiceNames { /// /// ssh-userauth diff --git a/Renci.SshClient/Renci.SshClient/Messages/Transport/DebugMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Transport/DebugMessage.cs index a185149f..8e53bdef 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Transport/DebugMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Transport/DebugMessage.cs @@ -1,7 +1,7 @@  namespace Renci.SshClient.Messages.Transport { - internal class DebugMessage : Message + public class DebugMessage : Message { public bool IsAlwaysDisplay { get; set; } diff --git a/Renci.SshClient/Renci.SshClient/Messages/Transport/DisconnectMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Transport/DisconnectMessage.cs index a90ec371..e1dab771 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Transport/DisconnectMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Transport/DisconnectMessage.cs @@ -2,7 +2,7 @@ namespace Renci.SshClient.Messages.Transport { - internal class DisconnectMessage : Message + public class DisconnectMessage : Message { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Messages/Transport/IgnoreMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Transport/IgnoreMessage.cs index 04d893d8..c64a735a 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Transport/IgnoreMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Transport/IgnoreMessage.cs @@ -1,7 +1,7 @@  namespace Renci.SshClient.Messages.Transport { - internal class IgnoreMessage : Message + public class IgnoreMessage : Message { public string Data { get; set; } diff --git a/Renci.SshClient/Renci.SshClient/Messages/Transport/KeyExchangeInitMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Transport/KeyExchangeInitMessage.cs index ee867004..f4c4fce9 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Transport/KeyExchangeInitMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Transport/KeyExchangeInitMessage.cs @@ -4,7 +4,7 @@ using System.Security.Cryptography; namespace Renci.SshClient.Messages.Transport { - internal class KeyExchangeInitMessage : Message + public class KeyExchangeInitMessage : Message { private static RNGCryptoServiceProvider _randomizer = new System.Security.Cryptography.RNGCryptoServiceProvider(); diff --git a/Renci.SshClient/Renci.SshClient/Messages/Transport/NewKeysMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Transport/NewKeysMessage.cs index 05bec349..684e0887 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Transport/NewKeysMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Transport/NewKeysMessage.cs @@ -1,6 +1,6 @@ namespace Renci.SshClient.Messages.Transport { - internal class NewKeysMessage : Message + public class NewKeysMessage : Message { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Messages/Transport/ServiceAcceptMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Transport/ServiceAcceptMessage.cs index d74fb903..8c043e94 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Transport/ServiceAcceptMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Transport/ServiceAcceptMessage.cs @@ -5,7 +5,7 @@ namespace Renci.SshClient.Messages.Transport /// /// SSH_MSG_SERVICE_ACCEPT /// - internal class ServiceAcceptMessage : Message + public class ServiceAcceptMessage : Message { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Messages/Transport/ServiceRequestMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Transport/ServiceRequestMessage.cs index 246e2fc5..2de22ad5 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Transport/ServiceRequestMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Transport/ServiceRequestMessage.cs @@ -5,7 +5,7 @@ namespace Renci.SshClient.Messages.Transport /// /// Contains SSH_MSG_SERVICE_REQUEST message information /// - internal class ServiceRequestMessage : Message + public class ServiceRequestMessage : Message { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Messages/Transport/UnimplementedMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Transport/UnimplementedMessage.cs index 9f6a5232..3240d453 100644 --- a/Renci.SshClient/Renci.SshClient/Messages/Transport/UnimplementedMessage.cs +++ b/Renci.SshClient/Renci.SshClient/Messages/Transport/UnimplementedMessage.cs @@ -1,7 +1,7 @@  namespace Renci.SshClient.Messages.Transport { - internal class UnimplementedMessage : Message + public class UnimplementedMessage : Message { public override MessageTypes MessageType { diff --git a/Renci.SshClient/Renci.SshClient/Renci.SshClient.csproj b/Renci.SshClient/Renci.SshClient/Renci.SshClient.csproj index 21c679f9..93b13cba 100644 --- a/Renci.SshClient/Renci.SshClient/Renci.SshClient.csproj +++ b/Renci.SshClient/Renci.SshClient/Renci.SshClient.csproj @@ -98,6 +98,7 @@ + diff --git a/Renci.SshClient/Renci.SshClient/Security/Cipher.cs b/Renci.SshClient/Renci.SshClient/Security/Cipher.cs index 194d2a2f..c310f13c 100644 --- a/Renci.SshClient/Renci.SshClient/Security/Cipher.cs +++ b/Renci.SshClient/Renci.SshClient/Security/Cipher.cs @@ -3,7 +3,7 @@ using System.Linq; namespace Renci.SshClient.Security { - internal abstract class Cipher + public abstract class Cipher { public abstract string Name { get; } diff --git a/Renci.SshClient/Renci.SshClient/Session.cs b/Renci.SshClient/Renci.SshClient/Session.cs index ed09e873..6e681f6b 100644 --- a/Renci.SshClient/Renci.SshClient/Session.cs +++ b/Renci.SshClient/Renci.SshClient/Session.cs @@ -21,7 +21,7 @@ using Renci.SshClient.Security; namespace Renci.SshClient { - internal class Session : IDisposable + public class Session : IDisposable { protected const int MAXIMUM_PACKET_SIZE = 35000; @@ -233,137 +233,137 @@ namespace Renci.SshClient /// /// Occurs when message received /// - public event EventHandler> DisconnectReceived; + internal event EventHandler> DisconnectReceived; /// /// Occurs when message received /// - public event EventHandler> IgnoreReceived; + internal event EventHandler> IgnoreReceived; /// /// Occurs when message received /// - public event EventHandler> UnimplementedReceived; + internal event EventHandler> UnimplementedReceived; /// /// Occurs when message received /// - public event EventHandler> DebugReceived; + internal event EventHandler> DebugReceived; /// /// Occurs when message received /// - public event EventHandler> ServiceRequestReceived; + internal event EventHandler> ServiceRequestReceived; /// /// Occurs when message received /// - public event EventHandler> ServiceAcceptReceived; + internal event EventHandler> ServiceAcceptReceived; /// /// Occurs when message received /// - public event EventHandler> KeyExchangeInitReceived; + internal event EventHandler> KeyExchangeInitReceived; /// /// Occurs when message received /// - public event EventHandler> NewKeysReceived; + internal event EventHandler> NewKeysReceived; /// /// Occurs when message received /// - public event EventHandler> UserAuthenticationRequestReceived; + internal event EventHandler> UserAuthenticationRequestReceived; /// /// Occurs when message received /// - public event EventHandler> UserAuthenticationFailureReceived; + internal event EventHandler> UserAuthenticationFailureReceived; /// /// Occurs when message received /// - public event EventHandler> UserAuthenticationSuccessReceived; + internal event EventHandler> UserAuthenticationSuccessReceived; /// /// Occurs when message received /// - public event EventHandler> UserAuthenticationBannerReceived; + internal event EventHandler> UserAuthenticationBannerReceived; /// /// Occurs when message received /// - public event EventHandler> GlobalRequestReceived; + internal event EventHandler> GlobalRequestReceived; /// /// Occurs when message received /// - public event EventHandler> RequestSuccessReceived; + internal event EventHandler> RequestSuccessReceived; /// /// Occurs when message received /// - public event EventHandler> RequestFailureReceived; + internal event EventHandler> RequestFailureReceived; /// /// Occurs when message received /// - public event EventHandler> ChannelOpenReceived; + internal event EventHandler> ChannelOpenReceived; /// /// Occurs when message received /// - public event EventHandler> ChannelOpenConfirmationReceived; + internal event EventHandler> ChannelOpenConfirmationReceived; /// /// Occurs when message received /// - public event EventHandler> ChannelOpenFailureReceived; + internal event EventHandler> ChannelOpenFailureReceived; /// /// Occurs when message received /// - public event EventHandler> ChannelWindowAdjustReceived; + internal event EventHandler> ChannelWindowAdjustReceived; /// /// Occurs when message received /// - public event EventHandler> ChannelDataReceived; + internal event EventHandler> ChannelDataReceived; /// /// Occurs when message received /// - public event EventHandler> ChannelExtendedDataReceived; + internal event EventHandler> ChannelExtendedDataReceived; /// /// Occurs when message received /// - public event EventHandler> ChannelEofReceived; + internal event EventHandler> ChannelEofReceived; /// /// Occurs when message received /// - public event EventHandler> ChannelCloseReceived; + internal event EventHandler> ChannelCloseReceived; /// /// Occurs when message received /// - public event EventHandler> ChannelRequestReceived; + internal event EventHandler> ChannelRequestReceived; /// /// Occurs when message received /// - public event EventHandler> ChannelSuccessReceived; + internal event EventHandler> ChannelSuccessReceived; /// /// Occurs when message received /// - public event EventHandler> ChannelFailureReceived; + internal event EventHandler> ChannelFailureReceived; /// /// Occurs when message received and is not handled by any of the event handlers /// - public event EventHandler> MessageReceived; + internal event EventHandler> MessageReceived; #endregion @@ -553,12 +553,12 @@ namespace Renci.SshClient this.SendDisconnect(DisconnectReasons.ByApplication, "Connection terminated by the client."); } - public T CreateChannel() where T : Channel, new() + internal T CreateChannel() where T : Channel, new() { return CreateChannel(0, 0x100000, 0x8000); } - public T CreateChannel(uint serverChannelNumber, uint windowSize, uint packetSize) where T : Channel, new() + internal T CreateChannel(uint serverChannelNumber, uint windowSize, uint packetSize) where T : Channel, new() { T channel = new T(); lock (this) @@ -1008,7 +1008,7 @@ namespace Renci.SshClient { this._keyExchangeCompletedWaitHandle.Reset(); - // Connection type messages are not allowed during key excahnge phase + // Connection type messages are not allowed during key exchange phase this.UnRegisterMessageType(MessageTypes.GlobalRequest); this.UnRegisterMessageType(MessageTypes.RequestSuccess); this.UnRegisterMessageType(MessageTypes.RequestFailure); diff --git a/Renci.SshClient/Renci.SshClient/SftpClient.cs b/Renci.SshClient/Renci.SshClient/SftpClient.cs index 6b0fb9c4..e4d76a17 100644 --- a/Renci.SshClient/Renci.SshClient/SftpClient.cs +++ b/Renci.SshClient/Renci.SshClient/SftpClient.cs @@ -8,39 +8,13 @@ namespace Renci.SshClient /// /// /// - public class SftpClient : IDisposable + public class SftpClient : SshBaseClient { + /// + /// Holds SftpSession instance that used to communicate to the SFTP server + /// private SftpSession _sftpSession; - private Session _session; - - /// - /// Gets the connection info. - /// - /// The connection info. - public ConnectionInfo ConnectionInfo { get; private set; } - - /// - /// Gets a value indicating whether client is connected. - /// - /// - /// true if client is connected; otherwise, false. - /// - public bool IsConnected - { - get - { - if (this._session == null) - { - return false; - } - else - { - return this._session.IsConnected; - } - } - } - /// /// Gets or sets the operation timeout. /// @@ -60,10 +34,10 @@ namespace Renci.SshClient /// /// The connection info. public SftpClient(ConnectionInfo connectionInfo) + : base(connectionInfo) { this.OperationTimeout = -1; this.BufferSize = 1024 * 16; - this.ConnectionInfo = connectionInfo; } /// @@ -74,7 +48,7 @@ namespace Renci.SshClient /// The username. /// The password. public SftpClient(string host, int port, string username, string password) - : this(new ConnectionInfo + : base(new ConnectionInfo { Host = host, Port = port, @@ -91,7 +65,7 @@ namespace Renci.SshClient /// The username. /// The password. public SftpClient(string host, string username, string password) - : this(new ConnectionInfo + : base(new ConnectionInfo { Host = host, Username = username, @@ -108,7 +82,7 @@ namespace Renci.SshClient /// The username. /// The key file. public SftpClient(string host, int port, string username, PrivateKeyFile keyFile) - : this(new ConnectionInfo + : base(new ConnectionInfo { Host = host, Port = port, @@ -125,7 +99,7 @@ namespace Renci.SshClient /// The username. /// The key file. public SftpClient(string host, string username, PrivateKeyFile keyFile) - : this(new ConnectionInfo + : base(new ConnectionInfo { Host = host, Username = username, @@ -136,38 +110,10 @@ namespace Renci.SshClient #endregion - /// - /// Connects client to the server. - /// - public void Connect() - { - if (this._session == null) - { - this._session = new Session(this.ConnectionInfo); - } - this._session.Connect(); - - this._sftpSession = new SftpSession(this._session, this.OperationTimeout); - - this._sftpSession.Connect(); - } - - /// - /// Disconnects client from the server. - /// - public void Disconnect() - { - this._sftpSession.Disconnect(); - - this._session.Disconnect(); - - this._session = null; - } - #region List Directory /// - /// Begins the list directory. + /// Begins the list directory operation. /// /// The path. /// The async callback. @@ -183,10 +129,10 @@ namespace Renci.SshClient } /// - /// Ends the list directory. + /// Ends the list directory operation. /// /// An that references the asynchronous operation. - /// + /// List of files public IEnumerable EndListDirectory(IAsyncResult asyncResult) { var sftpAsyncResult = asyncResult as SftpAsyncResult; @@ -207,7 +153,7 @@ namespace Renci.SshClient /// Lists the directory. /// /// The path. - /// + /// List of files public IEnumerable ListDirectory(string path) { return this.EndListDirectory(this.BeginListDirectory(path, null, null)); @@ -554,51 +500,27 @@ namespace Renci.SshClient #endregion - #region IDisposable Members - - private bool disposed = false; - - public void Dispose() + /// + /// Called when client is connected to the server. + /// + protected override void OnConnected() { - Dispose(true); + base.OnConnected(); - GC.SuppressFinalize(this); + this._sftpSession = new SftpSession(this.Session, this.OperationTimeout); + + this._sftpSession.Connect(); } - private void Dispose(bool disposing) + /// + /// Called when client is disconnecting from the server. + /// + protected override void OnDisconnecting() { - // Check to see if Dispose has already been called. - if (!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if (disposing) - { - // Dispose managed resources. - if (this._session != null) - { - this._session.Dispose(); - } - if (this._sftpSession != null) - { - this._sftpSession.Dispose(); - } - } + base.OnDisconnecting(); - // Note disposing has been done. - disposed = true; - } + this._sftpSession.Disconnect(); } - ~SftpClient() - { - // Do not re-create Dispose clean-up code here. - // Calling Dispose(false) is optimal in terms of - // readability and maintainability. - Dispose(false); - } - - #endregion - } } \ No newline at end of file diff --git a/Renci.SshClient/Renci.SshClient/SshBaseClient.cs b/Renci.SshClient/Renci.SshClient/SshBaseClient.cs new file mode 100644 index 00000000..dffeb56d --- /dev/null +++ b/Renci.SshClient/Renci.SshClient/SshBaseClient.cs @@ -0,0 +1,161 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; +using Renci.SshClient.Sftp; + +namespace Renci.SshClient +{ + public abstract class SshBaseClient : IDisposable + { + /// + /// Gets current session. + /// + protected Session Session { get; private set; } + + /// + /// Gets the connection info. + /// + public ConnectionInfo ConnectionInfo { get; private set; } + + /// + /// Gets a value indicating whether this client is connected to the server. + /// + /// + /// true if this client is connected; otherwise, false. + /// + public bool IsConnected + { + get + { + if (this.Session == null) + return false; + else + return this.Session.IsConnected; + } + } + + /// + /// Initializes a new instance of the class. + /// + /// The connection info. + public SshBaseClient(ConnectionInfo connectionInfo) + { + this.ConnectionInfo = connectionInfo; + this.Session = new Session(connectionInfo); + } + + /// + /// Connects client to the server. + /// + public void Connect() + { + this.OnConnecting(); + + if (this.IsConnected) + { + this.Session.Disconnect(); + } + + this.Session = new Session(this.ConnectionInfo); + this.Session.Connect(); + + this.OnConnected(); + } + + /// + /// Disconnects client from the server. + /// + public void Disconnect() + { + this.OnDisconnecting(); + + this.Session.Disconnect(); + + this.OnDisconnected(); + } + + /// + /// Sends keep-alive message to the server. + /// + public void KeepAlive() + { + this.Session.KeepAlive(); + } + + /// + /// Called when client is connecting to the server. + /// + protected virtual void OnConnecting() + { + + } + + /// + /// Called when client is connected to the server. + /// + protected virtual void OnConnected() + { + + } + + /// + /// Called when client is disconnecting from the server. + /// + protected virtual void OnDisconnecting() + { + + } + + /// + /// Called when client is disconnected from the server. + /// + protected virtual void OnDisconnected() + { + + } + + #region IDisposable Members + + private bool disposed = false; + + public void Dispose() + { + Dispose(true); + + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + // Check to see if Dispose has already been called. + if (!this.disposed) + { + // If disposing equals true, dispose all managed + // and unmanaged resources. + if (disposing) + { + // Dispose managed resources. + if (this.Session != null) + { + this.Session.Dispose(); + } + } + + // Note disposing has been done. + disposed = true; + } + } + + ~SshBaseClient() + { + // Do not re-create Dispose clean-up code here. + // Calling Dispose(false) is optimal in terms of + // readability and maintainability. + Dispose(false); + } + + #endregion + } +} diff --git a/Renci.SshClient/Renci.SshClient/SshClient.cs b/Renci.SshClient/Renci.SshClient/SshClient.cs index 9b435446..bb833060 100644 --- a/Renci.SshClient/Renci.SshClient/SshClient.cs +++ b/Renci.SshClient/Renci.SshClient/SshClient.cs @@ -4,25 +4,16 @@ using System.IO; namespace Renci.SshClient { - public class SshClient : IDisposable + public class SshClient : SshBaseClient { - private Session _session; - + /// + /// Holds the list of forwarded ports + /// private List _forwardedPorts = new List(); - public ConnectionInfo ConnectionInfo { get; private set; } - - public bool IsConnected - { - get - { - if (this._session == null) - return false; - else - return this._session.IsConnected; - } - } - + /// + /// Gets the list of forwarded ports. + /// public IEnumerable ForwardedPorts { get @@ -31,14 +22,15 @@ namespace Renci.SshClient } } + #region Constructors + public SshClient(ConnectionInfo connectionInfo) + : base(connectionInfo) { - this.ConnectionInfo = connectionInfo; - this._session = new Session(connectionInfo); } public SshClient(string host, int port, string username, string password) - : this(new ConnectionInfo + : base(new ConnectionInfo { Host = host, Port = port, @@ -49,7 +41,7 @@ namespace Renci.SshClient } public SshClient(string host, string username, string password) - : this(new ConnectionInfo + : base(new ConnectionInfo { Host = host, Username = username, @@ -59,7 +51,7 @@ namespace Renci.SshClient } public SshClient(string host, int port, string username, PrivateKeyFile keyFile) - : this(new ConnectionInfo + : base(new ConnectionInfo { Host = host, Port = port, @@ -70,7 +62,7 @@ namespace Renci.SshClient } public SshClient(string host, string username, PrivateKeyFile keyFile) - : this(new ConnectionInfo + : base(new ConnectionInfo { Host = host, Username = username, @@ -79,29 +71,34 @@ namespace Renci.SshClient { } - public void Connect() - { - this._session = new Session(this.ConnectionInfo); - this._session.Connect(); - } + #endregion - public void Disconnect() + /// + /// Called when client is disconnecting from the server. + /// + protected override void OnDisconnecting() { + base.OnDisconnecting(); + foreach (var port in this._forwardedPorts) { port.Stop(); } - this._session.Disconnect(); - - // Clean up objects created using previouse session instance - //this._sftp = null; } + /// + /// Adds forwarded port to the list. + /// + /// Type of forwarded port to add + /// The bound port. + /// The connected host. + /// The connected port. + /// Forwarded port public T AddForwardedPort(uint boundPort, string connectedHost, uint connectedPort) where T : ForwardedPort, new() { T port = new T(); - port.Session = this._session; + port.Session = this.Session; port.BoundPort = boundPort; port.ConnectedHost = connectedHost; port.ConnectedPort = connectedPort; @@ -111,6 +108,10 @@ namespace Renci.SshClient return port; } + /// + /// Stops and removes the forwarded port from the list. + /// + /// Forwarded port. public void RemoveForwardedPort(ForwardedPort port) { // Stop port forwarding before removing it @@ -119,16 +120,21 @@ namespace Renci.SshClient this._forwardedPorts.Remove(port); } - public void KeepAlive() - { - this._session.KeepAlive(); - } - + /// + /// Creates the command to be executed. + /// + /// The command text. + /// public SshCommand CreateCommand(string commandText) { - return new SshCommand(this._session, commandText); + return new SshCommand(this.Session, commandText); } + /// + /// Creates and executes the command. + /// + /// The command text. + /// public SshCommand RunCommand(string commandText) { var cmd = this.CreateCommand(commandText); @@ -136,51 +142,22 @@ namespace Renci.SshClient return cmd; } + /// + /// Creates the shell. (not complete) + /// + /// The input. + /// The output. + /// The extended output. + /// Name of the terminal. + /// The columns. + /// The rows. + /// The width. + /// The height. + /// The terminal mode. + /// public Shell CreateShell(Stream input, TextWriter output, TextWriter extendedOutput, string terminalName, uint columns, uint rows, uint width, uint height, string terminalMode) { - return new Shell(this._session, input, output, extendedOutput, terminalName, columns, rows, width, height, terminalMode); + return new Shell(this.Session, input, output, extendedOutput, terminalName, columns, rows, width, height, terminalMode); } - - #region IDisposable Members - - private bool disposed = false; - - public void Dispose() - { - Dispose(true); - - GC.SuppressFinalize(this); - } - - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if (!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if (disposing) - { - // Dispose managed resources. - if (this._session != null) - { - this._session.Dispose(); - } - } - - // Note disposing has been done. - disposed = true; - } - } - - ~SshClient() - { - // Do not re-create Dispose clean-up code here. - // Calling Dispose(false) is optimal in terms of - // readability and maintainability. - Dispose(false); - } - - #endregion } }