Skip to content

Feature: Global Response Handler (for SSH Server Keepalives) - #711

Closed
JustinGrote wants to merge 3 commits into
sshnet:developfrom
JustinGrote:feature/ServerKeepaliveResponse
Closed

JustinGrote wants to merge 3 commits into
sshnet:developfrom
JustinGrote:feature/ServerKeepaliveResponse

Conversation

@JustinGrote

@JustinGrote JustinGrote commented Jul 29, 2020 •

Copy link
Copy Markdown

This adds a static method for responding to global requests, which simply returns a request failed packet if a global message is received. This is sufficient for the server keepalive mechanisms used by several SSH servers and is RFC4254 compliant.
https://tools.ietf.org/html/rfc4254#section-4

Resolves #709

NOTE: I am a C# n00b (Primarily a Powershell guy) and will need help refactoring this to something mergeable, and how to do tests.

/// <summary>
/// Responds to SSH Global Requests (https://tools.ietf.org/html/rfc4254#section-4)
/// </summary>
class GlobalRequests {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify the access modifier (public/internal/private...)

/// </summary>
internal static void GlobalRequestHandler(Object sender, EventArgs e)
{
var session = (ISession) sender;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Safer if programmed as
(sender as ISession)?.SendMessage(new RequestFailureMessage());

or

if (sender is  ISession session)
{
    session.SendMessage(new RequestFailureMessage());
}

/// <summary>
/// Responds to SSH Global Requests (https://tools.ietf.org/html/rfc4254#section-4)
/// </summary>
class GlobalRequests {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a unit test for this new class and functionality.

@JustinGrote

Copy link
Copy Markdown
Author

Closing as I have no interest in pursing this further, someone else can feel free to pick it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] respond to server check alive requests

2 participants