Skip to content

Commit

Permalink
Implemented "set tcp nodelay" for SSH connections (#75)
Browse files Browse the repository at this point in the history
Can't tell if its actually doing anything but I guess no errors means success?
  • Loading branch information
davidrg committed Aug 27, 2022
1 parent ac7fbae commit 609c60b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion kermit/k95/ckoshs.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ ssh_parameters_t* ssh_parameters_new(
char* user_known_hosts_file, char* global_known_hosts_file,
char* username, char* password, char* terminal_type, int pty_width,
int pty_height, char* auth_methods, char* ciphers, int heartbeat,
char* hostkey_algorithms, char* macs, char* key_exchange_methods) {
char* hostkey_algorithms, char* macs, char* key_exchange_methods,
int nodelay) {
ssh_parameters_t* params;

params = malloc(sizeof(ssh_parameters_t));
Expand All @@ -107,6 +108,7 @@ ssh_parameters_t* ssh_parameters_new(
params->macs = NULL;
params->key_exchange_methods = NULL;
params->keepalive_seconds = heartbeat;
params->nodelay = nodelay;

/* Copy hostname and port*/
params->hostname = _strdup(hostname);
Expand Down Expand Up @@ -1185,6 +1187,8 @@ static int configure_session(ssh_client_state_t * state) {
&state->parameters->gssapi_delegate_credentials);
ssh_options_set(state->session, SSH_OPTIONS_PROCESS_CONFIG,
&state->parameters->use_openssh_config);
ssh_options_set(state->session, SSH_OPTIONS_NODELAY,
&state->parameters->nodelay);
if (!state->parameters->compression) {
ssh_options_set(state->session, SSH_OPTIONS_COMPRESSION_C_S, "no");
ssh_options_set(state->session, SSH_OPTIONS_COMPRESSION_S_C, "no");
Expand Down
5 changes: 4 additions & 1 deletion kermit/k95/ckoshs.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ typedef struct {
char* key_exchange_methods; /* Comma separated list */
int keepalive_seconds; /* Keepalive interval in
* seconds, 0 disables. */
int nodelay; /* Set to disable nagles agorithm */

/* Allowed authentication types */
BOOL allow_password_auth;
Expand Down Expand Up @@ -183,6 +184,7 @@ void get_current_terminal_dimensions(int* rows, int* cols);
* @param hostkey_algorithms Comma-separated list of allowed hostkey algorithms
* @param macs Comma-separated list of allowed macs
* @param key_exchange_methods Comma-separated list of key exchange methods
* @param nodelay Set to disable Nagle's algorithm
* @return A new ssh_parameters_t instance.
*/
ssh_parameters_t* ssh_parameters_new(
Expand All @@ -192,7 +194,8 @@ ssh_parameters_t* ssh_parameters_new(
char* user_known_hosts_file, char* global_known_hosts_file,
char* username, char* password, char* terminal_type, int pty_width,
int pty_height, char* auth_methods, char* ciphers, int heartbeat,
char* hostkey_algorithms, char* macs, char* key_exchange_methods);
char* hostkey_algorithms, char* macs, char* key_exchange_methods,
int nodelay);

/** Frees the ssh_parameters_t struct and all its members.
*
Expand Down
5 changes: 4 additions & 1 deletion kermit/k95/ckossh.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ char *cksshv = "SSH support, 10.0.0, 28 July 2022";
* char* ssh2_gnh NULL SSH-2 Global Known Hosts file
* int pwflg 0 Password has been supplied (/password:)
* int ssh_hbt 0 Heartbeat (keepalive) setting
* int tcp_nodelay 0 Enable/disable nagle algorithm
* char* pwbuf "\0" Supplied password
* char* uidbuf "" Supplied username (if any)
* char* ssh2_auth NULL Comma-separated list of allowed auth methods
Expand Down Expand Up @@ -250,6 +251,7 @@ char *cksshv = "SSH support, 10.0.0, 28 July 2022";
extern char uidbuf[]; /* User ID set via /user: */
extern char pwbuf[]; /* Password set via /password: */
extern int pwflg; /* Password has been set */
extern int tcp_nodelay; /* Enable/disable Nagle's algorithm */
int ssh_sock; /* TODO: get rid of this (unless its needed for connecting
* through a proxy server?) */

Expand Down Expand Up @@ -491,7 +493,8 @@ int ssh_open() {
ssh_hbt, /* Heartbeat in seconds */
ssh2_hka, /* Allowed host key algorithms */
ssh2_mac, /* Allowed MACs */
ssh2_kex /* Key exchange methods */
ssh2_kex, /* Key exchange methods */
tcp_nodelay /* Enable/disable Nagle's algorithm */
);
if (parameters == NULL) {
debug(F100, "ssh_open() - failed to construct parameters struct", "", 0);
Expand Down

0 comments on commit 609c60b

Please sign in to comment.