Proxy, add support tab with reset button, which clears all stored cache data and restarts squid. Since a squid stop can take long and consistency isn't very important on files bound to be deleted, its faster to killall -9. closes https://github.com/opnsense/core/issues/3545

This commit is contained in:
Ad Schellevis 2019-06-20 13:03:48 +02:00
parent b62b34fe64
commit cdaa275fff
3 changed files with 77 additions and 0 deletions

View File

@ -56,6 +56,23 @@ class ServiceController extends ApiMutableServiceControllerBase
(!empty((string)$mdlProxy->general->cache->local->enabled) != $prev_cache_active);
}
/**
* reload template only (for example PAC does not need to change squid configuration)
* @return array
*/
public function resetAction()
{
if ($this->request->isPost()) {
// close session for long running action
$this->sessionClose();
$backend = new Backend();
return array('status' => $backend->configdRun('proxy reset'));
} else {
return array('error' => 'This API endpoint must be called via POST',
'status' => 'error');
}
}
/**
* reload template only (for example PAC does not need to change squid configuration)
* @return array

View File

@ -268,6 +268,33 @@
});
});
$("#resetAct").click(function() {
BootstrapDialog.show({
type:BootstrapDialog.TYPE_DANGER,
title: '{{ lang._('Reset') }} ',
message: '{{ lang._('Are you sure you want to flush all generated content and restart the proxy?') }}',
buttons: [{
label: '{{ lang._('Yes') }}',
cssClass: 'btn-primary',
action: function(dlg){
dlg.close();
$("#resetAct_progress").addClass("fa fa-spinner fa-pulse");
ajaxCall("/api/proxy/service/reset", {}, function(data,status) {
$("#resetAct_progress").removeClass("fa fa-spinner fa-pulse");
updateServiceControlUI('proxy');
});
}
}, {
label: '{{ lang._('No') }}',
action: function(dlg){
dlg.close();
}
}]
});
});
// update history on tab state and implement navigation
if(window.location.hash != "") {
$('a[href="' + window.location.hash + '"]').click()
@ -301,6 +328,7 @@
</ul>
</li>
<li><a data-toggle="tab" href="#remote_acls"><b>{{ lang._('Remote Access Control Lists') }}</b></a></li>
<li><a data-toggle="tab" href="#support"><b>{{ lang._('Support') }}</b></a></li>
</ul>
<div class="content-box tab-content">
@ -442,6 +470,26 @@
</tbody>
</table>
</div>
<div id="support" class="tab-pane fade">
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>{{ lang._('Action')}}</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<button class="btn btn-primary" id="resetAct" type="button">{{ lang._('Reset') }}<i id="resetAct_progress" class=""></button>
</td>
<td>
{{ lang._('Reset all generated content (cached files and certificates included) and restart the proxy.') }}
</td>
</tr>
</tbody>
</table>
</div>
</div>
{{ partial("layout_partials/base_dialog",['fields':formDialogEditBlacklist,'id':'DialogEditBlacklist','label':lang._('Edit blacklist')])}}

View File

@ -26,6 +26,18 @@ parameters:
type:script
message:restarting proxy
[reset]
command:
/usr/bin/killall -9 squid;
rm /var/run/squid/squid.pid;
rm -rf /var/squid/*;
/usr/local/opnsense/scripts/proxy/setup.sh;
/usr/local/sbin/pluginctl webproxy start;
/usr/local/etc/rc.d/squid start
parameters:
type:script
message:reset and restart proxy
[reload]
command:
/usr/local/sbin/pluginctl webproxy reload;