Add original code

This commit is contained in:
Jyri Eerola 2017-09-25 17:34:21 +03:00 committed by GitHub
parent 97a09a6b69
commit 4a341edab8

14
wol.py Normal file
View file

@ -0,0 +1,14 @@
import socket
def wake(mac: str):
payload = [0xff] * 6 + [int(f'0x{x}', 16) for x in mac.split(':')] * 16
sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
sock.sendto(bytes(payload), ('ff02::1', 9))
if __name__ == 'main':
import sys
wol(sys.argv[1])