diff --git a/listener.py b/listener.py index 8a9e586..76472dc 100755 --- a/listener.py +++ b/listener.py @@ -323,7 +323,9 @@ def main(): def get_mac_vendor(mac): prefix = mac.upper()[0:8].replace(":", "-") + print(f"[DEBUG] Looking up prefix: {prefix}") if prefix in vendor_cache: + print(f"[DEBUG] Cached hit: {vendor_cache[prefix]}") return vendor_cache[prefix] try: if not os.path.exists("oui.txt"): @@ -333,12 +335,15 @@ def get_mac_vendor(mac): urllib.request.urlretrieve(url, "oui.txt") with open("oui.txt", "r", encoding="utf-8", errors="ignore") as f: for line in f: - if "(hex)" in line and prefix in line: - parts = line.strip().split() - if len(parts) >= 3 and parts[0] == prefix and parts[1] == "(hex)": - vendor = " ".join(parts[2:]).strip() - vendor_cache[prefix] = vendor - return vendor + if line.strip().endswith("(hex)"): + parts = line.split() + if len(parts) >= 3: + print(f"[DEBUG] Checking line: {parts}") + if parts[0] == prefix: + vendor = " ".join(parts[2:]).replace("(hex)", "").strip() + vendor_cache[prefix] = vendor + print(f"[DEBUG] Vendor found: {vendor}") + return vendor except Exception as e: print(f"[ERROR] Vendor lookup failed: {e}") vendor_cache[prefix] = "Unknown"