Development
This commit is contained in:
parent
ea8a025488
commit
f7cbe2acf9
2 changed files with 4 additions and 25 deletions
|
|
@ -47,8 +47,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Vendor",
|
"label": "Vendor",
|
||||||
"field": "vendor",
|
"field": "vendor"
|
||||||
"render": "raw_html"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "VLAN",
|
"label": "VLAN",
|
||||||
|
|
|
||||||
|
|
@ -22,34 +22,14 @@ 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):
|
||||||
"""Return (short, long) where short is the abbreviated name and long is the full IEEE name."""
|
|
||||||
short, long = '', ''
|
|
||||||
if _mac_parser:
|
if _mac_parser:
|
||||||
try:
|
try:
|
||||||
short = _mac_parser.get_manuf(mac) or ''
|
return _mac_parser.get_manuf(mac) or ''
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
if _mac_lookup:
|
return ''
|
||||||
try:
|
|
||||||
long = _mac_lookup.lookup(mac) or ''
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
return (short or long, long)
|
|
||||||
|
|
||||||
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 ======================================================
|
# File loaders ======================================================
|
||||||
|
|
@ -249,7 +229,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': _vendor_html(_get_vendor(parts[1])),
|
'vendor': _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),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue