Skip to content

Commit

Permalink
Merge pull request #189 from PepperDash/ssh-fix
Browse files Browse the repository at this point in the history
Update some exception messages to not print exception
  • Loading branch information
ndorin authored Mar 6, 2025
2 parents ab61b26 + 8ace195 commit 880a68b
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/Comm/GenericSshClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public void Connect()
try
{
Client.Connect();
TheStream = Client.CreateShellStream("PDTShell", 100, 80, 100, 200, 65534);
TheStream = Client.CreateShellStream("PDTShell", 0, 0, 0, 0, 65534);
if (TheStream.DataAvailable)
{
// empty the buffer if there is data
Expand All @@ -269,18 +269,17 @@ public void Connect()

if (ie is SocketException)
{
this.LogException(ie, "CONNECTION failure: Cannot reach host, ({1})", Key, ie.Message);
this.LogException(ie, "CONNECTION failure: Cannot reach host");
}

if (ie is System.Net.Sockets.SocketException socketException)
{
this.LogException(ie, "'{0}' Connection failure: Cannot reach host '{1}' on port {2}, ({3})",
Key, Hostname, Port, ie.GetType());
this.LogException(ie, "Connection failure: Cannot reach {host} on {port}",
Hostname, Port);
}
if (ie is SshAuthenticationException)
{
this.LogException(ie, "Authentication failure for username '{0}', ({1})", this,
Username, ie.Message);
this.LogException(ie, "Authentication failure for username {userName}", Username);
}
else
this.LogException(ie, "Error on connect");
Expand All @@ -289,7 +288,7 @@ public void Connect()
KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED);
if (AutoReconnect)
{
this.LogDebug("Checking autoreconnect: {0}, {1}ms", AutoReconnect, AutoReconnectIntervalMs);
this.LogDebug("Checking autoreconnect: {autoReconnect}, {autoReconnectInterval}ms", AutoReconnect, AutoReconnectIntervalMs);
ReconnectTimer.Reset(AutoReconnectIntervalMs);
}
}
Expand Down Expand Up @@ -499,14 +498,14 @@ public void SendText(string text)
}
catch (ObjectDisposedException ex)
{
this.LogException(ex, "ObjectDisposedException sending {message}", text);
this.LogError("ObjectDisposedException sending '{message}'. Restarting connection...", text.Trim());

KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED);
ReconnectTimer.Reset();
}
catch (Exception ex)
{
this.LogException(ex, "Exception sending text: {message}", text);
this.LogException(ex, "Exception sending text: '{message}'", text);
}
}

Expand Down

0 comments on commit 880a68b

Please sign in to comment.