Development
This commit is contained in:
parent
a4652866c3
commit
27eaea3d73
19 changed files with 602 additions and 427 deletions
|
|
@ -33,7 +33,7 @@ def add_vlan():
|
|||
radius_default = 'radius_default' in request.form
|
||||
mdns_reflection = 'mdns_reflection' in request.form
|
||||
use_blocklists = sanitize.filterlist(request.form.getlist('use_blocklists'),
|
||||
{b.get('name') for b in load_core().get('blocklists', [])})
|
||||
{b.get('name') for b in load_core().get('dns_blocking', {}).get('blocklists', [])})
|
||||
|
||||
if not name:
|
||||
flash('Name is required.', 'error')
|
||||
|
|
@ -104,7 +104,7 @@ def edit_vlan():
|
|||
radius_default = 'radius_default' in request.form
|
||||
mdns_reflection = 'mdns_reflection' in request.form
|
||||
use_blocklists = sanitize.filterlist(request.form.getlist('use_blocklists'),
|
||||
{b.get('name') for b in load_core().get('blocklists', [])})
|
||||
{b.get('name') for b in load_core().get('dns_blocking', {}).get('blocklists', [])})
|
||||
|
||||
# subnet_mask is only present when the column is visible (not all edit paths send it).
|
||||
# Validate if submitted; fall back to the stored value otherwise.
|
||||
|
|
|
|||
|
|
@ -111,9 +111,9 @@ def ddns_tableaccounts_rowdelete():
|
|||
return redirect(VIEW)
|
||||
|
||||
|
||||
@bp.route('/action/ddns_cardcheckinterval_save', methods=['POST'])
|
||||
@bp.route('/action/ddns_cardipcheckinterval_save', methods=['POST'])
|
||||
@require_level('administrator')
|
||||
def ddns_cardcheckinterval_save():
|
||||
def ddns_cardipcheckinterval_save():
|
||||
raw = request.form.get('timer_interval', '').strip()
|
||||
try:
|
||||
mins = int(raw)
|
||||
|
|
@ -157,9 +157,9 @@ def ddns_cardipcheckservices_save():
|
|||
return redirect(VIEW)
|
||||
|
||||
|
||||
@bp.route('/action/ddns_cardddnslog_save', methods=['POST'])
|
||||
@bp.route('/action/ddns_cardlogging_save', methods=['POST'])
|
||||
@require_level('administrator')
|
||||
def ddns_cardddnslog_save():
|
||||
def ddns_cardlogging_save():
|
||||
log_max_kb = validate.int_range(request.form.get('log_max_kb', '').strip(), 64, None)
|
||||
if log_max_kb is None:
|
||||
flash('Max Log Size must be a number >= 64.', 'error')
|
||||
|
|
@ -178,9 +178,9 @@ def ddns_cardddnslog_save():
|
|||
return redirect(VIEW)
|
||||
|
||||
|
||||
@bp.route('/action/ddns_cardddnslog_clear', methods=['POST'])
|
||||
@bp.route('/action/ddns_cardlogging_clear', methods=['POST'])
|
||||
@require_level('administrator')
|
||||
def ddns_cardddnslog_clear():
|
||||
def ddns_cardlogging_clear():
|
||||
try:
|
||||
open(LOG_FILE, 'w').close()
|
||||
flash('DDNS log cleared.', 'success')
|
||||
|
|
@ -189,9 +189,9 @@ def ddns_cardddnslog_clear():
|
|||
return redirect(VIEW)
|
||||
|
||||
|
||||
@bp.route('/action/ddns_cardddnslog_download', methods=['GET'])
|
||||
@bp.route('/action/ddns_cardlogging_download', methods=['GET'])
|
||||
@require_level('administrator')
|
||||
def ddns_cardddnslog_download():
|
||||
def ddns_cardlogging_download():
|
||||
if not os.path.isfile(LOG_FILE):
|
||||
abort(404)
|
||||
return send_file(LOG_FILE, as_attachment=True, download_name='ddns.log', mimetype='text/plain')
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
import re
|
||||
from flask import Blueprint, request, redirect, flash
|
||||
from auth import require_level
|
||||
from config_utils import load_core, save_core, verify_core_hash, queued_msg
|
||||
import sanitize
|
||||
import validation as validate
|
||||
|
||||
bp = Blueprint('action_dnsblocklists', __name__)
|
||||
bp = Blueprint('action_dnsblocking', __name__)
|
||||
|
||||
VIEW = '/view/view_dns_blocklists'
|
||||
VIEW = '/view/view_dns_blocking'
|
||||
|
||||
_VALID_FORMATS_STR = ', '.join(sorted(validate.VALID_BLOCKLIST_FORMATS))
|
||||
|
||||
|
|
@ -50,9 +51,9 @@ def _parse_fields():
|
|||
return {'name': name, 'description': description, 'format': fmt, 'url': url}, None
|
||||
|
||||
|
||||
@bp.route('/action/dnsblocklists_tableblocklists_rowdelete', methods=['POST'])
|
||||
@bp.route('/action/dnsblocking_tableblocklists_rowdelete', methods=['POST'])
|
||||
@require_level('administrator')
|
||||
def dnsblocklists_tableblocklists_rowdelete():
|
||||
def dnsblocking_tableblocklists_rowdelete():
|
||||
idx = _row_index()
|
||||
if idx is None:
|
||||
flash('Invalid request.', 'error')
|
||||
|
|
@ -62,7 +63,7 @@ def dnsblocklists_tableblocklists_rowdelete():
|
|||
return redirect(VIEW)
|
||||
|
||||
core = load_core()
|
||||
items = core.get('blocklists', [])
|
||||
items = core.get('dns_blocking', {}).get('blocklists', [])
|
||||
if idx < 0 or idx >= len(items):
|
||||
flash('Entry not found.', 'error')
|
||||
return redirect(VIEW)
|
||||
|
|
@ -79,9 +80,9 @@ def dnsblocklists_tableblocklists_rowdelete():
|
|||
return redirect(VIEW)
|
||||
|
||||
|
||||
@bp.route('/action/dnsblocklists_tableblocklists_rowedit', methods=['POST'])
|
||||
@bp.route('/action/dnsblocking_tableblocklists_rowedit', methods=['POST'])
|
||||
@require_level('administrator')
|
||||
def dnsblocklists_tableblocklists_rowedit():
|
||||
def dnsblocking_tableblocklists_rowedit():
|
||||
idx = _row_index()
|
||||
if idx is None:
|
||||
flash('Invalid request.', 'error')
|
||||
|
|
@ -95,7 +96,7 @@ def dnsblocklists_tableblocklists_rowedit():
|
|||
return redirect(VIEW)
|
||||
|
||||
core = load_core()
|
||||
items = core.get('blocklists', [])
|
||||
items = core.get('dns_blocking', {}).get('blocklists', [])
|
||||
if idx < 0 or idx >= len(items):
|
||||
flash('Entry not found.', 'error')
|
||||
return redirect(VIEW)
|
||||
|
|
@ -117,9 +118,9 @@ def dnsblocklists_tableblocklists_rowedit():
|
|||
return redirect(VIEW)
|
||||
|
||||
|
||||
@bp.route('/action/dnsblocklists_cardaddblocklist_add', methods=['POST'])
|
||||
@bp.route('/action/dnsblocking_cardaddblocklist_add', methods=['POST'])
|
||||
@require_level('administrator')
|
||||
def dnsblocklists_cardaddblocklist_add():
|
||||
def dnsblocking_cardaddblocklist_add():
|
||||
fields, err = _parse_fields()
|
||||
if err:
|
||||
return redirect(VIEW)
|
||||
|
|
@ -128,7 +129,7 @@ def dnsblocklists_cardaddblocklist_add():
|
|||
return redirect(VIEW)
|
||||
|
||||
core = load_core()
|
||||
blocklists = core.setdefault('blocklists', [])
|
||||
blocklists = core.setdefault('dns_blocking', {}).setdefault('blocklists', [])
|
||||
|
||||
if any(b.get('name', '').lower() == fields['name'].lower() for b in blocklists):
|
||||
flash('The configuration has not been saved because a blocklist with that name already exists.', 'error')
|
||||
|
|
@ -152,9 +153,9 @@ def dnsblocklists_cardaddblocklist_add():
|
|||
return redirect(VIEW)
|
||||
|
||||
|
||||
@bp.route('/action/dnsblocklists_cardblocklistrefresh_save', methods=['POST'])
|
||||
@bp.route('/action/dnsblocking_cardblocklistrefresh_save', methods=['POST'])
|
||||
@require_level('administrator')
|
||||
def dnsblocklists_cardblocklistrefresh_save():
|
||||
def dnsblocking_cardblocklistrefresh_save():
|
||||
daily_execute_time = validate.time_24h(sanitize.time_24h(request.form.get('daily_execute_time_24hr_local', '')))
|
||||
|
||||
if not daily_execute_time:
|
||||
|
|
@ -166,15 +167,48 @@ def dnsblocklists_cardblocklistrefresh_save():
|
|||
return redirect(VIEW)
|
||||
|
||||
core = load_core()
|
||||
core.setdefault('general', {})['daily_execute_time_24hr_local'] = daily_execute_time
|
||||
core.setdefault('dns_blocking', {}).setdefault('general', {})['daily_execute_time_24hr_local'] = daily_execute_time
|
||||
save_core(core)
|
||||
|
||||
flash(queued_msg('core apply'), 'success')
|
||||
return redirect(VIEW)
|
||||
|
||||
|
||||
@bp.route('/action/dnsblocklists_cardblocklistrefresh_refresh', methods=['POST'])
|
||||
@bp.route('/action/dnsblocking_cardblocklistrefresh_refreshnow', methods=['POST'])
|
||||
@require_level('administrator')
|
||||
def dnsblocklists_cardblocklistrefresh_refresh():
|
||||
def dnsblocking_cardblocklistrefresh_refreshnow():
|
||||
flash(queued_msg('core update-blocklists', action_label='Blocklist refresh queued'), 'success')
|
||||
return redirect(VIEW)
|
||||
|
||||
|
||||
@bp.route('/action/dnsblocking_cardlogging_save', methods=['POST'])
|
||||
@require_level('administrator')
|
||||
def dnsblocking_cardlogging_save():
|
||||
log_max_kb_raw = request.form.get('log_max_kb', '').strip()
|
||||
log_errors_only = 'log_errors_only' in request.form
|
||||
dnsmasq_log_queries = 'dnsmasq_log_queries' in request.form
|
||||
|
||||
log_max_kb = validate.int_range(log_max_kb_raw, 64, None)
|
||||
if log_max_kb is None:
|
||||
flash('Max Log Size must be a number >= 64.', 'error')
|
||||
return redirect(VIEW)
|
||||
|
||||
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)
|
||||
|
||||
core = load_core()
|
||||
core.setdefault('dns_blocking', {}).setdefault('general', {}).update({
|
||||
'log_max_kb': log_max_kb,
|
||||
'log_errors_only': log_errors_only,
|
||||
})
|
||||
core.setdefault('network_interfaces', {})['dnsmasq_log_queries'] = dnsmasq_log_queries
|
||||
errors = validate.validate_config(core)
|
||||
if errors:
|
||||
for msg in errors:
|
||||
flash(msg, 'error')
|
||||
return redirect(VIEW)
|
||||
save_core(core)
|
||||
|
||||
flash(queued_msg('core apply'), 'success')
|
||||
return redirect(VIEW)
|
||||
|
|
@ -10,39 +10,6 @@ bp = Blueprint('action_general', __name__)
|
|||
_VIEW = '/view/view_general'
|
||||
|
||||
|
||||
@bp.route('/action/general_cardlogging_save', methods=['POST'])
|
||||
@require_level('administrator')
|
||||
def general_cardlogging_save():
|
||||
log_max_kb_raw = request.form.get('log_max_kb', '').strip()
|
||||
log_errors_only = 'log_errors_only' in request.form
|
||||
dnsmasq_log_queries = 'dnsmasq_log_queries' in request.form
|
||||
|
||||
log_max_kb = validate.int_range(log_max_kb_raw, 64, None)
|
||||
if log_max_kb is None:
|
||||
flash('Max Log Size must be a number >= 64.', 'error')
|
||||
return redirect(_VIEW)
|
||||
|
||||
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)
|
||||
|
||||
core = load_core()
|
||||
core.setdefault('general', {}).update({
|
||||
'log_max_kb': log_max_kb,
|
||||
'log_errors_only': log_errors_only,
|
||||
'dnsmasq_log_queries': dnsmasq_log_queries,
|
||||
})
|
||||
errors = validate.validate_config(core)
|
||||
if errors:
|
||||
for msg in errors:
|
||||
flash(msg, 'error')
|
||||
return redirect(_VIEW)
|
||||
save_core(core)
|
||||
|
||||
flash(queued_msg('core apply'), 'success')
|
||||
return redirect(_VIEW)
|
||||
|
||||
|
||||
@bp.route('/action/general_cardpendingchanges_save', methods=['POST'])
|
||||
@require_level('administrator')
|
||||
def general_cardpendingchanges_save():
|
||||
|
|
@ -51,7 +18,7 @@ def general_cardpendingchanges_save():
|
|||
return redirect(_VIEW)
|
||||
|
||||
core = load_core()
|
||||
core.setdefault('general', {})['apply_on_save'] = 'apply_on_save' in request.form
|
||||
core.setdefault('network_interfaces', {})['apply_on_save'] = 'apply_on_save' in request.form
|
||||
save_core(core)
|
||||
|
||||
flash(queued_msg('core apply'), 'success')
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ def networkinterfaces_cardnetworkinterface_save():
|
|||
return redirect(_VIEW)
|
||||
|
||||
core = load_core()
|
||||
gen = core.setdefault('general', {})
|
||||
gen = core.setdefault('network_interfaces', {})
|
||||
gen['wan_interface'] = wan
|
||||
gen['lan_interface'] = lan
|
||||
errors = validate.validate_config(core)
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ from config_utils import (
|
|||
_seconds_until_next_run, _entry_ts_from_queue,
|
||||
)
|
||||
|
||||
bp = Blueprint('api_apply_status', __name__)
|
||||
bp = Blueprint('api_apply_health', __name__)
|
||||
|
||||
|
||||
@bp.route('/api/apply-status')
|
||||
@bp.route('/api/apply-health')
|
||||
@require_level('viewer')
|
||||
def apply_status():
|
||||
def apply_health():
|
||||
entry_uuid = request.args.get('uuid', '')
|
||||
if not entry_uuid:
|
||||
return jsonify({'status': 'unknown'})
|
||||
|
|
@ -11,7 +11,7 @@ DASHBOARD_DONE = f'{CONFIGS_DIR}/.dashboard-done'
|
|||
DASHBOARD_LAST_RUN = f'{CONFIGS_DIR}/.dashboard-last-run'
|
||||
DASHBOARD_LOCK = f'{CONFIGS_DIR}/.dashboard-lock'
|
||||
DASHBOARD_PENDING = f'{CONFIGS_DIR}/.dashboard-pending'
|
||||
STATUS_FILE = f'{CONFIGS_DIR}/.status'
|
||||
HEALTH_FILE = f'{CONFIGS_DIR}/.health'
|
||||
PRODUCT_NAME = os.environ.get('PRODUCT_NAME', 'routlin')
|
||||
DASHB_TIMER_NAME = f'{PRODUCT_NAME}-dashboard-queue'
|
||||
DDNS_TIMER_NAME = f'{PRODUCT_NAME}-ddns-update'
|
||||
|
|
@ -111,7 +111,7 @@ def _trim_if_needed():
|
|||
|
||||
def _apply_on_save():
|
||||
try:
|
||||
return load_core().get('general', {}).get('apply_on_save', True)
|
||||
return load_core().get('network_interfaces', {}).get('apply_on_save', True)
|
||||
except Exception:
|
||||
return True
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from action_apply_mdns import bp as action_apply_mdns_bp
|
|||
from action_apply_vpn import bp as action_apply_vpn_bp
|
||||
from action_apply_banned_ips import bp as action_apply_banned_ips_bp
|
||||
from action_apply_host_overrides import bp as action_apply_host_overrides_bp
|
||||
from action_dnsblocklists import bp as action_dnsblocklists_bp
|
||||
from action_dnsblocking import bp as action_dnsblocking_bp
|
||||
from action_apply_vlans import bp as action_apply_vlans_bp
|
||||
from action_apply_inter_vlan import bp as action_apply_inter_vlan_bp
|
||||
from action_apply_port_forwarding import bp as action_apply_port_forwarding_bp
|
||||
|
|
@ -22,7 +22,7 @@ from action_delete_account import bp as action_delete_account_bp
|
|||
from action_save_preferences import bp as action_save_preferences_bp
|
||||
from action_change_password import bp as action_change_password_bp
|
||||
from action_ddns import bp as action_ddns_bp
|
||||
from api_apply_status import bp as api_apply_status_bp
|
||||
from api_apply_health import bp as api_apply_health_bp
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = os.environ.get('SECRET_KEY', os.urandom(24))
|
||||
|
|
@ -34,7 +34,7 @@ app.register_blueprint(action_apply_mdns_bp)
|
|||
app.register_blueprint(action_apply_vpn_bp)
|
||||
app.register_blueprint(action_apply_banned_ips_bp)
|
||||
app.register_blueprint(action_apply_host_overrides_bp)
|
||||
app.register_blueprint(action_dnsblocklists_bp)
|
||||
app.register_blueprint(action_dnsblocking_bp)
|
||||
app.register_blueprint(action_apply_vlans_bp)
|
||||
app.register_blueprint(action_apply_inter_vlan_bp)
|
||||
app.register_blueprint(action_apply_port_forwarding_bp)
|
||||
|
|
@ -48,7 +48,7 @@ app.register_blueprint(action_delete_account_bp)
|
|||
app.register_blueprint(action_save_preferences_bp)
|
||||
app.register_blueprint(action_change_password_bp)
|
||||
app.register_blueprint(action_ddns_bp)
|
||||
app.register_blueprint(api_apply_status_bp)
|
||||
app.register_blueprint(api_apply_health_bp)
|
||||
|
||||
def _seed_initial_account():
|
||||
email = os.environ.get('INITIAL_MANAGER_EMAIL', '').strip().lower()
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ def _resolve_iface(vlan, core):
|
|||
))
|
||||
idx = next((i for i, v in enumerate(wg_sorted) if v is vlan), 0)
|
||||
return f'wg{idx}'
|
||||
lan = core.get('general', {}).get('lan_interface', 'eth0')
|
||||
lan = core.get('network_interfaces', {}).get('lan_interface', 'eth0')
|
||||
vid = validate.derive_vlan_id(vlan.get('subnet', ''), vlan.get('subnet_mask', 24)) or 1
|
||||
return lan if vid == 1 else f'{lan}.{vid}'
|
||||
|
||||
|
|
@ -258,7 +258,7 @@ def _config_datasource(name):
|
|||
vlans = core.get('vlans', [])
|
||||
|
||||
if name == 'interfaces':
|
||||
gen = core.get('general', {})
|
||||
gen = core.get('network_interfaces', {})
|
||||
wan = gen.get('wan_interface', '')
|
||||
lan = gen.get('lan_interface', '')
|
||||
return [
|
||||
|
|
@ -274,7 +274,7 @@ def _config_datasource(name):
|
|||
|
||||
if name == 'blocklists':
|
||||
rows = []
|
||||
for bl in core.get('blocklists', []):
|
||||
for bl in core.get('dns_blocking', {}).get('blocklists', []):
|
||||
row = dict(bl)
|
||||
bl_path = f'{CONFIGS_DIR}/blocklists/{bl.get("save_as", "")}'
|
||||
try:
|
||||
|
|
@ -288,7 +288,7 @@ def _config_datasource(name):
|
|||
return rows
|
||||
|
||||
if name == 'vlans':
|
||||
bl_desc = {b['name']: b.get('description', b['name']) for b in core.get('blocklists', []) if 'name' in b}
|
||||
bl_desc = {b['name']: b.get('description', b['name']) for b in core.get('dns_blocking', {}).get('blocklists', []) if 'name' in b}
|
||||
rows = []
|
||||
for v in sorted(vlans, key=lambda x: validate.derive_vlan_id(x.get('subnet', ''), x.get('subnet_mask', 24)) or 0):
|
||||
row = {k: v.get(k) for k in ('name', 'subnet', 'subnet_mask', 'radius_default', 'mdns_reflection', 'is_vpn')}
|
||||
|
|
@ -421,7 +421,7 @@ def _bl_last_update():
|
|||
def _blocklist_stats_html(core):
|
||||
bl_dir = f'{CONFIGS_DIR}/blocklists'
|
||||
rows = ''
|
||||
for bl in core.get('blocklists', []):
|
||||
for bl in core.get('dns_blocking', {}).get('blocklists', []):
|
||||
name = e(bl.get('name', ''))
|
||||
save_as = bl.get('save_as', '')
|
||||
bl_path = f'{bl_dir}/{save_as}' if save_as else ''
|
||||
|
|
@ -557,18 +557,19 @@ def _vpn_info():
|
|||
def collect_tokens():
|
||||
tokens = {}
|
||||
core = _load_core()
|
||||
gen = core.get('general', {})
|
||||
net = core.get('network_interfaces', {})
|
||||
dns_blk_gen = core.get('dns_blocking', {}).get('general', {})
|
||||
dns = core.get('upstream_dns', {})
|
||||
vlans = core.get('vlans', [])
|
||||
tokens['GENERAL_WAN_INTERFACE'] = str(gen.get('wan_interface', '-'))
|
||||
tokens['GENERAL_LAN_INTERFACE'] = str(gen.get('lan_interface', '-'))
|
||||
tokens['GENERAL_WAN_STATUS'] = _iface_status(gen.get('wan_interface', ''))
|
||||
tokens['GENERAL_LAN_STATUS'] = _iface_status(gen.get('lan_interface', ''))
|
||||
tokens['GENERAL_LOG_MAX_KB'] = str(gen.get('log_max_kb', '-'))
|
||||
tokens['GENERAL_WAN_INTERFACE'] = str(net.get('wan_interface', '-'))
|
||||
tokens['GENERAL_LAN_INTERFACE'] = str(net.get('lan_interface', '-'))
|
||||
tokens['GENERAL_WAN_STATUS'] = _iface_status(net.get('wan_interface', ''))
|
||||
tokens['GENERAL_LAN_STATUS'] = _iface_status(net.get('lan_interface', ''))
|
||||
tokens['GENERAL_LOG_MAX_KB'] = str(dns_blk_gen.get('log_max_kb', '-'))
|
||||
|
||||
sys_ifaces = _get_system_interfaces()
|
||||
# Always include currently-configured values so dropdowns are never blank.
|
||||
for configured in [gen.get('wan_interface', ''), gen.get('lan_interface', '')]:
|
||||
for configured in [net.get('wan_interface', ''), net.get('lan_interface', '')]:
|
||||
if configured and configured not in sys_ifaces:
|
||||
sys_ifaces.append(configured)
|
||||
sys_ifaces.sort()
|
||||
|
|
@ -586,10 +587,10 @@ def collect_tokens():
|
|||
)
|
||||
tokens['NETWORK_INTERFACE_STATS_SPEED_PAD'] = str(max(max_speed_len, len('Speed')))
|
||||
|
||||
tokens['GENERAL_LOG_ERRORS_ONLY'] = 'true' if gen.get('log_errors_only') else 'false'
|
||||
tokens['GENERAL_DNSMASQ_LOG_QUERIES'] = 'true' if gen.get('dnsmasq_log_queries') else 'false'
|
||||
tokens['GENERAL_DAILY_EXECUTE_TIME'] = str(gen.get('daily_execute_time_24hr_local', '-'))
|
||||
tokens['GENERAL_APPLY_ON_SAVE'] = 'true' if gen.get('apply_on_save', True) else 'false'
|
||||
tokens['GENERAL_LOG_ERRORS_ONLY'] = 'true' if dns_blk_gen.get('log_errors_only') else 'false'
|
||||
tokens['GENERAL_DNSMASQ_LOG_QUERIES'] = 'true' if net.get('dnsmasq_log_queries') else 'false'
|
||||
tokens['GENERAL_DAILY_EXECUTE_TIME'] = str(dns_blk_gen.get('daily_execute_time_24hr_local', '-'))
|
||||
tokens['GENERAL_APPLY_ON_SAVE'] = 'true' if net.get('apply_on_save', True) else 'false'
|
||||
|
||||
pending_items = get_dashboard_pending()
|
||||
if pending_items:
|
||||
|
|
@ -645,7 +646,7 @@ def collect_tokens():
|
|||
tokens['EXISTING_VLAN_NAMES_JSON'] = json.dumps([v.get('name', '') for v in vlans])
|
||||
tokens['EXISTING_VLAN_INTERFACES_JSON'] = json.dumps([_resolve_iface(v, core) for v in vlans])
|
||||
tokens['STAT_BANNED_IP_COUNT'] = str(sum(1 for b in core.get('banned_ips', []) if b.get('enabled', True)))
|
||||
tokens['STAT_BLOCKLIST_COUNT'] = str(len(core.get('blocklists', [])))
|
||||
tokens['STAT_BLOCKLIST_COUNT'] = str(len(core.get('dns_blocking', {}).get('blocklists', [])))
|
||||
tokens['BLOCKLIST_STATS_HTML'] = _blocklist_stats_html(core)
|
||||
|
||||
ddns = _load_ddns()
|
||||
|
|
@ -745,7 +746,7 @@ def collect_tokens():
|
|||
|
||||
tokens['BLOCKLIST_NAME_OPTIONS'] = json.dumps([
|
||||
{'value': bl.get('name', ''), 'label': bl.get('description', bl.get('name', ''))}
|
||||
for bl in core.get('blocklists', [])
|
||||
for bl in core.get('dns_blocking', {}).get('blocklists', [])
|
||||
])
|
||||
|
||||
tokens['ACCOUNT_LEVEL_OPTIONS'] = json.dumps([
|
||||
|
|
@ -1542,7 +1543,7 @@ def render_layout(view_id, content_html, tokens):
|
|||
problem_bars = ''
|
||||
try:
|
||||
import json as _j
|
||||
st = _j.load(open(f'{CONFIGS_DIR}/.status'))
|
||||
st = _j.load(open(f'{CONFIGS_DIR}/.health'))
|
||||
grouped = {'error': [], 'warning': []}
|
||||
for section in ('configurations', 'logs'):
|
||||
for item in st.get(section, []):
|
||||
|
|
@ -2449,7 +2450,7 @@ function startApplyPoller(uuid, bar, mine) {
|
|||
}
|
||||
|
||||
function doPoll() {
|
||||
fetch('/api/apply-status?uuid=' + encodeURIComponent(uuid))
|
||||
fetch('/api/apply-health?uuid=' + encodeURIComponent(uuid))
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(onStatus)
|
||||
.catch(function() { pollTimer = setTimeout(doPoll, 3000); });
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
{ "type": "nav_item", "label": "General", "map_to": "view_general", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "Network Interfaces", "map_to": "view_network_interfaces", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "Upstream DNS", "map_to": "view_upstream_dns", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "DNS Blocklists", "map_to": "view_dns_blocklists", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "DNS Blocking", "map_to": "view_dns_blocking", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "VLANs", "map_to": "view_vlans", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "Inter-VLAN Exceptions", "map_to": "view_inter_vlan", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "Port Forwarding", "map_to": "view_port_forwarding", "client_requirement": "client_is_administrator+" },
|
||||
|
|
|
|||
|
|
@ -317,10 +317,10 @@
|
|||
},
|
||||
{
|
||||
"type": "stat_card",
|
||||
"label": "Check Interval",
|
||||
"label": "IP Check Interval",
|
||||
"value": "%DDNS_TIMER_INTERVAL%",
|
||||
"sub": "%STAT_PUBLIC_IP_LAST_CHECKED%",
|
||||
"edit_action": "/action/ddns_cardcheckinterval_save",
|
||||
"edit_action": "/action/ddns_cardipcheckinterval_save",
|
||||
"edit_field": "timer_interval",
|
||||
"edit_input_type": "number",
|
||||
"edit_min": "1",
|
||||
|
|
@ -509,7 +509,7 @@
|
|||
},
|
||||
{
|
||||
"type": "card",
|
||||
"label": "DDNS Log",
|
||||
"label": "Logging",
|
||||
"client_requirement": "client_is_administrator+",
|
||||
"items": [
|
||||
{
|
||||
|
|
@ -527,12 +527,12 @@
|
|||
"items": [
|
||||
{
|
||||
"type": "button_ghost",
|
||||
"action": "/action/ddns_cardddnslog_download",
|
||||
"action": "/action/ddns_cardlogging_download",
|
||||
"text": "Download Log"
|
||||
},
|
||||
{
|
||||
"type": "button_danger",
|
||||
"action": "/action/ddns_cardddnslog_clear",
|
||||
"action": "/action/ddns_cardlogging_clear",
|
||||
"method": "post",
|
||||
"text": "Clear Log"
|
||||
}
|
||||
|
|
@ -543,7 +543,7 @@
|
|||
},
|
||||
{
|
||||
"type": "form",
|
||||
"action": "/action/ddns_cardddnslog_save",
|
||||
"action": "/action/ddns_cardlogging_save",
|
||||
"method": "post",
|
||||
"items": [
|
||||
{
|
||||
|
|
@ -568,7 +568,7 @@
|
|||
"items": [
|
||||
{
|
||||
"type": "button_primary",
|
||||
"action": "/action/ddns_cardddnslog_save",
|
||||
"action": "/action/ddns_cardlogging_save",
|
||||
"method": "post",
|
||||
"text": "Save"
|
||||
},
|
||||
|
|
@ -601,60 +601,6 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "card",
|
||||
"label": "Logging",
|
||||
"client_requirement": "client_is_administrator+",
|
||||
"items": [
|
||||
{
|
||||
"type": "form",
|
||||
"action": "/action/general_cardlogging_save",
|
||||
"method": "post",
|
||||
"items": [
|
||||
{
|
||||
"type": "field",
|
||||
"label": "Max Log Size (KB)",
|
||||
"name": "log_max_kb",
|
||||
"input_type": "number",
|
||||
"value": "%GENERAL_LOG_MAX_KB%",
|
||||
"min": 64,
|
||||
"hint": "Log is cleared and restarted when it exceeds this size."
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"label": "Errors Only",
|
||||
"name": "log_errors_only",
|
||||
"input_type": "checkbox",
|
||||
"value": "%GENERAL_LOG_ERRORS_ONLY%",
|
||||
"hint": "Only write error-level messages to the log."
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"label": "Log DNS Queries",
|
||||
"name": "dnsmasq_log_queries",
|
||||
"input_type": "checkbox",
|
||||
"value": "%GENERAL_DNSMASQ_LOG_QUERIES%",
|
||||
"hint": "Log every DNS query. High volume \u2014 enable for debugging only."
|
||||
},
|
||||
{
|
||||
"type": "button_row",
|
||||
"items": [
|
||||
{
|
||||
"type": "button_primary",
|
||||
"action": "/action/general_cardlogging_save",
|
||||
"method": "post",
|
||||
"text": "Save"
|
||||
},
|
||||
{
|
||||
"type": "button_cancel",
|
||||
"text": "Cancel"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "card",
|
||||
"label": "Pending Changes",
|
||||
|
|
@ -858,7 +804,10 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{ "type": "raw_html", "html": "<br /><br /><br /><br /><br />" }
|
||||
{
|
||||
"type": "raw_html",
|
||||
"html": "<br /><br /><br /><br /><br />"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -1191,7 +1140,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"id": "view_dns_blocklists",
|
||||
"id": "view_dns_blocking",
|
||||
"client_requirement": "client_is_viewer+",
|
||||
"items": [
|
||||
{
|
||||
|
|
@ -1199,7 +1148,7 @@
|
|||
"items": [
|
||||
{
|
||||
"type": "h1",
|
||||
"text": "DNS Blocklists"
|
||||
"text": "DNS Blocking"
|
||||
},
|
||||
{
|
||||
"type": "p",
|
||||
|
|
@ -1207,6 +1156,60 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "card",
|
||||
"label": "Logging",
|
||||
"client_requirement": "client_is_administrator+",
|
||||
"items": [
|
||||
{
|
||||
"type": "form",
|
||||
"action": "/action/dnsblocking_cardlogging_save",
|
||||
"method": "post",
|
||||
"items": [
|
||||
{
|
||||
"type": "field",
|
||||
"label": "Max Log Size (KB)",
|
||||
"name": "log_max_kb",
|
||||
"input_type": "number",
|
||||
"value": "%GENERAL_LOG_MAX_KB%",
|
||||
"min": 64,
|
||||
"hint": "Log is cleared and restarted when it exceeds this size."
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"label": "Errors Only",
|
||||
"name": "log_errors_only",
|
||||
"input_type": "checkbox",
|
||||
"value": "%GENERAL_LOG_ERRORS_ONLY%",
|
||||
"hint": "Only write error-level messages to the log."
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"label": "Log DNS Queries",
|
||||
"name": "dnsmasq_log_queries",
|
||||
"input_type": "checkbox",
|
||||
"value": "%GENERAL_DNSMASQ_LOG_QUERIES%",
|
||||
"hint": "Log every DNS query. High volume \u2014 enable for debugging only."
|
||||
},
|
||||
{
|
||||
"type": "button_row",
|
||||
"items": [
|
||||
{
|
||||
"type": "button_primary",
|
||||
"action": "/action/dnsblocking_cardlogging_save",
|
||||
"method": "post",
|
||||
"text": "Save"
|
||||
},
|
||||
{
|
||||
"type": "button_cancel",
|
||||
"text": "Cancel"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "table",
|
||||
"datasource": "config:blocklists",
|
||||
|
|
@ -1234,7 +1237,7 @@
|
|||
"row_actions": [
|
||||
{
|
||||
"client_requirement": "client_is_administrator+",
|
||||
"action": "/action/dnsblocklists_tableblocklists_rowedit",
|
||||
"action": "/action/dnsblocking_tableblocklists_rowedit",
|
||||
"method": "inline_edit",
|
||||
"text": "Edit",
|
||||
"class": "btn-ghost btn-sm",
|
||||
|
|
@ -1262,7 +1265,7 @@
|
|||
},
|
||||
{
|
||||
"client_requirement": "client_is_administrator+",
|
||||
"action": "/action/dnsblocklists_tableblocklists_rowdelete",
|
||||
"action": "/action/dnsblocking_tableblocklists_rowdelete",
|
||||
"method": "post",
|
||||
"text": "Delete",
|
||||
"class": "btn-danger btn-sm"
|
||||
|
|
@ -1277,7 +1280,7 @@
|
|||
"items": [
|
||||
{
|
||||
"type": "form",
|
||||
"action": "/action/dnsblocklists_cardaddblocklist_add",
|
||||
"action": "/action/dnsblocking_cardaddblocklist_add",
|
||||
"method": "post",
|
||||
"items": [
|
||||
{
|
||||
|
|
@ -1315,7 +1318,7 @@
|
|||
"items": [
|
||||
{
|
||||
"type": "button_primary",
|
||||
"action": "/action/dnsblocklists_cardaddblocklist_add",
|
||||
"action": "/action/dnsblocking_cardaddblocklist_add",
|
||||
"method": "post",
|
||||
"text": "Add Blocklist"
|
||||
},
|
||||
|
|
@ -1347,7 +1350,7 @@
|
|||
"items": [
|
||||
{
|
||||
"type": "button_secondary",
|
||||
"action": "/action/dnsblocklists_cardblocklistrefresh_refresh",
|
||||
"action": "/action/dnsblocking_cardblocklistrefresh_refreshnow",
|
||||
"method": "post",
|
||||
"text": "Refresh All Now"
|
||||
}
|
||||
|
|
@ -1359,7 +1362,7 @@
|
|||
},
|
||||
{
|
||||
"type": "form",
|
||||
"action": "/action/dnsblocklists_cardblocklistrefresh_save",
|
||||
"action": "/action/dnsblocking_cardblocklistrefresh_save",
|
||||
"method": "post",
|
||||
"items": [
|
||||
{
|
||||
|
|
@ -1377,7 +1380,7 @@
|
|||
"items": [
|
||||
{
|
||||
"type": "button_primary",
|
||||
"action": "/action/dnsblocklists_cardblocklistrefresh_save",
|
||||
"action": "/action/dnsblocking_cardblocklistrefresh_save",
|
||||
"method": "post",
|
||||
"text": "Save"
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue