Development
This commit is contained in:
parent
49dd4a2cf8
commit
e33133df1e
9 changed files with 412 additions and 414 deletions
|
|
@ -619,10 +619,10 @@ def run_apply():
|
|||
pass
|
||||
|
||||
|
||||
def run_update_blocklists():
|
||||
def run_merge_blocklists():
|
||||
try:
|
||||
subprocess.run(
|
||||
['python3', f'{CONFIGS_DIR}/core.py', '--update-blocklists'],
|
||||
['python3', f'{CONFIGS_DIR}/core.py', '--merge-blocklists'],
|
||||
capture_output=True, timeout=120
|
||||
)
|
||||
except Exception:
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import config_utils
|
|||
import sanitize
|
||||
import mod_validation as validate
|
||||
|
||||
DNS_LOG_FILE = Path(config_utils.CONFIGS_DIR) / 'dns-blocklists.log'
|
||||
DNS_LOG_FILE = Path(config_utils.CONFIGS_DIR) / 'blocklists.log'
|
||||
|
||||
_PAGE = Path(__file__).parent.name
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ def blocklists_delete():
|
|||
flash(msg, 'error')
|
||||
return redirect(f'/{_PAGE}')
|
||||
changes = config_utils.diff_fields(before, None)
|
||||
flash(config_utils.record_group(cfg, 'dns_blocking.blocklists', 'name', name, changes, 'core apply', queue=False), 'success')
|
||||
flash(config_utils.record_group(cfg, 'dns_blocking.blocklists', 'name', name, changes, 'merge blocklists'), 'success')
|
||||
return redirect(f'/{_PAGE}')
|
||||
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ def blocklists_edit():
|
|||
flash(msg, 'error')
|
||||
return redirect(f'/{_PAGE}')
|
||||
changes = config_utils.diff_fields(before, items[idx])
|
||||
flash(config_utils.record_group(cfg, 'dns_blocking.blocklists', 'name', fields['name'], changes, 'core apply', queue=False), 'success')
|
||||
flash(config_utils.record_group(cfg, 'dns_blocking.blocklists', 'name', fields['name'], changes, 'merge blocklists'), 'success')
|
||||
return redirect(f'/{_PAGE}')
|
||||
|
||||
|
||||
|
|
@ -239,7 +239,7 @@ def addblocklist_add():
|
|||
flash(msg, 'error')
|
||||
return redirect(f'/{_PAGE}')
|
||||
changes = config_utils.diff_fields(None, entry)
|
||||
flash(config_utils.record_group(cfg, 'dns_blocking.blocklists', 'name', fields['name'], changes, 'core apply', queue=False), 'success')
|
||||
flash(config_utils.record_group(cfg, 'dns_blocking.blocklists', 'name', fields['name'], changes, 'merge blocklists'), 'success')
|
||||
return redirect(f'/{_PAGE}')
|
||||
|
||||
|
||||
|
|
@ -267,7 +267,9 @@ def blocklistrefresh_save():
|
|||
@bp.route('/action/dnsblocking/blocklistrefresh_refresh', methods=['POST'])
|
||||
@auth.require_level('administrator')
|
||||
def blocklistrefresh_refresh():
|
||||
flash(config_utils.queued_msg('core update-blocklists', action_label='Blocklist refresh queued'), 'success')
|
||||
config_utils.queue_command('download blocklists')
|
||||
config_utils.queue_command('merge blocklists')
|
||||
flash('Blocklist download and merge queued.', 'success')
|
||||
return redirect(f'/{_PAGE}')
|
||||
|
||||
|
||||
|
|
@ -319,4 +321,4 @@ def logging_download():
|
|||
if not DNS_LOG_FILE.is_file():
|
||||
flash('Log file not found.', 'error')
|
||||
return redirect(f'/{_PAGE}')
|
||||
return send_file(DNS_LOG_FILE, as_attachment=True, download_name='dns-blocklists.log', mimetype='text/plain')
|
||||
return send_file(DNS_LOG_FILE, as_attachment=True, download_name='blocklists.log', mimetype='text/plain')
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from datetime import datetime, timezone
|
|||
import config_utils
|
||||
import factory
|
||||
|
||||
DNS_LOG_FILE = f'{config_utils.CONFIGS_DIR}/dns-blocklists.log'
|
||||
DNS_LOG_FILE = f'{config_utils.CONFIGS_DIR}/blocklists.log'
|
||||
DNS_LOG_MAX = 50
|
||||
|
||||
BL_TYPE_LABELS = {'community': 'Community', 'local': 'Local'}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue