diff --git a/src/protocols/rdp/rdp.c b/src/protocols/rdp/rdp.c index bbe76851..7b52a917 100644 --- a/src/protocols/rdp/rdp.c +++ b/src/protocols/rdp/rdp.c @@ -977,7 +977,7 @@ void* guac_rdp_client_thread(void* data) { /* Attempt SSH connection */ rdp_client->sftp_session = guac_common_ssh_create_session(client, settings->sftp_hostname, - settings->sftp_port, rdp_client->sftp_user, rdp_client->sftp_keepalive); + settings->sftp_port, rdp_client->sftp_user, settings->sftp_keepalive); /* Fail if SSH connection does not succeed */ if (rdp_client->sftp_session == NULL) { diff --git a/src/protocols/rdp/rdp.h b/src/protocols/rdp/rdp.h index 70e909b1..943155dd 100644 --- a/src/protocols/rdp/rdp.h +++ b/src/protocols/rdp/rdp.h @@ -141,11 +141,6 @@ typedef struct guac_rdp_client { * An SFTP-based filesystem. */ guac_common_ssh_sftp_filesystem* sftp_filesystem; - - /** - * A keepalive interval for SFTP connections. - */ - int sftp_keepalive; #endif /** diff --git a/src/protocols/rdp/rdp_settings.c b/src/protocols/rdp/rdp_settings.c index 998f0a21..32c09415 100644 --- a/src/protocols/rdp/rdp_settings.c +++ b/src/protocols/rdp/rdp_settings.c @@ -84,6 +84,7 @@ const char* GUAC_RDP_CLIENT_ARGS[] = { "sftp-private-key", "sftp-passphrase", "sftp-directory", + "sftp-keepalive", #endif "recording-path", @@ -366,6 +367,13 @@ enum RDP_ARGS_IDX { */ IDX_SFTP_DIRECTORY, + /** + * The interval at which SSH keepalive messages are sent to the server for + * SFTP connections. The default is 0 (disabling keepalives), and a value + * of 1 is automatically increased to 2 by libssh2 to avoid busy loop corner + * cases. + */ + IDX_SFTP_KEEPALIVE, #endif /** @@ -775,6 +783,14 @@ guac_rdp_settings* guac_rdp_parse_args(guac_user* user, settings->sftp_directory = guac_user_parse_args_string(user, GUAC_RDP_CLIENT_ARGS, argv, IDX_SFTP_DIRECTORY, NULL); + + /* Default keepalive value */ + settings->sftp_keepalive = + guac_user_parse_args_int(user, GUAC_RDP_CLIENT_ARGS, argv, + IDX_SFTP_KEEPALIVE, 0); + if (settings->sftp_keepalive == 1) + guac_user_log(user, GUAC_LOG_WARNING, "The minimum allowed " + "value for keepalives by libssh2 is 2 seconds."); #endif /* Read recording path */ diff --git a/src/protocols/rdp/rdp_settings.h b/src/protocols/rdp/rdp_settings.h index 3ff634ad..47e5289a 100644 --- a/src/protocols/rdp/rdp_settings.h +++ b/src/protocols/rdp/rdp_settings.h @@ -359,6 +359,14 @@ typedef struct guac_rdp_settings { * the destination directory is otherwise ambiguous). */ char* sftp_directory; + + /** + * The interval at which SSH keepalive messages are sent to the server for + * SFTP connections. The default is 0 (disabling keepalives), and a value + * of 1 is automatically increased to 2 by libssh2 to avoid busy loop corner + * cases. + */ + int sftp_keepalive; #endif /** diff --git a/src/protocols/vnc/settings.c b/src/protocols/vnc/settings.c index 0977af19..60e2f61c 100644 --- a/src/protocols/vnc/settings.c +++ b/src/protocols/vnc/settings.c @@ -66,6 +66,7 @@ const char* GUAC_VNC_CLIENT_ARGS[] = { "sftp-private-key", "sftp-passphrase", "sftp-directory", + "sftp-keepalive", #endif "recording-path", @@ -227,6 +228,14 @@ enum VNC_ARGS_IDX { * the destination directory is otherwise ambiguous). */ IDX_SFTP_DIRECTORY, + + /** + * The interval at which SSH keepalive messages are sent to the server for + * SFTP connections. The default is 0 (disabling keepalives), and a value + * of 1 is automatically increased to 2 by libssh2 to avoid busy loop corner + * cases. + */ + IDX_SFTP_KEEPALIVE, #endif /** @@ -395,6 +404,14 @@ guac_vnc_settings* guac_vnc_parse_args(guac_user* user, settings->sftp_directory = guac_user_parse_args_string(user, GUAC_VNC_CLIENT_ARGS, argv, IDX_SFTP_DIRECTORY, NULL); + + /* Default keepalive value */ + settings->sftp_keepalive = + guac_user_parse_args_int(user, GUAC_VNC_CLIENT_ARGS, argv, + IDX_SFTP_KEEPALIVE, 0); + if (settings->sftp_keepalive == 1) + guac_user_log(user, GUAC_LOG_WARNING, "The minimum allowed " + "value for keepalives by libssh2 is 2 seconds."); #endif /* Read recording path */ diff --git a/src/protocols/vnc/settings.h b/src/protocols/vnc/settings.h index 17626676..ba1bfdde 100644 --- a/src/protocols/vnc/settings.h +++ b/src/protocols/vnc/settings.h @@ -173,6 +173,14 @@ typedef struct guac_vnc_settings { * the destination directory is otherwise ambiguous). */ char* sftp_directory; + + /** + * The interval at which SSH keepalive messages are sent to the server for + * SFTP connections. The default is 0 (disabling keepalives), and a value + * of 1 is automatically increased to 2 by libssh2 to avoid busy loop corner + * cases. + */ + int sftp_keepalive; #endif /** diff --git a/src/protocols/vnc/vnc.c b/src/protocols/vnc/vnc.c index 4410e5f7..9aac436b 100644 --- a/src/protocols/vnc/vnc.c +++ b/src/protocols/vnc/vnc.c @@ -261,7 +261,7 @@ void* guac_vnc_client_thread(void* data) { /* Attempt SSH connection */ vnc_client->sftp_session = guac_common_ssh_create_session(client, settings->sftp_hostname, - settings->sftp_port, vnc_client->sftp_user, vnc_client->sftp_keepalive); + settings->sftp_port, vnc_client->sftp_user, settings->sftp_keepalive); /* Fail if SSH connection does not succeed */ if (vnc_client->sftp_session == NULL) { diff --git a/src/protocols/vnc/vnc.h b/src/protocols/vnc/vnc.h index a09f3ed3..0edbcd47 100644 --- a/src/protocols/vnc/vnc.h +++ b/src/protocols/vnc/vnc.h @@ -108,11 +108,6 @@ typedef struct guac_vnc_client { * An SFTP-based filesystem. */ guac_common_ssh_sftp_filesystem* sftp_filesystem; - - /** - * The interval at which to send SSH keepalive messages for SFTP. - */ - int sftp_keepalive; #endif /**