GUACAMOLE-203: Expand SSH keepalives to cover SFTP connections for other protocols.
This commit is contained in:
parent
9993684205
commit
e7fc8a0d98
@ -98,7 +98,7 @@ void guac_common_ssh_uninit();
|
||||
* if the connection or authentication were not successful.
|
||||
*/
|
||||
guac_common_ssh_session* guac_common_ssh_create_session(guac_client* client,
|
||||
const char* hostname, const char* port, guac_common_ssh_user* user);
|
||||
const char* hostname, const char* port, guac_common_ssh_user* user, const int keepalive);
|
||||
|
||||
/**
|
||||
* Disconnects and destroys the given SSH session, freeing all associated
|
||||
|
@ -414,7 +414,7 @@ static int guac_common_ssh_authenticate(guac_common_ssh_session* common_session)
|
||||
}
|
||||
|
||||
guac_common_ssh_session* guac_common_ssh_create_session(guac_client* client,
|
||||
const char* hostname, const char* port, guac_common_ssh_user* user) {
|
||||
const char* hostname, const char* port, guac_common_ssh_user* user, const int keepalive) {
|
||||
|
||||
int retval;
|
||||
|
||||
@ -532,6 +532,10 @@ guac_common_ssh_session* guac_common_ssh_create_session(guac_client* client,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Configure session keepalive */
|
||||
if (keepalive > 0)
|
||||
libssh2_keepalive_config(common_session->session, 1, keepalive);
|
||||
|
||||
/* Return created session */
|
||||
return common_session;
|
||||
|
||||
|
@ -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);
|
||||
settings->sftp_port, rdp_client->sftp_user, rdp_client->sftp_keepalive);
|
||||
|
||||
/* Fail if SSH connection does not succeed */
|
||||
if (rdp_client->sftp_session == NULL) {
|
||||
|
@ -141,6 +141,11 @@ 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
|
||||
|
||||
/**
|
||||
|
@ -218,16 +218,12 @@ void* ssh_client_thread(void* data) {
|
||||
|
||||
/* Open SSH session */
|
||||
ssh_client->session = guac_common_ssh_create_session(client,
|
||||
settings->hostname, settings->port, ssh_client->user);
|
||||
settings->hostname, settings->port, ssh_client->user, settings->server_alive_interval);
|
||||
if (ssh_client->session == NULL) {
|
||||
/* Already aborted within guac_common_ssh_create_session() */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Set keepalive configuration for session */
|
||||
if (settings->server_alive_interval > 0)
|
||||
libssh2_keepalive_config(ssh_client->session->session, 1, settings->server_alive_interval);
|
||||
|
||||
pthread_mutex_init(&ssh_client->term_channel_lock, NULL);
|
||||
|
||||
/* Open channel for terminal */
|
||||
@ -262,7 +258,7 @@ void* ssh_client_thread(void* data) {
|
||||
guac_client_log(client, GUAC_LOG_DEBUG, "Reconnecting for SFTP...");
|
||||
ssh_client->sftp_session =
|
||||
guac_common_ssh_create_session(client, settings->hostname,
|
||||
settings->port, ssh_client->user);
|
||||
settings->port, ssh_client->user, settings->server_alive_interval);
|
||||
if (ssh_client->sftp_session == NULL) {
|
||||
/* Already aborted within guac_common_ssh_create_session() */
|
||||
return NULL;
|
||||
|
@ -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);
|
||||
settings->sftp_port, vnc_client->sftp_user, vnc_client->sftp_keepalive);
|
||||
|
||||
/* Fail if SSH connection does not succeed */
|
||||
if (vnc_client->sftp_session == NULL) {
|
||||
|
@ -108,6 +108,11 @@ 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
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user