Development
This commit is contained in:
parent
e289583c4b
commit
efdc2c63f2
4 changed files with 114 additions and 7 deletions
31
docker/routlin-dash/app/action_apply_ddns_ip_check.py
Normal file
31
docker/routlin-dash/app/action_apply_ddns_ip_check.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
from flask import Blueprint, request, redirect, flash
|
||||
from auth import require_level
|
||||
from config_utils import load_core, save_core, verify_core_hash
|
||||
|
||||
bp = Blueprint('action_apply_ddns_ip_check', __name__)
|
||||
|
||||
VIEW = '/view/view_ddns'
|
||||
|
||||
|
||||
@bp.route('/action/ddns_ip_check_save', methods=['POST'])
|
||||
@require_level('administrator')
|
||||
def ddns_ip_check_save():
|
||||
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)
|
||||
|
||||
http_services = [u.strip() for u in request.form.getlist('http_services') if u.strip()]
|
||||
dig_services = [u.strip() for u in request.form.getlist('dig_services') if u.strip()]
|
||||
|
||||
if not http_services and not dig_services:
|
||||
flash('At least one IP check service is required.', 'error')
|
||||
return redirect(VIEW)
|
||||
|
||||
services = [{'type': 'http', 'url': u} for u in http_services]
|
||||
services += [{'type': 'dig', 'url': u} for u in dig_services]
|
||||
|
||||
core = load_core()
|
||||
core.setdefault('ddns', {})['ip_check_services'] = services
|
||||
save_core(core)
|
||||
flash('IP check services saved.', 'success')
|
||||
return redirect(VIEW)
|
||||
Loading…
Add table
Add a link
Reference in a new issue