GUAC-654: Implement local echo.
This commit is contained in:
parent
b87d99cc40
commit
4a7e5609f5
@ -85,6 +85,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
|
|||||||
client_data->telnet = NULL;
|
client_data->telnet = NULL;
|
||||||
client_data->socket_fd = -1;
|
client_data->socket_fd = -1;
|
||||||
client_data->naws_enabled = 0;
|
client_data->naws_enabled = 0;
|
||||||
|
client_data->echo_enabled = 1;
|
||||||
|
|
||||||
if (argc != TELNET_ARGS_COUNT) {
|
if (argc != TELNET_ARGS_COUNT) {
|
||||||
guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR, "Wrong number of arguments");
|
guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR, "Wrong number of arguments");
|
||||||
|
@ -75,6 +75,12 @@ typedef struct guac_telnet_client_data {
|
|||||||
*/
|
*/
|
||||||
int naws_enabled;
|
int naws_enabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether all user input should be automatically echoed to the
|
||||||
|
* terminal.
|
||||||
|
*/
|
||||||
|
int echo_enabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The terminal which will render all output from the telnet client.
|
* The terminal which will render all output from the telnet client.
|
||||||
*/
|
*/
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
#include <libtelnet.h>
|
#include <libtelnet.h>
|
||||||
|
|
||||||
static const telnet_telopt_t __telnet_options[] = {
|
static const telnet_telopt_t __telnet_options[] = {
|
||||||
{ TELNET_TELOPT_ECHO, TELNET_WONT, TELNET_DONT },
|
{ TELNET_TELOPT_ECHO, TELNET_WONT, TELNET_DO },
|
||||||
{ TELNET_TELOPT_TTYPE, TELNET_WILL, TELNET_DONT },
|
{ TELNET_TELOPT_TTYPE, TELNET_WILL, TELNET_DONT },
|
||||||
{ TELNET_TELOPT_COMPRESS2, TELNET_WONT, TELNET_DO },
|
{ TELNET_TELOPT_COMPRESS2, TELNET_WONT, TELNET_DO },
|
||||||
{ TELNET_TELOPT_MSSP, TELNET_WONT, TELNET_DO },
|
{ TELNET_TELOPT_MSSP, TELNET_WONT, TELNET_DO },
|
||||||
@ -89,7 +89,19 @@ static void __guac_telnet_event_handler(telnet_t* telnet, telnet_event_t* event,
|
|||||||
guac_client_stop(client);
|
guac_client_stop(client);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Feature enable */
|
/* Remote feature enabled */
|
||||||
|
case TELNET_EV_WILL:
|
||||||
|
if (event->neg.telopt == TELNET_TELOPT_ECHO)
|
||||||
|
client_data->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)
|
||||||
|
client_data->echo_enabled = 1; /* Enable local echo, as remote won't echo */
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Local feature enable */
|
||||||
case TELNET_EV_DO:
|
case TELNET_EV_DO:
|
||||||
if (event->neg.telopt == TELNET_TELOPT_NAWS) {
|
if (event->neg.telopt == TELNET_TELOPT_NAWS) {
|
||||||
client_data->naws_enabled = 1;
|
client_data->naws_enabled = 1;
|
||||||
@ -131,8 +143,11 @@ static void* __guac_telnet_input_thread(void* data) {
|
|||||||
int bytes_read;
|
int bytes_read;
|
||||||
|
|
||||||
/* Write all data read */
|
/* Write all data read */
|
||||||
while ((bytes_read = guac_terminal_read_stdin(client_data->term, buffer, sizeof(buffer))) > 0)
|
while ((bytes_read = guac_terminal_read_stdin(client_data->term, buffer, sizeof(buffer))) > 0) {
|
||||||
telnet_send(client_data->telnet, buffer, bytes_read);
|
telnet_send(client_data->telnet, buffer, bytes_read);
|
||||||
|
if (client_data->echo_enabled)
|
||||||
|
guac_terminal_write_stdout(client_data->term, buffer, bytes_read);
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user