GUACAMOLE-630: Automatically send current color scheme and font to users joining SSH, telnet, and Kubernetes connections.

This commit is contained in:
Michael Jumper 2019-08-04 12:52:00 -07:00
parent ccfcfb116d
commit f56df8b8be
12 changed files with 149 additions and 0 deletions

View File

@ -199,3 +199,26 @@ int guac_kubernetes_argv_handler(guac_user* user, guac_stream* stream,
}
void* guac_kubernetes_send_current_argv(guac_user* user, void* data) {
guac_kubernetes_client* kubernetes_client = (guac_kubernetes_client*) data;
guac_terminal* terminal = kubernetes_client->term;
/* Send current color scheme */
guac_user_stream_argv(user, user->socket, "text/plain", "color-scheme",
terminal->color_scheme);
/* Send current font name */
guac_user_stream_argv(user, user->socket, "text/plain", "font-name",
terminal->font_name);
/* Send current font size */
char font_size[64];
sprintf(font_size, "%i", terminal->font_size);
guac_user_stream_argv(user, user->socket, "text/plain", "font-size",
font_size);
return NULL;
}

View File

@ -37,5 +37,26 @@
*/
guac_user_argv_handler guac_kubernetes_argv_handler;
/**
* Sends the current values of all non-sensitive parameters which may be set
* while the connection is running to the given user. Note that the user
* receiving these values will not necessarily be able to set new values
* themselves if their connection is read-only. This function is provided for
* convenience, as it is can be used as the callback for
* guac_client_foreach_user() or guac_client_for_owner().
*
* @param user
* The user that should receive the values of all non-sensitive parameters
* which may be set while the connection is running.
*
* @param data
* The guac_kubernetes_client instance associated with the current
* connection.
*
* @return
* Always NULL.
*/
void* guac_kubernetes_send_current_argv(guac_user* user, void* data);
#endif

View File

@ -18,6 +18,8 @@
*/
#include "config.h"
#include "argv.h"
#include "client.h"
#include "common/recording.h"
#include "io.h"
@ -249,6 +251,10 @@ void* guac_kubernetes_client_thread(void* data) {
goto fail;
}
/* Send current values of exposed arguments to owner only */
guac_client_for_owner(client, guac_kubernetes_send_current_argv,
kubernetes_client);
/* Set up typescript, if requested */
if (settings->typescript_path != NULL) {
guac_terminal_create_typescript(kubernetes_client->term,

View File

@ -74,6 +74,7 @@ int guac_kubernetes_user_join_handler(guac_user* user, int argc, char** argv) {
/* If not owner, synchronize with current display */
else {
guac_terminal_dup(kubernetes_client->term, user, user->socket);
guac_kubernetes_send_current_argv(user, kubernetes_client);
guac_socket_flush(user->socket);
}

View File

@ -204,3 +204,26 @@ int guac_ssh_argv_handler(guac_user* user, guac_stream* stream,
}
void* guac_ssh_send_current_argv(guac_user* user, void* data) {
guac_ssh_client* ssh_client = (guac_ssh_client*) data;
guac_terminal* terminal = ssh_client->term;
/* Send current color scheme */
guac_user_stream_argv(user, user->socket, "text/plain", "color-scheme",
terminal->color_scheme);
/* Send current font name */
guac_user_stream_argv(user, user->socket, "text/plain", "font-name",
terminal->font_name);
/* Send current font size */
char font_size[64];
sprintf(font_size, "%i", terminal->font_size);
guac_user_stream_argv(user, user->socket, "text/plain", "font-size",
font_size);
return NULL;
}

View File

@ -37,5 +37,25 @@
*/
guac_user_argv_handler guac_ssh_argv_handler;
/**
* Sends the current values of all non-sensitive parameters which may be set
* while the connection is running to the given user. Note that the user
* receiving these values will not necessarily be able to set new values
* themselves if their connection is read-only. This function is provided for
* convenience, as it is can be used as the callback for
* guac_client_foreach_user() or guac_client_for_owner().
*
* @param user
* The user that should receive the values of all non-sensitive parameters
* which may be set while the connection is running.
*
* @param data
* The guac_ssh_client instance associated with the current connection.
*
* @return
* Always NULL.
*/
void* guac_ssh_send_current_argv(guac_user* user, void* data);
#endif

View File

@ -19,6 +19,7 @@
#include "config.h"
#include "argv.h"
#include "common/recording.h"
#include "common-ssh/sftp.h"
#include "common-ssh/ssh.h"
@ -233,6 +234,9 @@ void* ssh_client_thread(void* data) {
return NULL;
}
/* Send current values of exposed arguments to owner only */
guac_client_for_owner(client, guac_ssh_send_current_argv, ssh_client);
/* Set up typescript, if requested */
if (settings->typescript_path != NULL) {
guac_terminal_create_typescript(ssh_client->term,

View File

@ -74,6 +74,7 @@ int guac_ssh_user_join_handler(guac_user* user, int argc, char** argv) {
/* If not owner, synchronize with current display */
else {
guac_terminal_dup(ssh_client->term, user, user->socket);
guac_ssh_send_current_argv(user, ssh_client);
guac_socket_flush(user->socket);
}

View File

@ -200,3 +200,26 @@ int guac_telnet_argv_handler(guac_user* user, guac_stream* stream,
}
void* guac_telnet_send_current_argv(guac_user* user, void* data) {
guac_telnet_client* telnet_client = (guac_telnet_client*) data;
guac_terminal* terminal = telnet_client->term;
/* Send current color scheme */
guac_user_stream_argv(user, user->socket, "text/plain", "color-scheme",
terminal->color_scheme);
/* Send current font name */
guac_user_stream_argv(user, user->socket, "text/plain", "font-name",
terminal->font_name);
/* Send current font size */
char font_size[64];
sprintf(font_size, "%i", terminal->font_size);
guac_user_stream_argv(user, user->socket, "text/plain", "font-size",
font_size);
return NULL;
}

View File

@ -37,5 +37,25 @@
*/
guac_user_argv_handler guac_telnet_argv_handler;
/**
* Sends the current values of all non-sensitive parameters which may be set
* while the connection is running to the given user. Note that the user
* receiving these values will not necessarily be able to set new values
* themselves if their connection is read-only. This function is provided for
* convenience, as it is can be used as the callback for
* guac_client_foreach_user() or guac_client_for_owner().
*
* @param user
* The user that should receive the values of all non-sensitive parameters
* which may be set while the connection is running.
*
* @param data
* The guac_telnet_client instance associated with the current connection.
*
* @return
* Always NULL.
*/
void* guac_telnet_send_current_argv(guac_user* user, void* data);
#endif

View File

@ -18,6 +18,8 @@
*/
#include "config.h"
#include "argv.h"
#include "common/recording.h"
#include "telnet.h"
#include "terminal/terminal.h"
@ -580,6 +582,10 @@ void* guac_telnet_client_thread(void* data) {
return NULL;
}
/* Send current values of exposed arguments to owner only */
guac_client_for_owner(client, guac_telnet_send_current_argv,
telnet_client);
/* Set up typescript, if requested */
if (settings->typescript_path != NULL) {
guac_terminal_create_typescript(telnet_client->term,

View File

@ -73,6 +73,7 @@ int guac_telnet_user_join_handler(guac_user* user, int argc, char** argv) {
/* If not owner, synchronize with current display */
else {
guac_terminal_dup(telnet_client->term, user, user->socket);
guac_telnet_send_current_argv(user, telnet_client);
guac_socket_flush(user->socket);
}