TELNET: Add ability to override detected echo setting.

This commit is contained in:
Nick Couchman 2017-09-09 14:45:11 -04:00
parent 99e6f89eba
commit ef289eaa4a
3 changed files with 27 additions and 2 deletions

View File

@ -39,6 +39,7 @@ const char* GUAC_TELNET_CLIENT_ARGS[] = {
"password-regex", "password-regex",
"font-name", "font-name",
"font-size", "font-size",
"override-echo",
"color-scheme", "color-scheme",
"typescript-path", "typescript-path",
"typescript-name", "typescript-name",
@ -94,6 +95,11 @@ enum TELNET_ARGS_IDX {
*/ */
IDX_FONT_SIZE, IDX_FONT_SIZE,
/**
* Whether or not to override the local telnet echo.
*/
IDX_OVERRIDE_ECHO,
/** /**
* The name of the color scheme to use. Currently valid color schemes are: * The name of the color scheme to use. Currently valid color schemes are:
* "black-white", "white-black", "gray-black", and "green-black", each * "black-white", "white-black", "gray-black", and "green-black", each
@ -239,6 +245,11 @@ guac_telnet_settings* guac_telnet_parse_args(guac_user* user,
guac_user_parse_args_int(user, GUAC_TELNET_CLIENT_ARGS, argv, guac_user_parse_args_int(user, GUAC_TELNET_CLIENT_ARGS, argv,
IDX_FONT_SIZE, GUAC_TELNET_DEFAULT_FONT_SIZE); IDX_FONT_SIZE, GUAC_TELNET_DEFAULT_FONT_SIZE);
/* Read echo override */
settings->override_echo =
guac_user_parse_args_string(user, GUAC_TELNET_CLIENT_ARGS, argv,
IDX_OVERRIDE_ECHO, NULL);
/* Copy requested color scheme */ /* Copy requested color scheme */
settings->color_scheme = settings->color_scheme =
guac_user_parse_args_string(user, GUAC_TELNET_CLIENT_ARGS, argv, guac_user_parse_args_string(user, GUAC_TELNET_CLIENT_ARGS, argv,
@ -314,6 +325,7 @@ void guac_telnet_settings_free(guac_telnet_settings* settings) {
/* Free display preferences */ /* Free display preferences */
free(settings->font_name); free(settings->font_name);
free(settings->color_scheme); free(settings->color_scheme);
free(settings->override_echo);
/* Free typescript settings */ /* Free typescript settings */
free(settings->typescript_name); free(settings->typescript_name);

View File

@ -127,6 +127,11 @@ typedef struct guac_telnet_settings {
*/ */
int font_size; int font_size;
/**
* Override the local echo detection.
*/
char* override_echo;
/** /**
* The name of the color scheme to use. * The name of the color scheme to use.
*/ */

View File

@ -195,13 +195,21 @@ static void __guac_telnet_event_handler(telnet_t* telnet, telnet_event_t* event,
/* Remote feature enabled */ /* Remote feature enabled */
case TELNET_EV_WILL: case TELNET_EV_WILL:
if (event->neg.telopt == TELNET_TELOPT_ECHO) if (settings->override_echo != NULL && strcmp(settings->override_echo, "disabled") == 0)
telnet_client->echo_enabled = 0;
else if (settings->override_echo != NULL && strcmp(settings->override_echo, "enabled") == 0)
telnet_client->echo_enabled = 1;
else if (event->neg.telopt == TELNET_TELOPT_ECHO)
telnet_client->echo_enabled = 0; /* Disable local echo, as remote will echo */ telnet_client->echo_enabled = 0; /* Disable local echo, as remote will echo */
break; break;
/* Remote feature disabled */ /* Remote feature disabled */
case TELNET_EV_WONT: case TELNET_EV_WONT:
if (event->neg.telopt == TELNET_TELOPT_ECHO) if (settings->override_echo != NULL && strcmp(settings->override_echo, "enabled") == 0)
telnet_client->echo_enabled = 1;
else if (settings->override_echo != NULL && strcmp(settings->override_echo, "disabled") == 0)
telnet_client->echo_enabled = 0;
else if (event->neg.telopt == TELNET_TELOPT_ECHO)
telnet_client->echo_enabled = 1; /* Enable local echo, as remote won't echo */ telnet_client->echo_enabled = 1; /* Enable local echo, as remote won't echo */
break; break;