Refactor environment variable loading to improve error handling and clarity

This commit is contained in:
Yaro Kasear 2025-04-30 14:27:39 -05:00
parent fa0a1fd930
commit 0e49e636ce

View file

@ -6,9 +6,15 @@ from collections import defaultdict
from scapy.all import sniff, Dot11, RadioTap
from dotenv import dotenv_values
# === Load ENV ===
config = dotenv_values(os.path.expanduser("~/wifi_test/settings.env"))
settings_path = os.path.expanduser("~/wifi_test/settings.env")
config = dotenv_values(settings_path)
if not config:
print(f"[!] Failed to load settings from {settings_path}")
exit(1)
LISTEN_INTERFACE = config.get("LISTEN_INTERFACE", "wlan0")
print(f"[+] Using LISTEN_INTERFACE = {LISTEN_INTERFACE}")
# === Globals ===
clients_per_channel = defaultdict(set)