Compare commits

...

1 Commits

Author SHA1 Message Date
Nick Couchman
ef289eaa4a TELNET: Add ability to override detected echo setting. 2017-09-09 14:45:11 -04:00
3 changed files with 27 additions and 2 deletions

View File

@ -39,6 +39,7 @@ const char* GUAC_TELNET_CLIENT_ARGS[] = {
"password-regex",
"font-name",
"font-size",
"override-echo",
"color-scheme",
"typescript-path",
"typescript-name",
@ -94,6 +95,11 @@ enum TELNET_ARGS_IDX {
*/
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:
* "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,
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 */
settings->color_scheme =
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(settings->font_name);
free(settings->color_scheme);
free(settings->override_echo);
/* Free typescript settings */
free(settings->typescript_name);

View File

@ -127,6 +127,11 @@ typedef struct guac_telnet_settings {
*/
int font_size;
/**
* Override the local echo detection.
*/
char* override_echo;
/**
* 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 */
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 */
break;
/* Remote feature disabled */
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 */
break;