GUACAMOLE-513: Adjust names of constants and fix style.

This commit is contained in:
Nick Couchman 2020-04-15 09:42:22 -04:00
parent a0d4bacbc6
commit 02a7291742
6 changed files with 44 additions and 15 deletions

View File

@ -69,8 +69,8 @@ libguacinc_HEADERS = \
guacamole/user.h \ guacamole/user.h \
guacamole/user-constants.h \ guacamole/user-constants.h \
guacamole/user-fntypes.h \ guacamole/user-fntypes.h \
guacamole/user-types.h \ guacamole/user-types.h \
guacamole/wol.h \ guacamole/wol.h \
guacamole/wol-constants.h guacamole/wol-constants.h
noinst_HEADERS = \ noinst_HEADERS = \

View File

@ -28,17 +28,15 @@
*/ */
/** /**
* The default broadcast address to which Wake-on-LAN packets will be sent * The value for the local IPv4 broadcast address.
* if one is not specified, which is the special value for the IPv4 local
* network broadcast.
*/ */
#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. * 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 * 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 * 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 * 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. * practice.
*/ */
#define GUAC_WOL_PORT 9 #define GUAC_WOL_PORT 9

View File

@ -1079,12 +1079,12 @@ guac_rdp_settings* guac_rdp_parse_args(guac_user* user,
/* Parse the WoL broadcast address. */ /* Parse the WoL broadcast address. */
settings->wol_broadcast_addr = settings->wol_broadcast_addr =
guac_user_parse_args_string(user, GUAC_RDP_CLIENT_ARGS, argv, 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. */ /* Parse the WoL wait time. */
settings->wol_wait_time = settings->wol_wait_time =
guac_user_parse_args_int(user, GUAC_RDP_CLIENT_ARGS, argv, 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);
} }

View File

@ -504,11 +504,11 @@ guac_ssh_settings* guac_ssh_parse_args(guac_user* user,
settings->wol_broadcast_addr = settings->wol_broadcast_addr =
guac_user_parse_args_string(user, GUAC_SSH_CLIENT_ARGS, argv, 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 = settings->wol_wait_time =
guac_user_parse_args_int(user, GUAC_SSH_CLIENT_ARGS, argv, 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);
} }

View File

@ -506,12 +506,12 @@ guac_telnet_settings* guac_telnet_parse_args(guac_user* user,
/* Parse the WoL broadcast address. */ /* Parse the WoL broadcast address. */
settings->wol_broadcast_addr = settings->wol_broadcast_addr =
guac_user_parse_args_string(user, GUAC_TELNET_CLIENT_ARGS, argv, 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. */ /* Parse the WoL wait time. */
settings->wol_wait_time = settings->wol_wait_time =
guac_user_parse_args_int(user, GUAC_TELNET_CLIENT_ARGS, argv, 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);
} }

View File

@ -559,6 +559,37 @@ guac_vnc_settings* guac_vnc_parse_args(guac_user* user,
guac_user_parse_args_boolean(user, GUAC_VNC_CLIENT_ARGS, argv, guac_user_parse_args_boolean(user, GUAC_VNC_CLIENT_ARGS, argv,
IDX_DISABLE_PASTE, false); 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; return settings;
} }