Development

This commit is contained in:
Matthew Grotke 2026-06-05 02:23:08 -04:00
parent b307461d44
commit 4734eb41a0
3 changed files with 32 additions and 16 deletions

View file

@ -1,7 +1,6 @@
import copy
import gzip
import io
import ipaddress
import os
import re
from pathlib import Path
@ -40,7 +39,7 @@ def regenerate():
def options_save():
mac_format = request.form.get('mac_format', 'aabbccddeeff')
apply_to = request.form.get('apply_to', 'all')
ap_ips_raw = request.form.get('ap_ips', '')
ap_ips = request.form.getlist('ap_ips')
if mac_format not in VALID_MAC_FORMATS:
flash('Invalid MAC format.', 'error')
@ -49,15 +48,17 @@ def options_save():
flash('Invalid apply_to value.', 'error')
return redirect(f'/{_PAGE}')
ap_ips = [line.strip() for line in ap_ips_raw.splitlines() if line.strip()]
cfg = load_config()
valid_ips = {
r['ip'] for r in cfg.get('dhcp_reservations', [])
if r.get('radius_client') is True
and r.get('ip') and r.get('ip') not in ('', 'dynamic')
}
for ip in ap_ips:
try:
ipaddress.IPv4Address(ip)
except ValueError:
flash(f'Invalid IP address: {ip}', 'error')
if ip not in valid_ips:
flash(f'Invalid AP selection: {ip}', 'error')
return redirect(f'/{_PAGE}')
cfg = load_config()
before = copy.deepcopy(cfg.get('radius', {}).get('options', {}))
after = {'mac_format': mac_format, 'apply_to': apply_to, 'ap_ips': ap_ips}
cfg.setdefault('radius', {})['options'] = after