GUACAMOLE-1686: Switch WOL in each of the protocols to use new wake_and_wait function.
This commit is contained in:
parent
69a616ceca
commit
e214ad4c29
@ -76,6 +76,7 @@
|
||||
#include <guacamole/socket.h>
|
||||
#include <guacamole/string.h>
|
||||
#include <guacamole/timestamp.h>
|
||||
#include <guacamole/wol-constants.h>
|
||||
#include <guacamole/wol.h>
|
||||
#include <winpr/error.h>
|
||||
#include <winpr/synch.h>
|
||||
@ -698,19 +699,49 @@ void* guac_rdp_client_thread(void* data) {
|
||||
guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
|
||||
guac_rdp_settings* settings = rdp_client->settings;
|
||||
|
||||
/* If Wake-on-LAN is enabled, try to wake. */
|
||||
/* If Wake-on-LAN is enabled, attempt to wake. */
|
||||
if (settings->wol_send_packet) {
|
||||
guac_client_log(client, GUAC_LOG_DEBUG, "Sending Wake-on-LAN packet, "
|
||||
"and pausing for %d seconds.", settings->wol_wait_time);
|
||||
|
||||
/* Send the Wake-on-LAN request. */
|
||||
if (guac_wol_wake(settings->wol_mac_addr, settings->wol_broadcast_addr,
|
||||
settings->wol_udp_port))
|
||||
|
||||
/**
|
||||
* If wait time is set, send the wake packet and try to connect to the
|
||||
* server, failing if the server does not respond.
|
||||
*/
|
||||
if (settings->wol_wait_time > 0) {
|
||||
guac_client_log(client, GUAC_LOG_DEBUG, "Sending Wake-on-LAN packet, "
|
||||
"and pausing for %d seconds.", settings->wol_wait_time);
|
||||
|
||||
/* char representation of a port should be, at most, 5 digits plus terminator. */
|
||||
char* str_port = guac_mem_alloc(6);
|
||||
if (guac_itoa(str_port, settings->port) < 1) {
|
||||
guac_client_log(client, GUAC_LOG_ERROR, "Failed to convert port to integer for WOL function.");
|
||||
guac_mem_free(str_port);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Send the Wake-on-LAN request and wait until the server is responsive. */
|
||||
if (guac_wol_wake_and_wait(settings->wol_mac_addr,
|
||||
settings->wol_broadcast_addr,
|
||||
settings->wol_udp_port,
|
||||
settings->wol_wait_time,
|
||||
GUAC_WOL_DEFAULT_CONNECT_RETRIES,
|
||||
settings->hostname,
|
||||
(const char *) str_port)) {
|
||||
guac_client_log(client, GUAC_LOG_ERROR, "Failed to send WOL packet, or server failed to wake up.");
|
||||
guac_mem_free(str_port);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
guac_mem_free(str_port);
|
||||
|
||||
}
|
||||
|
||||
/* Just send the packet and continue the connection, or return if failed. */
|
||||
else if(guac_wol_wake(settings->wol_mac_addr,
|
||||
settings->wol_broadcast_addr,
|
||||
settings->wol_udp_port)) {
|
||||
guac_client_log(client, GUAC_LOG_ERROR, "Failed to send WOL packet.");
|
||||
return NULL;
|
||||
|
||||
/* If wait time is specified, sleep for that amount of time. */
|
||||
if (settings->wol_wait_time > 0)
|
||||
guac_timestamp_msleep(settings->wol_wait_time * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
/* If audio enabled, choose an encoder */
|
||||
|
||||
@ -39,6 +39,7 @@
|
||||
#include <guacamole/recording.h>
|
||||
#include <guacamole/socket.h>
|
||||
#include <guacamole/timestamp.h>
|
||||
#include <guacamole/wol-constants.h>
|
||||
#include <guacamole/wol.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/ssl.h>
|
||||
@ -233,17 +234,35 @@ void* ssh_client_thread(void* data) {
|
||||
|
||||
/* If Wake-on-LAN is enabled, attempt to wake. */
|
||||
if (settings->wol_send_packet) {
|
||||
guac_client_log(client, GUAC_LOG_DEBUG, "Sending Wake-on-LAN packet, "
|
||||
"and pausing for %d seconds.", settings->wol_wait_time);
|
||||
|
||||
/* Send the Wake-on-LAN request. */
|
||||
if (guac_wol_wake(settings->wol_mac_addr, settings->wol_broadcast_addr,
|
||||
settings->wol_udp_port))
|
||||
/**
|
||||
* If wait time is set, send the wake packet and try to connect to the
|
||||
* server, failing if the server does not respond.
|
||||
*/
|
||||
if (settings->wol_wait_time > 0) {
|
||||
guac_client_log(client, GUAC_LOG_DEBUG, "Sending Wake-on-LAN packet, "
|
||||
"and pausing for %d seconds.", settings->wol_wait_time);
|
||||
|
||||
/* Send the Wake-on-LAN request and wait until the server is responsive. */
|
||||
if (guac_wol_wake_and_wait(settings->wol_mac_addr,
|
||||
settings->wol_broadcast_addr,
|
||||
settings->wol_udp_port,
|
||||
settings->wol_wait_time,
|
||||
GUAC_WOL_DEFAULT_CONNECT_RETRIES,
|
||||
settings->hostname,
|
||||
settings->port)) {
|
||||
guac_client_log(client, GUAC_LOG_ERROR, "Failed to send WOL packet or connect to remote server.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Just send the packet and continue the connection, or return if failed. */
|
||||
else if(guac_wol_wake(settings->wol_mac_addr,
|
||||
settings->wol_broadcast_addr,
|
||||
settings->wol_udp_port)) {
|
||||
guac_client_log(client, GUAC_LOG_ERROR, "Failed to send WOL packet.");
|
||||
return NULL;
|
||||
|
||||
/* If wait time is specified, sleep for that amount of time. */
|
||||
if (settings->wol_wait_time > 0)
|
||||
guac_timestamp_msleep(settings->wol_wait_time * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
/* Init SSH base libraries */
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
#include <guacamole/recording.h>
|
||||
#include <guacamole/socket-tcp.h>
|
||||
#include <guacamole/timestamp.h>
|
||||
#include <guacamole/wol-constants.h>
|
||||
#include <guacamole/wol.h>
|
||||
#include <libtelnet.h>
|
||||
|
||||
@ -494,17 +495,35 @@ void* guac_telnet_client_thread(void* data) {
|
||||
|
||||
/* If Wake-on-LAN is enabled, attempt to wake. */
|
||||
if (settings->wol_send_packet) {
|
||||
guac_client_log(client, GUAC_LOG_DEBUG, "Sending Wake-on-LAN packet, "
|
||||
"and pausing for %d seconds.", settings->wol_wait_time);
|
||||
|
||||
/* Send the Wake-on-LAN request. */
|
||||
if (guac_wol_wake(settings->wol_mac_addr, settings->wol_broadcast_addr,
|
||||
settings->wol_udp_port))
|
||||
/**
|
||||
* If wait time is set, send the wake packet and try to connect to the
|
||||
* server, failing if the server does not respond.
|
||||
*/
|
||||
if (settings->wol_wait_time > 0) {
|
||||
guac_client_log(client, GUAC_LOG_DEBUG, "Sending Wake-on-LAN packet, "
|
||||
"and pausing for %d seconds.", settings->wol_wait_time);
|
||||
|
||||
/* Send the Wake-on-LAN request and wait until the server is responsive. */
|
||||
if (guac_wol_wake_and_wait(settings->wol_mac_addr,
|
||||
settings->wol_broadcast_addr,
|
||||
settings->wol_udp_port,
|
||||
settings->wol_wait_time,
|
||||
GUAC_WOL_DEFAULT_CONNECT_RETRIES,
|
||||
settings->hostname,
|
||||
settings->port)) {
|
||||
guac_client_log(client, GUAC_LOG_ERROR, "Failed to send WOL packet or connect to remote server.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Just send the packet and continue the connection, or return if failed. */
|
||||
else if(guac_wol_wake(settings->wol_mac_addr,
|
||||
settings->wol_broadcast_addr,
|
||||
settings->wol_udp_port)) {
|
||||
guac_client_log(client, GUAC_LOG_ERROR, "Failed to send WOL packet.");
|
||||
return NULL;
|
||||
|
||||
/* If wait time is specified, sleep for that amount of time. */
|
||||
if (settings->wol_wait_time > 0)
|
||||
guac_timestamp_msleep(settings->wol_wait_time * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set up screen recording, if requested */
|
||||
|
||||
@ -42,10 +42,13 @@
|
||||
#endif
|
||||
|
||||
#include <guacamole/client.h>
|
||||
#include <guacamole/mem.h>
|
||||
#include <guacamole/protocol.h>
|
||||
#include <guacamole/recording.h>
|
||||
#include <guacamole/socket.h>
|
||||
#include <guacamole/string.h>
|
||||
#include <guacamole/timestamp.h>
|
||||
#include <guacamole/wol-constants.h>
|
||||
#include <guacamole/wol.h>
|
||||
#include <rfb/rfbclient.h>
|
||||
#include <rfb/rfbconfig.h>
|
||||
@ -274,17 +277,47 @@ void* guac_vnc_client_thread(void* data) {
|
||||
|
||||
/* If Wake-on-LAN is enabled, attempt to wake. */
|
||||
if (settings->wol_send_packet) {
|
||||
guac_client_log(client, GUAC_LOG_DEBUG, "Sending Wake-on-LAN packet, "
|
||||
"and pausing for %d seconds.", settings->wol_wait_time);
|
||||
|
||||
/* Send the Wake-on-LAN request. */
|
||||
if (guac_wol_wake(settings->wol_mac_addr, settings->wol_broadcast_addr,
|
||||
settings->wol_udp_port))
|
||||
|
||||
/**
|
||||
* If wait time is set, send the wake packet and try to connect to the
|
||||
* server, failing if the server does not respond.
|
||||
*/
|
||||
if (settings->wol_wait_time > 0) {
|
||||
guac_client_log(client, GUAC_LOG_DEBUG, "Sending Wake-on-LAN packet, "
|
||||
"and pausing for %d seconds.", settings->wol_wait_time);
|
||||
|
||||
/* char representation of a port should be, at most, 5 characters plus terminator. */
|
||||
char* str_port = guac_mem_alloc(6);
|
||||
if (guac_itoa(str_port, settings->port) < 1) {
|
||||
guac_client_log(client, GUAC_LOG_ERROR, "Failed to convert port to integer for WOL function.");
|
||||
guac_mem_free(str_port);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Send the Wake-on-LAN request and wait until the server is responsive. */
|
||||
if (guac_wol_wake_and_wait(settings->wol_mac_addr,
|
||||
settings->wol_broadcast_addr,
|
||||
settings->wol_udp_port,
|
||||
settings->wol_wait_time,
|
||||
GUAC_WOL_DEFAULT_CONNECT_RETRIES,
|
||||
settings->hostname,
|
||||
(const char *) str_port)) {
|
||||
guac_client_log(client, GUAC_LOG_ERROR, "Failed to send WOL packet or connect to remote system.");
|
||||
guac_mem_free(str_port);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
guac_mem_free(str_port);
|
||||
|
||||
}
|
||||
|
||||
/* Just send the packet and continue the connection, or return if failed. */
|
||||
else if(guac_wol_wake(settings->wol_mac_addr,
|
||||
settings->wol_broadcast_addr,
|
||||
settings->wol_udp_port)) {
|
||||
guac_client_log(client, GUAC_LOG_ERROR, "Failed to send WOL packet.");
|
||||
return NULL;
|
||||
|
||||
/* If wait time is specified, sleep for that amount of time. */
|
||||
if (settings->wol_wait_time > 0)
|
||||
guac_timestamp_msleep(settings->wol_wait_time * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
/* Configure clipboard encoding */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user