GUACAMOLE-313: Provide reference to in-progress screen recording.
This commit is contained in:
parent
db85163e20
commit
b37e73488f
@ -42,6 +42,21 @@
|
|||||||
*/
|
*/
|
||||||
#define GUAC_COMMON_RECORDING_MAX_NAME_LENGTH 2048
|
#define GUAC_COMMON_RECORDING_MAX_NAME_LENGTH 2048
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An in-progress session recording, attached to a guac_client instance such
|
||||||
|
* that output Guacamole instructions may be dynamically intercepted and
|
||||||
|
* written to a file.
|
||||||
|
*/
|
||||||
|
typedef struct guac_common_recording {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The guac_socket which writes directly to the recording file, rather than
|
||||||
|
* to any particular user.
|
||||||
|
*/
|
||||||
|
guac_socket* socket;
|
||||||
|
|
||||||
|
} guac_common_recording;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces the socket of the given client such that all further Guacamole
|
* Replaces the socket of the given client such that all further Guacamole
|
||||||
* protocol output will be copied into a file within the given path and having
|
* protocol output will be copied into a file within the given path and having
|
||||||
@ -68,11 +83,23 @@
|
|||||||
* exist.
|
* exist.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* Zero if the recording file has been successfully created and a recording
|
* A new guac_common_recording structure representing the in-progress
|
||||||
* will be written, non-zero otherwise.
|
* recording if the recording file has been successfully created and a
|
||||||
|
* recording will be written, NULL otherwise.
|
||||||
*/
|
*/
|
||||||
int guac_common_recording_create(guac_client* client, const char* path,
|
guac_common_recording* guac_common_recording_create(guac_client* client,
|
||||||
const char* name, int create_path);
|
const char* path, const char* name, int create_path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Frees the resources associated with the given in-progress recording. Note
|
||||||
|
* that, due to the manner that recordings are attached to the guac_client, the
|
||||||
|
* underlying guac_socket is not freed. The guac_socket will be automatically
|
||||||
|
* freed when the guac_client is freed.
|
||||||
|
*
|
||||||
|
* @param recording
|
||||||
|
* The guac_common_recording to free.
|
||||||
|
*/
|
||||||
|
void guac_common_recording_free(guac_common_recording* recording);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -133,8 +133,8 @@ static int guac_common_recording_open(const char* path,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int guac_common_recording_create(guac_client* client, const char* path,
|
guac_common_recording* guac_common_recording_create(guac_client* client,
|
||||||
const char* name, int create_path) {
|
const char* path, const char* name, int create_path) {
|
||||||
|
|
||||||
char filename[GUAC_COMMON_RECORDING_MAX_NAME_LENGTH];
|
char filename[GUAC_COMMON_RECORDING_MAX_NAME_LENGTH];
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ int guac_common_recording_create(guac_client* client, const char* path,
|
|||||||
#endif
|
#endif
|
||||||
guac_client_log(client, GUAC_LOG_ERROR,
|
guac_client_log(client, GUAC_LOG_ERROR,
|
||||||
"Creation of recording failed: %s", strerror(errno));
|
"Creation of recording failed: %s", strerror(errno));
|
||||||
return 1;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Attempt to open recording file */
|
/* Attempt to open recording file */
|
||||||
@ -154,18 +154,26 @@ int guac_common_recording_create(guac_client* client, const char* path,
|
|||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
guac_client_log(client, GUAC_LOG_ERROR,
|
guac_client_log(client, GUAC_LOG_ERROR,
|
||||||
"Creation of recording failed: %s", strerror(errno));
|
"Creation of recording failed: %s", strerror(errno));
|
||||||
return 1;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Replace client socket with wrapped socket */
|
/* Create recording structure with reference to underlying socket */
|
||||||
client->socket = guac_socket_tee(client->socket, guac_socket_open(fd));
|
guac_common_recording* recording = malloc(sizeof(guac_common_recording));
|
||||||
|
recording->socket = guac_socket_open(fd);
|
||||||
|
|
||||||
|
/* Replace client socket with wrapped recording socket */
|
||||||
|
client->socket = guac_socket_tee(client->socket, recording->socket);
|
||||||
|
|
||||||
/* Recording creation succeeded */
|
/* Recording creation succeeded */
|
||||||
guac_client_log(client, GUAC_LOG_INFO,
|
guac_client_log(client, GUAC_LOG_INFO,
|
||||||
"Recording of session will be saved to \"%s\".",
|
"Recording of session will be saved to \"%s\".",
|
||||||
filename);
|
filename);
|
||||||
|
|
||||||
return 0;
|
return recording;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void guac_common_recording_free(guac_common_recording* recording) {
|
||||||
|
free(recording);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "audio_input.h"
|
#include "audio_input.h"
|
||||||
|
#include "common/recording.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "rdp.h"
|
#include "rdp.h"
|
||||||
#include "rdp_disp.h"
|
#include "rdp_disp.h"
|
||||||
@ -122,6 +123,10 @@ int guac_rdp_client_free_handler(guac_client* client) {
|
|||||||
guac_common_ssh_uninit();
|
guac_common_ssh_uninit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Clean up recording, if in progress */
|
||||||
|
if (rdp_client->recording != NULL)
|
||||||
|
guac_common_recording_free(rdp_client->recording);
|
||||||
|
|
||||||
/* Clean up audio stream, if allocated */
|
/* Clean up audio stream, if allocated */
|
||||||
if (rdp_client->audio != NULL)
|
if (rdp_client->audio != NULL)
|
||||||
guac_audio_stream_free(rdp_client->audio);
|
guac_audio_stream_free(rdp_client->audio);
|
||||||
|
@ -668,7 +668,7 @@ static int guac_rdp_handle_connection(guac_client* client) {
|
|||||||
|
|
||||||
/* Set up screen recording, if requested */
|
/* Set up screen recording, if requested */
|
||||||
if (settings->recording_path != NULL) {
|
if (settings->recording_path != NULL) {
|
||||||
guac_common_recording_create(client,
|
rdp_client->recording = guac_common_recording_create(client,
|
||||||
settings->recording_path,
|
settings->recording_path,
|
||||||
settings->recording_name,
|
settings->recording_name,
|
||||||
settings->create_recording_path);
|
settings->create_recording_path);
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "common/clipboard.h"
|
#include "common/clipboard.h"
|
||||||
#include "common/display.h"
|
#include "common/display.h"
|
||||||
#include "common/list.h"
|
#include "common/list.h"
|
||||||
|
#include "common/recording.h"
|
||||||
#include "common/surface.h"
|
#include "common/surface.h"
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
#include "rdp_disp.h"
|
#include "rdp_disp.h"
|
||||||
@ -143,6 +144,12 @@ typedef struct guac_rdp_client {
|
|||||||
guac_common_ssh_sftp_filesystem* sftp_filesystem;
|
guac_common_ssh_sftp_filesystem* sftp_filesystem;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The in-progress session recording, or NULL if no recording is in
|
||||||
|
* progress.
|
||||||
|
*/
|
||||||
|
guac_common_recording* recording;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display size update module.
|
* Display size update module.
|
||||||
*/
|
*/
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
#include "common/recording.h"
|
||||||
#include "common-ssh/sftp.h"
|
#include "common-ssh/sftp.h"
|
||||||
#include "ssh.h"
|
#include "ssh.h"
|
||||||
#include "terminal/terminal.h"
|
#include "terminal/terminal.h"
|
||||||
@ -88,6 +89,10 @@ int guac_ssh_client_free_handler(guac_client* client) {
|
|||||||
guac_common_ssh_destroy_session(ssh_client->sftp_session);
|
guac_common_ssh_destroy_session(ssh_client->sftp_session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Clean up recording, if in progress */
|
||||||
|
if (ssh_client->recording != NULL)
|
||||||
|
guac_common_recording_free(ssh_client->recording);
|
||||||
|
|
||||||
/* Free interactive SSH session */
|
/* Free interactive SSH session */
|
||||||
if (ssh_client->session != NULL)
|
if (ssh_client->session != NULL)
|
||||||
guac_common_ssh_destroy_session(ssh_client->session);
|
guac_common_ssh_destroy_session(ssh_client->session);
|
||||||
|
@ -193,7 +193,7 @@ void* ssh_client_thread(void* data) {
|
|||||||
|
|
||||||
/* Set up screen recording, if requested */
|
/* Set up screen recording, if requested */
|
||||||
if (settings->recording_path != NULL) {
|
if (settings->recording_path != NULL) {
|
||||||
guac_common_recording_create(client,
|
ssh_client->recording = guac_common_recording_create(client,
|
||||||
settings->recording_path,
|
settings->recording_path,
|
||||||
settings->recording_name,
|
settings->recording_name,
|
||||||
settings->create_recording_path);
|
settings->create_recording_path);
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "common/recording.h"
|
||||||
#include "common-ssh/sftp.h"
|
#include "common-ssh/sftp.h"
|
||||||
#include "common-ssh/ssh.h"
|
#include "common-ssh/ssh.h"
|
||||||
#include "common-ssh/user.h"
|
#include "common-ssh/user.h"
|
||||||
@ -93,6 +94,12 @@ typedef struct guac_ssh_client {
|
|||||||
*/
|
*/
|
||||||
guac_terminal* term;
|
guac_terminal* term;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The in-progress session recording, or NULL if no recording is in
|
||||||
|
* progress.
|
||||||
|
*/
|
||||||
|
guac_common_recording* recording;
|
||||||
|
|
||||||
} guac_ssh_client ;
|
} guac_ssh_client ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
#include "common/recording.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "telnet.h"
|
#include "telnet.h"
|
||||||
#include "terminal/terminal.h"
|
#include "terminal/terminal.h"
|
||||||
@ -71,6 +72,10 @@ int guac_telnet_client_free_handler(guac_client* client) {
|
|||||||
if (telnet_client->socket_fd != -1)
|
if (telnet_client->socket_fd != -1)
|
||||||
close(telnet_client->socket_fd);
|
close(telnet_client->socket_fd);
|
||||||
|
|
||||||
|
/* Clean up recording, if in progress */
|
||||||
|
if (telnet_client->recording != NULL)
|
||||||
|
guac_common_recording_free(telnet_client->recording);
|
||||||
|
|
||||||
/* Kill terminal */
|
/* Kill terminal */
|
||||||
guac_terminal_free(telnet_client->term);
|
guac_terminal_free(telnet_client->term);
|
||||||
|
|
||||||
|
@ -467,7 +467,7 @@ void* guac_telnet_client_thread(void* data) {
|
|||||||
|
|
||||||
/* Set up screen recording, if requested */
|
/* Set up screen recording, if requested */
|
||||||
if (settings->recording_path != NULL) {
|
if (settings->recording_path != NULL) {
|
||||||
guac_common_recording_create(client,
|
telnet_client->recording = guac_common_recording_create(client,
|
||||||
settings->recording_path,
|
settings->recording_path,
|
||||||
settings->recording_name,
|
settings->recording_name,
|
||||||
settings->create_recording_path);
|
settings->create_recording_path);
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#define GUAC_TELNET_H
|
#define GUAC_TELNET_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "common/recording.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "terminal/terminal.h"
|
#include "terminal/terminal.h"
|
||||||
|
|
||||||
@ -69,7 +70,13 @@ typedef struct guac_telnet_client {
|
|||||||
* The terminal which will render all output from the telnet client.
|
* The terminal which will render all output from the telnet client.
|
||||||
*/
|
*/
|
||||||
guac_terminal* term;
|
guac_terminal* term;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The in-progress session recording, or NULL if no recording is in
|
||||||
|
* progress.
|
||||||
|
*/
|
||||||
|
guac_common_recording* recording;
|
||||||
|
|
||||||
} guac_telnet_client;
|
} guac_telnet_client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "common/recording.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "user.h"
|
#include "user.h"
|
||||||
#include "vnc.h"
|
#include "vnc.h"
|
||||||
@ -102,6 +103,10 @@ int guac_vnc_client_free_handler(guac_client* client) {
|
|||||||
guac_common_ssh_uninit();
|
guac_common_ssh_uninit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Clean up recording, if in progress */
|
||||||
|
if (vnc_client->recording != NULL)
|
||||||
|
guac_common_recording_free(vnc_client->recording);
|
||||||
|
|
||||||
/* Free clipboard */
|
/* Free clipboard */
|
||||||
if (vnc_client->clipboard != NULL)
|
if (vnc_client->clipboard != NULL)
|
||||||
guac_common_clipboard_free(vnc_client->clipboard);
|
guac_common_clipboard_free(vnc_client->clipboard);
|
||||||
|
@ -303,7 +303,7 @@ void* guac_vnc_client_thread(void* data) {
|
|||||||
|
|
||||||
/* Set up screen recording, if requested */
|
/* Set up screen recording, if requested */
|
||||||
if (settings->recording_path != NULL) {
|
if (settings->recording_path != NULL) {
|
||||||
guac_common_recording_create(client,
|
vnc_client->recording = guac_common_recording_create(client,
|
||||||
settings->recording_path,
|
settings->recording_path,
|
||||||
settings->recording_name,
|
settings->recording_name,
|
||||||
settings->create_recording_path);
|
settings->create_recording_path);
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "common/clipboard.h"
|
#include "common/clipboard.h"
|
||||||
#include "common/display.h"
|
#include "common/display.h"
|
||||||
#include "common/iconv.h"
|
#include "common/iconv.h"
|
||||||
|
#include "common/recording.h"
|
||||||
#include "common/surface.h"
|
#include "common/surface.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
@ -110,6 +111,12 @@ typedef struct guac_vnc_client {
|
|||||||
guac_common_ssh_sftp_filesystem* sftp_filesystem;
|
guac_common_ssh_sftp_filesystem* sftp_filesystem;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The in-progress session recording, or NULL if no recording is in
|
||||||
|
* progress.
|
||||||
|
*/
|
||||||
|
guac_common_recording* recording;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clipboard encoding-specific reader.
|
* Clipboard encoding-specific reader.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user