frame-it/utils.py
2020-01-22 19:50:57 +01:00

21 lines
503 B
Python

import os
import netifaces
def get_device_name() -> str:
if 'INTERFACE' not in os.environ:
print("[Error] \"INTERFACE\" not found in your environment variables")
print(" Please specify your network interface")
exit(0)
return os.environ['INTERFACE']
def get_mac_address() -> bytes:
return bytes(list(map(lambda i: int(i, 16), netifaces.ifaddresses(
get_device_name())[netifaces.AF_LINK][0]["addr"].split(":"))))
mac_address = get_mac_address()