From 02a72917429296978a5570b453040dd7a17012e7 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 15 Apr 2020 09:42:22 -0400 Subject: [PATCH] GUACAMOLE-513: Adjust names of constants and fix style. --- src/libguac/Makefile.am | 4 ++-- src/libguac/guacamole/wol-constants.h | 12 +++++------ src/protocols/rdp/settings.c | 4 ++-- src/protocols/ssh/settings.c | 4 ++-- src/protocols/telnet/settings.c | 4 ++-- src/protocols/vnc/settings.c | 31 +++++++++++++++++++++++++++ 6 files changed, 44 insertions(+), 15 deletions(-) diff --git a/src/libguac/Makefile.am b/src/libguac/Makefile.am index 68d80278..ad7d7c9d 100644 --- a/src/libguac/Makefile.am +++ b/src/libguac/Makefile.am @@ -69,8 +69,8 @@ libguacinc_HEADERS = \ guacamole/user.h \ guacamole/user-constants.h \ guacamole/user-fntypes.h \ - guacamole/user-types.h \ - guacamole/wol.h \ + guacamole/user-types.h \ + guacamole/wol.h \ guacamole/wol-constants.h noinst_HEADERS = \ diff --git a/src/libguac/guacamole/wol-constants.h b/src/libguac/guacamole/wol-constants.h index 8e5fb4e4..6f27dd07 100644 --- a/src/libguac/guacamole/wol-constants.h +++ b/src/libguac/guacamole/wol-constants.h @@ -28,17 +28,15 @@ */ /** - * The default broadcast address to which Wake-on-LAN packets will be sent - * if one is not specified, which is the special value for the IPv4 local - * network broadcast. + * The value for the local IPv4 broadcast address. */ -#define GUAC_WOL_DEFAULT_BROADCAST "255.255.255.255" +#define GUAC_WOL_LOCAL_IPV4_BROADCAST "255.255.255.255" /** - * The default number of seconds to wait after sending the Wake-on-LAN packet + * The number of seconds to wait after sending the Wake-on-LAN packet * for the destination host to start responding. */ -#define GUAC_WOL_DEFAULT_WAIT_TIME 60 +#define GUAC_WOL_BOOT_WAIT_TIME 60 /** * The size of the magic Wake-on-LAN packet to send to wake a remote host. This @@ -50,7 +48,7 @@ /** * The port number that the magic packet should contain as the destination. In * reality this doesn't matter all that much, since the packet is not usually - * processed by a full IP stack, but it is considered a pretty standard + * processed by a full IP stack, but defining one is considered a standard * practice. */ #define GUAC_WOL_PORT 9 diff --git a/src/protocols/rdp/settings.c b/src/protocols/rdp/settings.c index 3c692556..7c4b23cb 100644 --- a/src/protocols/rdp/settings.c +++ b/src/protocols/rdp/settings.c @@ -1079,12 +1079,12 @@ guac_rdp_settings* guac_rdp_parse_args(guac_user* user, /* Parse the WoL broadcast address. */ settings->wol_broadcast_addr = guac_user_parse_args_string(user, GUAC_RDP_CLIENT_ARGS, argv, - IDX_WOL_BROADCAST_ADDR, GUAC_WOL_DEFAULT_BROADCAST); + IDX_WOL_BROADCAST_ADDR, GUAC_WOL_LOCAL_IPV4_BROADCAST); /* Parse the WoL wait time. */ settings->wol_wait_time = guac_user_parse_args_int(user, GUAC_RDP_CLIENT_ARGS, argv, - IDX_WOL_WAIT_TIME, GUAC_WOL_DEFAULT_WAIT_TIME); + IDX_WOL_WAIT_TIME, GUAC_WOL_BOOT_WAIT_TIME); } diff --git a/src/protocols/ssh/settings.c b/src/protocols/ssh/settings.c index 679545f8..c76feaeb 100644 --- a/src/protocols/ssh/settings.c +++ b/src/protocols/ssh/settings.c @@ -504,11 +504,11 @@ guac_ssh_settings* guac_ssh_parse_args(guac_user* user, settings->wol_broadcast_addr = guac_user_parse_args_string(user, GUAC_SSH_CLIENT_ARGS, argv, - IDX_WOL_BROADCAST_ADDR, GUAC_WOL_DEFAULT_BROADCAST); + IDX_WOL_BROADCAST_ADDR, GUAC_WOL_LOCAL_IPV4_BROADCAST); settings->wol_wait_time = guac_user_parse_args_int(user, GUAC_SSH_CLIENT_ARGS, argv, - IDX_WOL_WAIT_TIME, GUAC_WOL_DEFAULT_WAIT_TIME); + IDX_WOL_WAIT_TIME, GUAC_WOL_BOOT_WAIT_TIME); } diff --git a/src/protocols/telnet/settings.c b/src/protocols/telnet/settings.c index 2fca8fed..63f68d17 100644 --- a/src/protocols/telnet/settings.c +++ b/src/protocols/telnet/settings.c @@ -506,12 +506,12 @@ guac_telnet_settings* guac_telnet_parse_args(guac_user* user, /* Parse the WoL broadcast address. */ settings->wol_broadcast_addr = guac_user_parse_args_string(user, GUAC_TELNET_CLIENT_ARGS, argv, - IDX_WOL_BROADCAST_ADDR, GUAC_WOL_DEFAULT_BROADCAST); + IDX_WOL_BROADCAST_ADDR, GUAC_WOL_LOCAL_IPV4_BROADCAST); /* Parse the WoL wait time. */ settings->wol_wait_time = guac_user_parse_args_int(user, GUAC_TELNET_CLIENT_ARGS, argv, - IDX_WOL_WAIT_TIME, GUAC_WOL_DEFAULT_WAIT_TIME); + IDX_WOL_WAIT_TIME, GUAC_WOL_BOOT_WAIT_TIME); } diff --git a/src/protocols/vnc/settings.c b/src/protocols/vnc/settings.c index 2ac33b9f..847f6733 100644 --- a/src/protocols/vnc/settings.c +++ b/src/protocols/vnc/settings.c @@ -558,6 +558,37 @@ guac_vnc_settings* guac_vnc_parse_args(guac_user* user, settings->disable_paste = guac_user_parse_args_boolean(user, GUAC_VNC_CLIENT_ARGS, argv, IDX_DISABLE_PASTE, false); + + /* Parse Wake-on-LAN (WoL) settings */ + settings->wol_send_packet = + guac_user_parse_args_boolean(user, GUAC_VNC_CLIENT_ARGS, argv, + IDX_WOL_SEND_PACKET, false); + + if (settings->wol_send_packet) { + + /* If WoL has been enabled but no MAC provided, log warning and disable. */ + if(strcmp(argv[IDX_WOL_MAC_ADDR], "") == 0) { + guac_user_log(user, GUAC_LOG_WARNING, "Wake on LAN was requested, ", + "but no MAC address was specified. WoL will not be sent."); + settings->wol_send_packet = false; + } + + /* Parse the WoL MAC address. */ + settings->wol_mac_addr = + guac_user_parse_args_string(user, GUAC_VNC_CLIENT_ARGS, argv, + IDX_WOL_MAC_ADDR, NULL); + + /* Parse the WoL broadcast address. */ + settings->wol_broadcast_addr = + guac_user_parse_args_string(user, GUAC_VNC_CLIENT_ARGS, argv, + IDX_WOL_BROADCAST_ADDR, GUAC_WOL_LOCAL_IPV4_BROADCAST); + + /* Parse the WoL wait time. */ + settings->wol_wait_time = + guac_user_parse_args_int(user, GUAC_VNC_CLIENT_ARGS, argv, + IDX_WOL_WAIT_TIME, GUAC_WOL_BOOT_WAIT_TIME); + + } return settings;