28 lines
964 B
Python
28 lines
964 B
Python
from flask import Blueprint, request, redirect, flash
|
|
from auth import require_level
|
|
from config_utils import load_core, save_core, verify_core_hash, apply_msg
|
|
import sanitize
|
|
|
|
bp = Blueprint('action_apply_mdns', __name__)
|
|
|
|
|
|
|
|
@bp.route('/action/apply_mdns', methods=['POST'])
|
|
@require_level('administrator')
|
|
def apply_mdns():
|
|
mdns_enabled = 'mdns_enabled' in request.form
|
|
mdns_reflect_vlans = [sanitize.name(v) for v in request.form.getlist('mdns_reflect_vlans') if v.strip()]
|
|
|
|
if not verify_core_hash(request.form.get('config_hash', '')):
|
|
flash('Configuration was modified by another session. Please refresh and try again.', 'error')
|
|
return redirect('/view/view_mdns')
|
|
|
|
core = load_core()
|
|
core.setdefault('mdns_reflection', {}).update({
|
|
'enabled': mdns_enabled,
|
|
'reflect_vlans': mdns_reflect_vlans,
|
|
})
|
|
save_core(core)
|
|
|
|
flash(apply_msg(), 'success')
|
|
return redirect('/view/view_mdns')
|