mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 09:04:39 +00:00
Unbound blocklists / OPNsense UI: strengthen error handling (#5761)
* Unbound blocklists / OPNsense UI: strengthen error handling Also changes the OPNsense UI error handling routine to display a 'status_msg' if provided. Otherwise just display 'status' to preserve backwards compatibility.
This commit is contained in:
parent
73a062c6cb
commit
1f1502acf4
@ -48,12 +48,16 @@ class ServiceController extends ApiMutableServiceControllerBase
|
||||
if ($response !== null) {
|
||||
$response['status'] = "OK";
|
||||
$response['status_msg'] = sprintf(
|
||||
gettext("Added %d and removed %d resource records."),
|
||||
gettext("Added %d and removed %d resource records."),
|
||||
$response['additions'],
|
||||
$response['removals']
|
||||
);
|
||||
return $response;
|
||||
}
|
||||
return array('message' => 'unable to run configd action');
|
||||
|
||||
return array(
|
||||
'status' => 'ERR',
|
||||
'status_msg' => gettext('An error occurred during script execution. Check the logs for details'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,7 +42,9 @@
|
||||
return dfObj;
|
||||
},
|
||||
onAction: function(data, status) {
|
||||
$("#responseMsg").removeClass("hidden").html(data['status_msg']);
|
||||
if (data['status'].toLowerCase().trim() == 'ok') {
|
||||
$("#responseMsg").removeClass("hidden").html(data['status_msg']);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -48,7 +48,9 @@ def unbound_control_do(action, bulk_input):
|
||||
for input in bulk_input:
|
||||
p.stdin.write("%s\n" % input)
|
||||
|
||||
return p.communicate()[0]
|
||||
result = p.communicate()[0]
|
||||
# return code is only available after communicate()
|
||||
return (result, p.returncode)
|
||||
|
||||
# parse arguments
|
||||
parser = argparse.ArgumentParser()
|
||||
@ -87,10 +89,14 @@ if args.dnsbl:
|
||||
# RR removals only accept domain names, so strip it again (xxx.xx 0.0.0.0 --> xxx.xx)
|
||||
removals = {line.split(' ')[0].strip() for line in removals}
|
||||
uc = unbound_control_do('local_datas_remove', removals)
|
||||
syslog.syslog(syslog.LOG_NOTICE, 'unbound-control returned: %s' % uc)
|
||||
syslog.syslog(syslog.LOG_NOTICE, 'unbound-control returned: %s' % uc[0])
|
||||
if uc[1] is not 0:
|
||||
sys.exit(1)
|
||||
if additions:
|
||||
uc = unbound_control_do('local_datas', additions)
|
||||
syslog.syslog(syslog.LOG_NOTICE, 'unbound-control returned: %s' % uc)
|
||||
syslog.syslog(syslog.LOG_NOTICE, 'unbound-control returned: %s' % uc[0])
|
||||
if uc[1] is not 0:
|
||||
sys.exit(1)
|
||||
|
||||
output = {'additions': len(additions), 'removals': len(removals)}
|
||||
|
||||
|
||||
@ -575,7 +575,7 @@ $.fn.SimpleActionButton = function (params) {
|
||||
BootstrapDialog.show({
|
||||
type: BootstrapDialog.TYPE_WARNING,
|
||||
title: this_button.data('error-title'),
|
||||
message: data['status'],
|
||||
message: data['status_msg'] ? data['status_msg'] : data['status'],
|
||||
draggable: true
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user