Development

This commit is contained in:
Matthew Grotke 2026-06-02 00:00:39 -04:00
parent 09e6b7403d
commit e6c5a8136c
3 changed files with 23 additions and 11 deletions

View file

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

View file

@ -17,18 +17,29 @@ HEALTH_FILE = os.path.join(CONFIGS_DIR, '.health')
bp = Blueprint('view_page', __name__)
try:
from mac_vendor_lookup import MacLookup as _MacLookup
_mac_lookup = _MacLookup()
import manuf as _manuf_mod
_mac_parser = _manuf_mod.MacParser()
except Exception:
_mac_lookup = None
_mac_parser = None
def _get_vendor(mac):
if _mac_lookup is None:
return ''
"""Return (short, long) vendor names. long may be empty if no comment available."""
if _mac_parser is None:
return ('', '')
try:
return _mac_lookup.lookup(mac) or ''
short = _mac_parser.get_manuf(mac) or ''
long = _mac_parser.get_comment(mac) or ''
return (short, long)
except Exception:
return ''
return ('', '')
def _vendor_html(vendor):
short, long = vendor
if not short:
return '-'
if long and long != short:
return f'<span class="tag" data-tooltip="{e(long)}">{e(short)}</span>'
return e(short)
# File loaders ======================================================
@ -228,10 +239,10 @@ def live_dhcp_leases():
'hostname': hostname_html,
'ip_address': parts[2],
'mac_address': parts[1],
'vendor': _get_vendor(parts[1]),
'vendor': _vendor_html(_get_vendor(parts[1])),
'vlan_name': vlan_name,
'last_active': last_active,
'renews': 'in ' + relative_time(renews_ts or expiry, now),
'renews': 'in ' + relative_time(renews_ts or expiry, now, short=True),
})
except Exception:
pass

View file

@ -1,3 +1,3 @@
flask
bcrypt
mac-vendor-lookup
manuf