mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 17:14:46 +00:00
Services: Unbound DNS: DNS over TLS - minor improvements to handle "Dot" endpoints and make sure the page actually calls them cc @swhite2
Some small fixes to prevent referer magic to determine he dot endpoint (searchDotAction, getDotAction, ...), since __call() will only be triggered for non existing endpoints (https://www.php.net/manual/en/language.oop5.overloading.php#object.call), we need to set the default to the methods that do exist. Next we can filter and change the target accordingly. The volt template should figure out where it lives, we could have passed this in the ui controller as well, but as these are only two templates and a single page, javascript will do.
This commit is contained in:
parent
0da84ef19f
commit
f4081dfcdf
@ -38,7 +38,7 @@ class SettingsController extends ApiMutableModelControllerBase
|
||||
protected static $internalModelClass = '\OPNsense\Unbound\Unbound';
|
||||
protected static $internalModelName = 'unbound';
|
||||
|
||||
private $type = 'dot';
|
||||
private $type = 'forward';
|
||||
|
||||
public function updateBlocklistAction()
|
||||
{
|
||||
@ -108,17 +108,14 @@ class SettingsController extends ApiMutableModelControllerBase
|
||||
/*
|
||||
* Catch all Dot API endpoints and redirect them to Forward for
|
||||
* backwards compatibility and infer the type from the request.
|
||||
* If no type is provided, default to dot.
|
||||
* If no type is provided, default to forward (__call only triggers on non-existing methods).
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
if (substr($method, -6) == 'Action') {
|
||||
$fn = preg_replace('/Dot/', 'Forward', $method);
|
||||
if (method_exists(get_class($this), $fn)) {
|
||||
// set the type to forward if the request came from the corresponding gui page or is explicitly set in the API call
|
||||
if (preg_match("/forward/i", $this->request->getHTTPReferer()) || ($this->request->getPost('dot') && $this->request->getPost('dot')['type'] == 'forward')) {
|
||||
$this->type = "forward";
|
||||
}
|
||||
if (method_exists(get_class($this), $fn) && preg_match("/.*dot/i", $method)) {
|
||||
$this->type = "dot";
|
||||
return $this->$fn(...$args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
<script>
|
||||
|
||||
$( document ).ready(function() {
|
||||
let this_page = window.location.href.replace(/[/]/g, '').toLowerCase().endsWith('forward') ? 'Forward' : 'Dot';
|
||||
$('tr[id="row_unbound.forwarding.info"]').addClass('hidden');
|
||||
/* Handle retrieval and saving of the single system forwarding checkbox */
|
||||
let data_get_map = {'frm_ForwardingSettings':"/api/unbound/settings/get"};
|
||||
@ -75,8 +76,8 @@
|
||||
*/
|
||||
function openDialog(uuid) {
|
||||
var editDlg = "DialogEdit";
|
||||
var setUrl = "/api/unbound/settings/setDot/";
|
||||
var getUrl = "/api/unbound/settings/getDot/";
|
||||
var setUrl = "/api/unbound/settings/set"+this_page+"/";
|
||||
var getUrl = "/api/unbound/settings/get"+this_page+"/";
|
||||
var urlMap = {};
|
||||
urlMap['frm_' + editDlg] = getUrl + uuid;
|
||||
mapDataToFormUI(urlMap).done(function () {
|
||||
@ -110,12 +111,12 @@
|
||||
*************************************************************************************************************/
|
||||
|
||||
$("#grid-dot").UIBootgrid(
|
||||
{ 'search':'/api/unbound/settings/searchDot/',
|
||||
'get':'/api/unbound/settings/getDot/',
|
||||
'set':'/api/unbound/settings/setDot/',
|
||||
'add':'/api/unbound/settings/addDot/',
|
||||
'del':'/api/unbound/settings/delDot/',
|
||||
'toggle':'/api/unbound/settings/toggleDot/'
|
||||
{ 'search':'/api/unbound/settings/search'+this_page+'/',
|
||||
'get':'/api/unbound/settings/get'+this_page+'/',
|
||||
'set':'/api/unbound/settings/set'+this_page+'/',
|
||||
'add':'/api/unbound/settings/add'+this_page+'/',
|
||||
'del':'/api/unbound/settings/del'+this_page+'/',
|
||||
'toggle':'/api/unbound/settings/toggle'+this_page+'/'
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user