From 09e6b7403dc9f9948b972cc2d5e5d4da16cf1adf Mon Sep 17 00:00:00 2001 From: Matthew Grotke Date: Mon, 1 Jun 2026 23:55:56 -0400 Subject: [PATCH] Development --- debug_leases.py | 47 ++++++++++++++++++++++++++++ docker/routlin-dash/app/view_page.py | 10 +++--- docker/routlin-dash/requirements.txt | 2 +- 3 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 debug_leases.py diff --git a/debug_leases.py b/debug_leases.py new file mode 100644 index 0000000..eb99734 --- /dev/null +++ b/debug_leases.py @@ -0,0 +1,47 @@ +import sys, glob, json, os + +# Find config.json under /routlin_location +config_path = None +for candidate in [ + '/routlin_location/config.json', + '/routlin_location/configs/config.json', +]: + if os.path.exists(candidate): + config_path = candidate + break + +if not config_path: + matches = glob.glob('/routlin_location/**/config.json', recursive=True) + config_path = matches[0] if matches else None + +if not config_path: + print('ERROR: could not find config.json under /routlin_location') + sys.exit(1) + +print(f'Using config: {config_path}') +cfg = json.load(open(config_path)) +res = {r['mac'].lower(): r['hostname'] for r in cfg.get('dhcp_reservations', []) if r.get('mac') and r.get('hostname')} +print(f'{len(res)} reservations in mac_to_res') + +for f in sorted(glob.glob('/var/lib/misc/dnsmasq-routlin-*.leases')): + print(f'\n--- {f} ---') + for line in open(f): + p = line.strip().split() + if len(p) >= 4: + mac = p[1].lower() + device_h = p[3] if p[3] != '*' else '(none)' + res_h = res.get(mac, '(no reservation)') + print(f' mac={mac} device_h={device_h} res_h={res_h}') + +try: + from mac_vendor_lookup import MacLookup + ml = MacLookup() + print('\n--- vendor lookup test ---') + for mac in list(res.keys())[:5]: + try: + vendor = ml.lookup(mac) + except Exception as e: + vendor = f'(error: {e})' + print(f' {mac} {vendor}') +except ImportError: + print('\nmac-vendor-lookup not installed') diff --git a/docker/routlin-dash/app/view_page.py b/docker/routlin-dash/app/view_page.py index c772388..31f2019 100644 --- a/docker/routlin-dash/app/view_page.py +++ b/docker/routlin-dash/app/view_page.py @@ -17,16 +17,16 @@ HEALTH_FILE = os.path.join(CONFIGS_DIR, '.health') bp = Blueprint('view_page', __name__) try: - import manuf as _manuf_mod - _mac_parser = _manuf_mod.MacParser() + from mac_vendor_lookup import MacLookup as _MacLookup + _mac_lookup = _MacLookup() except Exception: - _mac_parser = None + _mac_lookup = None def _get_vendor(mac): - if _mac_parser is None: + if _mac_lookup is None: return '' try: - return _mac_parser.get_comment(mac) or _mac_parser.get_manuf(mac) or '' + return _mac_lookup.lookup(mac) or '' except Exception: return '' diff --git a/docker/routlin-dash/requirements.txt b/docker/routlin-dash/requirements.txt index 1cdb17b..b2fed68 100644 --- a/docker/routlin-dash/requirements.txt +++ b/docker/routlin-dash/requirements.txt @@ -1,3 +1,3 @@ flask bcrypt -manuf +mac-vendor-lookup