diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/ServiceController.php b/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/ServiceController.php index d3cfa889f..1da1f0a70 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/ServiceController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/ServiceController.php @@ -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 diff --git a/src/opnsense/mvc/app/views/OPNsense/Proxy/index.volt b/src/opnsense/mvc/app/views/OPNsense/Proxy/index.volt index 9249dbcc9..af45ec130 100644 --- a/src/opnsense/mvc/app/views/OPNsense/Proxy/index.volt +++ b/src/opnsense/mvc/app/views/OPNsense/Proxy/index.volt @@ -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 @@
  • {{ lang._('Remote Access Control Lists') }}
  • +
  • {{ lang._('Support') }}
  • @@ -442,6 +470,26 @@
    +
    + + + + + + + + + + + + + +
    {{ lang._('Action')}}
    + + + {{ lang._('Reset all generated content (cached files and certificates included) and restart the proxy.') }} +
    +
    {{ partial("layout_partials/base_dialog",['fields':formDialogEditBlacklist,'id':'DialogEditBlacklist','label':lang._('Edit blacklist')])}} diff --git a/src/opnsense/service/conf/actions.d/actions_proxy.conf b/src/opnsense/service/conf/actions.d/actions_proxy.conf index 660b09ffb..66cb28368 100644 --- a/src/opnsense/service/conf/actions.d/actions_proxy.conf +++ b/src/opnsense/service/conf/actions.d/actions_proxy.conf @@ -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;