Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions defaults/python/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,32 @@ def _try_parse_info(ip_address: str):

if not infos:
raise Exception(f"WOL failed - {address} does not have any IPv4 or IPv6 interfaces!")

tried_addresses = []
def try_send_magic_packet(ip_address, family):
try:
cache_key = (ip_address, family)
if cache_key in tried_addresses:
return

for family, address_info in infos:
address_log = address if address == address_info else f"{address} ({address_info})"
logger.info(f"Sending WOL ({hostname} - {mac}) to {address_log}")
tried_addresses.append(cache_key)
address_log = address if address == ip_address else f"{address} ({ip_address})"
logger.info(f"Sending WOL ({hostname} - {mac}) to {address_log}")

send_magic_packet(mac, ip_address=ip_address, address_family=family, port=default_port)
except OSError as err:
acceptable_errors = [101]
if err.errno in acceptable_errors:
logger.warning(f"WOL failed: {str(err)}")
else:
raise

for family, address_info in infos:
if family == socket.AF_INET:
# Broadcast for IPv4
send_magic_packet(mac, ip_address="255.255.255.255", address_family=family, port=default_port)
try_send_magic_packet("255.255.255.255", family)

send_magic_packet(mac, ip_address=address_info, address_family=family, port=default_port)
try_send_magic_packet(address_info, family)


def is_moondeck_runner_ready():
Expand Down
2 changes: 1 addition & 1 deletion src/lib/commandproxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class CommandProxy {
const customExec = hostSettings?.customWolExecPath ?? null;

if (hostName !== null && address !== null && mac !== null && (!useCustomExec || customExec !== null)) {
await wakeOnLan(hostName, address, mac, customExec);
await wakeOnLan(hostName, address, mac, useCustomExec ? customExec : null);
await sleep(2 * 1000);
}
}
Expand Down