GUAC-236: Add session recording parameters to VNC, RDP, and SSH.

This commit is contained in:
Michael Jumper 2016-02-28 23:51:46 -08:00
parent a3fef4c1fc
commit 6fc208554d
9 changed files with 182 additions and 0 deletions

View File

@ -25,6 +25,7 @@
#include "client.h" #include "client.h"
#include "guac_cursor.h" #include "guac_cursor.h"
#include "guac_display.h" #include "guac_display.h"
#include "guac_recording.h"
#include "rdp.h" #include "rdp.h"
#include "rdp_bitmap.h" #include "rdp_bitmap.h"
#include "rdp_cliprdr.h" #include "rdp_cliprdr.h"
@ -699,6 +700,14 @@ void* guac_rdp_client_thread(void* data) {
/* Init random number generator */ /* Init random number generator */
srandom(time(NULL)); srandom(time(NULL));
/* Set up screen recording, if requested */
if (settings->recording_path != NULL) {
guac_common_recording_create(client,
settings->recording_path,
settings->recording_name,
settings->create_recording_path);
}
/* Create display */ /* Create display */
rdp_client->display = guac_common_display_alloc(client, rdp_client->display = guac_common_display_alloc(client,
rdp_client->settings->width, rdp_client->settings->width,

View File

@ -89,6 +89,10 @@ const char* GUAC_RDP_CLIENT_ARGS[] = {
"sftp-directory", "sftp-directory",
#endif #endif
"recording-path",
"recording-name",
"create-recording-path",
NULL NULL
}; };
@ -352,6 +356,10 @@ enum RDP_ARGS_IDX {
#endif #endif
IDX_RECORDING_PATH,
IDX_RECORDING_NAME,
IDX_CREATE_RECORDING_PATH,
RDP_ARGS_COUNT RDP_ARGS_COUNT
}; };
@ -673,6 +681,21 @@ guac_rdp_settings* guac_rdp_parse_args(guac_user* user,
IDX_SFTP_DIRECTORY, NULL); IDX_SFTP_DIRECTORY, NULL);
#endif #endif
/* Read recording path */
settings->recording_path =
guac_user_parse_args_string(user, GUAC_RDP_CLIENT_ARGS, argv,
IDX_RECORDING_PATH, NULL);
/* Read recording name */
settings->recording_name =
guac_user_parse_args_string(user, GUAC_RDP_CLIENT_ARGS, argv,
IDX_RECORDING_NAME, GUAC_RDP_DEFAULT_RECORDING_NAME);
/* Parse path creation flag */
settings->create_recording_path =
guac_user_parse_args_boolean(user, GUAC_RDP_CLIENT_ARGS, argv,
IDX_CREATE_RECORDING_PATH, 0);
/* Success */ /* Success */
return settings; return settings;
@ -688,6 +711,8 @@ void guac_rdp_settings_free(guac_rdp_settings* settings) {
free(settings->initial_program); free(settings->initial_program);
free(settings->password); free(settings->password);
free(settings->preconnection_blob); free(settings->preconnection_blob);
free(settings->recording_name);
free(settings->recording_path);
free(settings->remote_app); free(settings->remote_app);
free(settings->remote_app_args); free(settings->remote_app_args);
free(settings->remote_app_dir); free(settings->remote_app_dir);

View File

@ -56,6 +56,11 @@
*/ */
#define RDP_DEFAULT_DEPTH 16 #define RDP_DEFAULT_DEPTH 16
/**
* The filename to use for the screen recording, if not specified.
*/
#define GUAC_RDP_DEFAULT_RECORDING_NAME "recording"
/** /**
* All supported combinations of security types. * All supported combinations of security types.
*/ */
@ -328,6 +333,23 @@ typedef struct guac_rdp_settings {
char* sftp_directory; char* sftp_directory;
#endif #endif
/**
* The path in which the screen recording should be saved, if enabled. If
* no screen recording should be saved, this will be NULL.
*/
char* recording_path;
/**
* The filename to use for the screen recording, if enabled.
*/
char* recording_name;
/**
* Whether the screen recording path should be automatically created if it
* does not already exist.
*/
int create_recording_path;
} guac_rdp_settings; } guac_rdp_settings;
/** /**

View File

@ -50,6 +50,9 @@ const char* GUAC_SSH_CLIENT_ARGS[] = {
"typescript-path", "typescript-path",
"typescript-name", "typescript-name",
"create-typescript-path", "create-typescript-path",
"recording-path",
"recording-name",
"create-recording-path",
NULL NULL
}; };
@ -140,6 +143,24 @@ enum SSH_ARGS_IDX {
*/ */
IDX_CREATE_TYPESCRIPT_PATH, IDX_CREATE_TYPESCRIPT_PATH,
/**
* The full absolute path to the directory in which screen recordings
* should be written.
*/
IDX_RECORDING_PATH,
/**
* The name that should be given to screen recording which are written in
* the given path.
*/
IDX_RECORDING_NAME,
/**
* Whether the specified screen recording path should automatically be
* created if it does not yet exist.
*/
IDX_CREATE_RECORDING_PATH,
SSH_ARGS_COUNT SSH_ARGS_COUNT
}; };
@ -234,6 +255,21 @@ guac_ssh_settings* guac_ssh_parse_args(guac_user* user,
guac_user_parse_args_boolean(user, GUAC_SSH_CLIENT_ARGS, argv, guac_user_parse_args_boolean(user, GUAC_SSH_CLIENT_ARGS, argv,
IDX_CREATE_TYPESCRIPT_PATH, false); IDX_CREATE_TYPESCRIPT_PATH, false);
/* Read recording path */
settings->recording_path =
guac_user_parse_args_string(user, GUAC_SSH_CLIENT_ARGS, argv,
IDX_RECORDING_PATH, NULL);
/* Read recording name */
settings->recording_name =
guac_user_parse_args_string(user, GUAC_SSH_CLIENT_ARGS, argv,
IDX_RECORDING_NAME, GUAC_SSH_DEFAULT_RECORDING_NAME);
/* Parse path creation flag */
settings->create_recording_path =
guac_user_parse_args_boolean(user, GUAC_SSH_CLIENT_ARGS, argv,
IDX_CREATE_RECORDING_PATH, false);
/* Parsing was successful */ /* Parsing was successful */
return settings; return settings;
@ -262,6 +298,10 @@ void guac_ssh_settings_free(guac_ssh_settings* settings) {
free(settings->typescript_name); free(settings->typescript_name);
free(settings->typescript_path); free(settings->typescript_path);
/* Free screen recording settings */
free(settings->recording_name);
free(settings->recording_path);
/* Free overall structure */ /* Free overall structure */
free(settings); free(settings);

View File

@ -51,6 +51,11 @@
*/ */
#define GUAC_SSH_DEFAULT_TYPESCRIPT_NAME "typescript" #define GUAC_SSH_DEFAULT_TYPESCRIPT_NAME "typescript"
/**
* The filename to use for the screen recording, if not specified.
*/
#define GUAC_SSH_DEFAULT_RECORDING_NAME "recording"
/** /**
* Settings for the SSH connection. The values for this structure are parsed * Settings for the SSH connection. The values for this structure are parsed
* from the arguments given during the Guacamole protocol handshake using the * from the arguments given during the Guacamole protocol handshake using the
@ -157,6 +162,23 @@ typedef struct guac_ssh_settings {
*/ */
bool create_typescript_path; bool create_typescript_path;
/**
* The path in which the screen recording should be saved, if enabled. If
* no screen recording should be saved, this will be NULL.
*/
char* recording_path;
/**
* The filename to use for the screen recording, if enabled.
*/
char* recording_name;
/**
* Whether the screen recording path should be automatically created if it
* does not already exist.
*/
bool create_recording_path;
} guac_ssh_settings; } guac_ssh_settings;
/** /**

View File

@ -22,6 +22,7 @@
#include "config.h" #include "config.h"
#include "guac_recording.h"
#include "guac_sftp.h" #include "guac_sftp.h"
#include "guac_ssh.h" #include "guac_ssh.h"
#include "settings.h" #include "settings.h"
@ -183,6 +184,14 @@ void* ssh_client_thread(void* data) {
if (guac_common_ssh_init(client)) if (guac_common_ssh_init(client))
return NULL; return NULL;
/* Set up screen recording, if requested */
if (settings->recording_path != NULL) {
guac_common_recording_create(client,
settings->recording_path,
settings->recording_name,
settings->create_recording_path);
}
/* Create terminal */ /* Create terminal */
ssh_client->term = guac_terminal_create(client, ssh_client->term = guac_terminal_create(client,
settings->font_name, settings->font_size, settings->font_name, settings->font_size,

View File

@ -71,6 +71,10 @@ const char* GUAC_VNC_CLIENT_ARGS[] = {
"sftp-directory", "sftp-directory",
#endif #endif
"recording-path",
"recording-name",
"create-recording-path",
NULL NULL
}; };
@ -228,6 +232,10 @@ enum VNC_ARGS_IDX {
IDX_SFTP_DIRECTORY, IDX_SFTP_DIRECTORY,
#endif #endif
IDX_RECORDING_PATH,
IDX_RECORDING_NAME,
IDX_CREATE_RECORDING_PATH,
VNC_ARGS_COUNT VNC_ARGS_COUNT
}; };
@ -378,6 +386,20 @@ guac_vnc_settings* guac_vnc_parse_args(guac_user* user,
IDX_SFTP_DIRECTORY, NULL); IDX_SFTP_DIRECTORY, NULL);
#endif #endif
/* Read recording path */
settings->recording_path =
guac_user_parse_args_string(user, GUAC_VNC_CLIENT_ARGS, argv,
IDX_RECORDING_PATH, NULL);
/* Read recording name */
settings->recording_name =
guac_user_parse_args_string(user, GUAC_VNC_CLIENT_ARGS, argv,
IDX_RECORDING_NAME, GUAC_VNC_DEFAULT_RECORDING_NAME);
/* Parse path creation flag */
settings->create_recording_path =
guac_user_parse_args_boolean(user, GUAC_VNC_CLIENT_ARGS, argv,
IDX_CREATE_RECORDING_PATH, false);
return settings; return settings;
@ -389,6 +411,8 @@ void guac_vnc_settings_free(guac_vnc_settings* settings) {
free(settings->clipboard_encoding); free(settings->clipboard_encoding);
free(settings->encodings); free(settings->encodings);
free(settings->hostname); free(settings->hostname);
free(settings->recording_name);
free(settings->recording_path);
#ifdef ENABLE_VNC_REPEATER #ifdef ENABLE_VNC_REPEATER
/* Free VNC repeater settings */ /* Free VNC repeater settings */

View File

@ -28,6 +28,11 @@
#include <stdbool.h> #include <stdbool.h>
/**
* The filename to use for the screen recording, if not specified.
*/
#define GUAC_VNC_DEFAULT_RECORDING_NAME "recording"
/** /**
* VNC-specific client data. * VNC-specific client data.
*/ */
@ -173,6 +178,23 @@ typedef struct guac_vnc_settings {
char* sftp_directory; char* sftp_directory;
#endif #endif
/**
* The path in which the screen recording should be saved, if enabled. If
* no screen recording should be saved, this will be NULL.
*/
char* recording_path;
/**
* The filename to use for the screen recording, if enabled.
*/
char* recording_name;
/**
* Whether the screen recording path should be automatically created if it
* does not already exist.
*/
bool create_recording_path;
} guac_vnc_settings; } guac_vnc_settings;
/** /**

View File

@ -30,6 +30,7 @@
#include "guac_clipboard.h" #include "guac_clipboard.h"
#include "guac_cursor.h" #include "guac_cursor.h"
#include "guac_display.h" #include "guac_display.h"
#include "guac_recording.h"
#include "log.h" #include "log.h"
#include "settings.h" #include "settings.h"
#include "vnc.h" #include "vnc.h"
@ -317,6 +318,14 @@ void* guac_vnc_client_thread(void* data) {
/* Set remaining client data */ /* Set remaining client data */
vnc_client->rfb_client = rfb_client; vnc_client->rfb_client = rfb_client;
/* Set up screen recording, if requested */
if (settings->recording_path != NULL) {
guac_common_recording_create(client,
settings->recording_path,
settings->recording_name,
settings->create_recording_path);
}
/* Send name */ /* Send name */
guac_protocol_send_name(client->socket, rfb_client->desktopName); guac_protocol_send_name(client->socket, rfb_client->desktopName);