Development

This commit is contained in:
Matthew Grotke 2026-06-02 00:15:40 -04:00
parent f7cbe2acf9
commit 6d9aac0460
2 changed files with 25 additions and 4 deletions

View file

@ -47,7 +47,8 @@
}, },
{ {
"label": "Vendor", "label": "Vendor",
"field": "vendor" "field": "vendor",
"render": "raw_html"
}, },
{ {
"label": "VLAN", "label": "VLAN",

View file

@ -22,14 +22,34 @@ try:
except Exception: except Exception:
_mac_parser = None _mac_parser = None
try:
from mac_vendor_lookup import MacLookup as _MacLookup
_mac_lookup = _MacLookup()
except Exception:
_mac_lookup = None
def _get_vendor(mac): def _get_vendor(mac):
short, long = '', ''
if _mac_parser: if _mac_parser:
try: try:
return _mac_parser.get_manuf(mac) or '' short = _mac_parser.get_manuf(mac) or ''
except Exception: except Exception:
pass pass
return '' if _mac_lookup:
try:
long = _mac_lookup.lookup(mac) or ''
except Exception:
pass
return (short, long)
def _vendor_cell(vendor):
short, long = vendor
display = short if short else (long[:8] if long else '')
if not display:
return '-'
if long:
return f'<span data-vendor-long="{e(long)}">{e(display)}</span>'
return e(display)
# File loaders ====================================================== # File loaders ======================================================
@ -229,7 +249,7 @@ def live_dhcp_leases():
'hostname': hostname_html, 'hostname': hostname_html,
'ip_address': parts[2], 'ip_address': parts[2],
'mac_address': parts[1], 'mac_address': parts[1],
'vendor': _get_vendor(parts[1]), 'vendor': _vendor_cell(_get_vendor(parts[1])),
'vlan_name': vlan_name, 'vlan_name': vlan_name,
'last_active': last_active, 'last_active': last_active,
'renews': 'in ' + relative_time(renews_ts or expiry, now, short=True), 'renews': 'in ' + relative_time(renews_ts or expiry, now, short=True),