Development

This commit is contained in:
Matthew Grotke 2026-05-27 22:04:04 -04:00
parent eed1d295dc
commit d9f3bd8289
45 changed files with 635 additions and 666 deletions

View file

@ -1,3 +1,4 @@
from pathlib import Path
import copy
from flask import Blueprint, request, redirect, flash
@ -6,17 +7,19 @@ from config_utils import load_config, save_config_with_snapshot, verify_config_h
import sanitize
import validation as validate
bp = Blueprint('mdns', __name__)
_PAGE = Path(__file__).parent.name
bp = Blueprint(_PAGE, __name__)
@bp.route('/action/apply_mdns', methods=['POST'])
@bp.route('/action/mdns/settings_apply', methods=['POST'])
@require_level('administrator')
def apply_mdns():
def settings_apply():
mdns_enabled = 'mdns_enabled' in request.form
if not verify_config_hash(request.form.get('config_hash', '')):
flash('Configuration was modified by another session. Please refresh and try again.', 'error')
return redirect('/view/view_mdns')
return redirect(f'/{_PAGE}')
cfg = load_config()
mdns_reflect_vlans = sanitize.filterlist(
@ -33,7 +36,7 @@ def apply_mdns():
if errors:
for msg in errors:
flash(msg, 'error')
return redirect('/view/view_mdns')
return redirect(f'/{_PAGE}')
flash(save_config_with_snapshot(
cfg,
@ -41,4 +44,4 @@ def apply_mdns():
before=before or None, after=copy.deepcopy(cfg['mdns_reflection']),
description='Updated mDNS reflection settings',
), 'success')
return redirect('/view/view_mdns')
return redirect(f'/{_PAGE}')