mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-02-15 20:54:46 +00:00
sshClient, removing comments and repairing indentation
This commit is contained in:
@@ -212,55 +212,28 @@ namespace PepperDash.Core
|
|||||||
kauth.AuthenticationPrompt += new EventHandler<AuthenticationPromptEventArgs>(kauth_AuthenticationPrompt);
|
kauth.AuthenticationPrompt += new EventHandler<AuthenticationPromptEventArgs>(kauth_AuthenticationPrompt);
|
||||||
PasswordAuthenticationMethod pauth = new PasswordAuthenticationMethod(Username, Password);
|
PasswordAuthenticationMethod pauth = new PasswordAuthenticationMethod(Username, Password);
|
||||||
|
|
||||||
// Make a new client if we need it or things have changed
|
if (Client != null)
|
||||||
//if (Client == null || PropertiesHaveChanged())
|
{
|
||||||
//{
|
Debug.Console(1, this, "Cleaning up disconnected client");
|
||||||
if (Client != null)
|
Client.ErrorOccurred -= Client_ErrorOccurred;
|
||||||
{
|
KillStream();
|
||||||
Debug.Console(1, this, "Cleaning up disconnected client");
|
}
|
||||||
Client.ErrorOccurred -= Client_ErrorOccurred;
|
|
||||||
KillStream();
|
|
||||||
|
|
||||||
//if (TheStream != null)
|
|
||||||
//{
|
|
||||||
// TheStream.DataReceived -= Stream_DataReceived;
|
|
||||||
// TheStream.ErrorOccurred -= TheStream_ErrorOccurred;
|
|
||||||
//}
|
|
||||||
//TheStream = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug.Console(1, this, "Creating new SshClient");
|
Debug.Console(1, this, "Creating new SshClient");
|
||||||
ConnectionInfo connectionInfo = new ConnectionInfo(Hostname, Port, Username, pauth, kauth);
|
ConnectionInfo connectionInfo = new ConnectionInfo(Hostname, Port, Username, pauth, kauth);
|
||||||
Client = new SshClient(connectionInfo);
|
Client = new SshClient(connectionInfo);
|
||||||
Client.ErrorOccurred += Client_ErrorOccurred;
|
Client.ErrorOccurred += Client_ErrorOccurred;
|
||||||
//}
|
|
||||||
//PreviousHostname = Hostname;
|
|
||||||
//PreviousPassword = Password;
|
|
||||||
//PreviousPort = Port;
|
|
||||||
//PreviousUsername = Username;
|
|
||||||
|
|
||||||
//You can do it!
|
//You can do it!
|
||||||
ClientStatus = SocketStatus.SOCKET_STATUS_WAITING;
|
ClientStatus = SocketStatus.SOCKET_STATUS_WAITING;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Client.Connect();
|
Client.Connect();
|
||||||
|
TheStream = Client.CreateShellStream("PDTShell", 100, 80, 100, 200, 65534);
|
||||||
// Have to assume client is connected cause Client.IsConnected is busted in some cases
|
TheStream.DataReceived += Stream_DataReceived;
|
||||||
// All other conditions *should* error out...
|
//TheStream.ErrorOccurred += TheStream_ErrorOccurred;
|
||||||
//if (Client.IsConnected)
|
Debug.Console(1, this, "Connected");
|
||||||
//{
|
ClientStatus = SocketStatus.SOCKET_STATUS_CONNECTED;
|
||||||
//Client.KeepAliveInterval = TimeSpan.FromSeconds(2);
|
|
||||||
//Client.SendKeepAlive();
|
|
||||||
TheStream = Client.CreateShellStream("PDTShell", 100, 80, 100, 200, 65534);
|
|
||||||
TheStream.DataReceived += Stream_DataReceived;
|
|
||||||
//TheStream.ErrorOccurred += TheStream_ErrorOccurred;
|
|
||||||
Debug.Console(1, this, "Connected");
|
|
||||||
ClientStatus = SocketStatus.SOCKET_STATUS_CONNECTED;
|
|
||||||
//PreviousHostname = Hostname;
|
|
||||||
//PreviousPassword = Password;
|
|
||||||
//PreviousPort = Port;
|
|
||||||
//PreviousUsername = Username;
|
|
||||||
//}
|
|
||||||
return; // Success will not pass here
|
return; // Success will not pass here
|
||||||
}
|
}
|
||||||
catch (SshConnectionException e)
|
catch (SshConnectionException e)
|
||||||
@@ -320,6 +293,8 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
void HandleConnectionFailure()
|
void HandleConnectionFailure()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if (Client != null)
|
if (Client != null)
|
||||||
Client.Disconnect();
|
Client.Disconnect();
|
||||||
KillStream();
|
KillStream();
|
||||||
|
|||||||
Reference in New Issue
Block a user