GUACAMOLE-600: Add support for setting the VNC connection timeout.

This commit is contained in:
Virtually Nick 2023-02-16 17:48:20 -05:00
parent 47b9360d46
commit 520dd5ede3
3 changed files with 22 additions and 1 deletions

View File

@ -36,6 +36,7 @@
const char* GUAC_VNC_CLIENT_ARGS[] = { const char* GUAC_VNC_CLIENT_ARGS[] = {
"hostname", "hostname",
"port", "port",
"timeout",
"read-only", "read-only",
"encodings", "encodings",
GUAC_VNC_ARGV_USERNAME, GUAC_VNC_ARGV_USERNAME,
@ -108,6 +109,11 @@ enum VNC_ARGS_IDX {
*/ */
IDX_PORT, IDX_PORT,
/**
* The number of seconds to wait for the connection before timing out.
*/
IDX_TIMEOUT,
/** /**
* "true" if this connection should be read-only (user input should be * "true" if this connection should be read-only (user input should be
* dropped), "false" or blank otherwise. * dropped), "false" or blank otherwise.
@ -405,6 +411,10 @@ guac_vnc_settings* guac_vnc_parse_args(guac_user* user,
guac_user_parse_args_int(user, GUAC_VNC_CLIENT_ARGS, argv, guac_user_parse_args_int(user, GUAC_VNC_CLIENT_ARGS, argv,
IDX_PORT, 0); IDX_PORT, 0);
settings->timeout =
guac_user_parse_args_int(user, GUAC_VNC_CLIENT_ARGS, argv,
IDX_TIMEOUT, GUAC_VNC_DEFAULT_CONNECTION_TIMEOUT);
settings->username = settings->username =
guac_user_parse_args_string(user, GUAC_VNC_CLIENT_ARGS, argv, guac_user_parse_args_string(user, GUAC_VNC_CLIENT_ARGS, argv,
IDX_USERNAME, NULL); IDX_USERNAME, NULL);

View File

@ -25,6 +25,11 @@
#include <stdbool.h> #include <stdbool.h>
/**
* The default number of seconds to wait for a connection before timing out.
*/
#define GUAC_VNC_DEFAULT_CONNECTION_TIMEOUT 10
/** /**
* The filename to use for the screen recording, if not specified. * The filename to use for the screen recording, if not specified.
*/ */
@ -45,6 +50,11 @@ typedef struct guac_vnc_settings {
*/ */
int port; int port;
/**
* The number of seconds to wait for the connection before timing out.
*/
int timeout;
/** /**
* The username given in the arguments. * The username given in the arguments.
*/ */

View File

@ -201,9 +201,10 @@ rfbClient* guac_vnc_get_client(guac_client* client) {
rfb_client->MallocFrameBuffer = guac_vnc_malloc_framebuffer; rfb_client->MallocFrameBuffer = guac_vnc_malloc_framebuffer;
rfb_client->canHandleNewFBSize = 1; rfb_client->canHandleNewFBSize = 1;
/* Set hostname and port */ /* Set hostname, port, and timeout */
rfb_client->serverHost = strdup(vnc_settings->hostname); rfb_client->serverHost = strdup(vnc_settings->hostname);
rfb_client->serverPort = vnc_settings->port; rfb_client->serverPort = vnc_settings->port;
rfb_client->connectTimeout = vnc_settings->timeout;
#ifdef ENABLE_VNC_REPEATER #ifdef ENABLE_VNC_REPEATER
/* Set repeater parameters if specified */ /* Set repeater parameters if specified */