Development
This commit is contained in:
parent
f7cbe2acf9
commit
6d9aac0460
2 changed files with 25 additions and 4 deletions
|
|
@ -47,7 +47,8 @@
|
|||
},
|
||||
{
|
||||
"label": "Vendor",
|
||||
"field": "vendor"
|
||||
"field": "vendor",
|
||||
"render": "raw_html"
|
||||
},
|
||||
{
|
||||
"label": "VLAN",
|
||||
|
|
|
|||
|
|
@ -22,14 +22,34 @@ try:
|
|||
except Exception:
|
||||
_mac_parser = None
|
||||
|
||||
try:
|
||||
from mac_vendor_lookup import MacLookup as _MacLookup
|
||||
_mac_lookup = _MacLookup()
|
||||
except Exception:
|
||||
_mac_lookup = None
|
||||
|
||||
def _get_vendor(mac):
|
||||
short, long = '', ''
|
||||
if _mac_parser:
|
||||
try:
|
||||
return _mac_parser.get_manuf(mac) or ''
|
||||
short = _mac_parser.get_manuf(mac) or ''
|
||||
except Exception:
|
||||
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 ======================================================
|
||||
|
|
@ -229,7 +249,7 @@ def live_dhcp_leases():
|
|||
'hostname': hostname_html,
|
||||
'ip_address': parts[2],
|
||||
'mac_address': parts[1],
|
||||
'vendor': _get_vendor(parts[1]),
|
||||
'vendor': _vendor_cell(_get_vendor(parts[1])),
|
||||
'vlan_name': vlan_name,
|
||||
'last_active': last_active,
|
||||
'renews': 'in ' + relative_time(renews_ts or expiry, now, short=True),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue