Development

This commit is contained in:
Matthew Grotke 2026-06-03 01:32:13 -04:00
parent 2905f21052
commit f04b2b36cc
5 changed files with 22 additions and 10 deletions

View file

@ -55,7 +55,7 @@
"field": "vlan_name" "field": "vlan_name"
}, },
{ {
"label": "Last Active", "label": "Last Renewal",
"field": "last_active" "field": "last_active"
}, },
{ {

View file

@ -69,6 +69,11 @@ def live_dhcp_leases():
for r in cfg.get('dhcp_reservations', []) for r in cfg.get('dhcp_reservations', [])
if r.get('mac') and r.get('hostname') if r.get('mac') and r.get('hostname')
} }
mac_to_desc = {
r['mac'].lower(): r['description']
for r in cfg.get('dhcp_reservations', [])
if r.get('mac') and r.get('description')
}
for leases_file in glob.glob('/var/lib/misc/dnsmasq-routlin-*.leases'): for leases_file in glob.glob('/var/lib/misc/dnsmasq-routlin-*.leases'):
stem = os.path.basename(leases_file) stem = os.path.basename(leases_file)
vlan_name = stem[len('dnsmasq-routlin-'):-len('.leases')] vlan_name = stem[len('dnsmasq-routlin-'):-len('.leases')]
@ -95,12 +100,14 @@ def live_dhcp_leases():
mac_norm = parts[1].lower() mac_norm = parts[1].lower()
device_h = parts[3] if parts[3] != '*' else None device_h = parts[3] if parts[3] != '*' else None
res_h = mac_to_res.get(mac_norm) res_h = mac_to_res.get(mac_norm)
desc = mac_to_desc.get(mac_norm)
desc_attr = f' data-hostname-desc="{e(desc)}"' if desc else ''
if res_h and device_h and device_h.lower() != res_h.lower(): if res_h and device_h and device_h.lower() != res_h.lower():
hostname_html = f'<strong>{e(res_h)}</strong><br/>({e(device_h)})' hostname_html = f'<span{desc_attr}>{e(res_h)}<br/>({e(device_h)})</span>' if desc_attr else f'{e(res_h)}<br/>({e(device_h)})'
elif res_h: elif res_h:
hostname_html = f'<strong>{e(res_h)}</strong>' hostname_html = f'<span{desc_attr}>{e(res_h)}</span>' if desc_attr else e(res_h)
elif device_h: elif device_h:
hostname_html = e(device_h) hostname_html = f'<span{desc_attr}>{e(device_h)}</span>' if desc_attr else e(device_h)
else: else:
hostname_html = '-' hostname_html = '-'
rows.append({ rows.append({

View file

@ -223,17 +223,21 @@
"label": "Max Log Size (KB)", "label": "Max Log Size (KB)",
"name": "log_max_kb", "name": "log_max_kb",
"input_type": "number", "input_type": "number",
"layout": "inline",
"value": "%GENERAL_LOG_MAX_KB%", "value": "%GENERAL_LOG_MAX_KB%",
"min": 64, "min": 64,
"hint": "Log is cleared and restarted when it exceeds this size." "hint": "Log will automatically be cleared when it reaches this size."
},
{
"type": "hr"
}, },
{ {
"type": "field", "type": "field",
"label": "Only record errors to log", "label": "",
"name": "log_errors_only", "name": "log_errors_only",
"input_type": "checkbox", "input_type": "checkbox",
"value": "%GENERAL_LOG_ERRORS_ONLY%", "checkbox_label": "Only record errors to log",
"hint": "Only write error-level messages to the log." "value": "%GENERAL_LOG_ERRORS_ONLY%"
}, },
{ {
"type": "hr" "type": "hr"

View file

@ -114,7 +114,7 @@
"input_type": "checkbox", "input_type": "checkbox",
"checkbox_label": "Log auth requests", "checkbox_label": "Log auth requests",
"value": "%RADIUS_LOGGING%", "value": "%RADIUS_LOGGING%",
"hint": "Enables auth and auth_accept/auth_reject in radiusd.conf." "hint": "%RADIUS_LOGGING_HINT%"
}, },
{ {
"type": "hr" "type": "hr"
@ -149,7 +149,7 @@
"layout": "inline", "layout": "inline",
"value": "%RADIUS_GEN_LOG_MAX_KB%", "value": "%RADIUS_GEN_LOG_MAX_KB%",
"min": "64", "min": "64",
"hint": "Log display will be truncated to this size." "hint": "Log will automatically be cleared when it reaches this size."
}, },
{ {
"type": "button_row", "type": "button_row",

View file

@ -66,6 +66,7 @@ def collect_tokens(cfg):
tokens['RADIUS_MAC_FORMAT'] = fr_opts.get('mac_format', 'aabbccddeeff') tokens['RADIUS_MAC_FORMAT'] = fr_opts.get('mac_format', 'aabbccddeeff')
tokens['RADIUS_APPLY_TO'] = fr_opts.get('apply_to', 'all') tokens['RADIUS_APPLY_TO'] = fr_opts.get('apply_to', 'all')
tokens['RADIUS_LOGGING'] = 'true' if fr_gen.get('logging', False) else '' tokens['RADIUS_LOGGING'] = 'true' if fr_gen.get('logging', False) else ''
tokens['RADIUS_LOGGING_HINT'] = 'Unchecking will clear logs.' if fr_gen.get('logging', False) else ''
tokens['RADIUS_GEN_LOG_MAX_KB'] = str(fr_gen.get('log_max_kb', 1024)) tokens['RADIUS_GEN_LOG_MAX_KB'] = str(fr_gen.get('log_max_kb', 1024))
tokens['RADIUS_LOG_TAIL'], tokens['RADIUS_LOG_SUMMARY'] = radius_log_tail(cfg) tokens['RADIUS_LOG_TAIL'], tokens['RADIUS_LOG_SUMMARY'] = radius_log_tail(cfg)
return tokens return tokens