mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
dns/dnscryptproxy: add manual server selection (#1077)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
PLUGIN_NAME= dnscrypt-proxy
|
||||
PLUGIN_VERSION= 1.0
|
||||
PLUGINS_REVISION= 1
|
||||
PLUGIN_VERSION= 1.1
|
||||
PLUGIN_COMMENT= Flexible DNS proxy supporting DNSCrypt and DoH
|
||||
PLUGIN_DEPENDS= dnscrypt-proxy2
|
||||
PLUGIN_MAINTAINER= m.muenz@gmail.com
|
||||
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2018 Michael Muenz <m.muenz@gmail.com>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OPNsense\Dnscryptproxy\Api;
|
||||
|
||||
use \OPNsense\Base\ApiMutableModelControllerBase;
|
||||
use \OPNsense\Core\Backend;
|
||||
|
||||
class ServerController extends ApiMutableModelControllerBase
|
||||
{
|
||||
static protected $internalModelName = 'server';
|
||||
static protected $internalModelClass = '\OPNsense\Dnscryptproxy\Server';
|
||||
|
||||
public function searchServerAction()
|
||||
{
|
||||
return $this->searchBase('servers.server', array("enabled", "name", "stamp"));
|
||||
}
|
||||
public function getServerAction($uuid = null)
|
||||
{
|
||||
$this->sessionClose();
|
||||
return $this->getBase('server', 'servers.server', $uuid);
|
||||
}
|
||||
public function addServerAction()
|
||||
{
|
||||
return $this->addBase('server', 'servers.server');
|
||||
}
|
||||
public function delServerAction($uuid)
|
||||
{
|
||||
return $this->delBase('servers.server', $uuid);
|
||||
}
|
||||
public function setServerAction($uuid)
|
||||
{
|
||||
return $this->setBase('server', 'servers.server', $uuid);
|
||||
}
|
||||
public function toggleServerAction($uuid)
|
||||
{
|
||||
return $this->toggleBase('servers.server', $uuid);
|
||||
}
|
||||
}
|
||||
+1
@@ -36,6 +36,7 @@ class GeneralController extends \OPNsense\Base\IndexController
|
||||
$this->view->formDialogEditDnscryptproxyForward = $this->getForm("dialogEditDnscryptproxyForward");
|
||||
$this->view->formDialogEditDnscryptproxyCloak = $this->getForm("dialogEditDnscryptproxyCloak");
|
||||
$this->view->formDialogEditDnscryptproxyWhitelist = $this->getForm("dialogEditDnscryptproxyWhitelist");
|
||||
$this->view->formDialogEditDnscryptproxyServer = $this->getForm("dialogEditDnscryptproxyServer");
|
||||
$this->view->pick('OPNsense/Dnscryptproxy/general');
|
||||
}
|
||||
}
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>server.enabled</id>
|
||||
<label>Enabled</label>
|
||||
<type>checkbox</type>
|
||||
<help>This will enable or disable the server stamp.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>server.name</id>
|
||||
<label>Name</label>
|
||||
<type>text</type>
|
||||
<help>Set the name of the stamp.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>server.stamp</id>
|
||||
<label>SDNS Stamp</label>
|
||||
<type>text</type>
|
||||
<help>Set the SDNS stamp without sdns:// prefix.</help>
|
||||
</field>
|
||||
</form>
|
||||
+8
@@ -157,4 +157,12 @@
|
||||
<type>text</type>
|
||||
<help>Maximum TTL for negatively cached entries.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>general.serverlist</id>
|
||||
<label>Server List</label>
|
||||
<type>select_multiple</type>
|
||||
<style>tokenize</style>
|
||||
<allownew>true</allownew>
|
||||
<help><![CDATA[Set a list of <a href="https://dnscrypt.info/public-servers">known servers</a> e.g. if you want to stick with Cisco only. You can also put your manually added servers here. Please use on your own risk.]]></help>
|
||||
</field>
|
||||
</form>
|
||||
|
||||
@@ -133,5 +133,8 @@
|
||||
<MaximumValue>86400</MaximumValue>
|
||||
<ValidationMessage>Choose a number between 1 and 86400.</ValidationMessage>
|
||||
</cache_neg_max_ttl>
|
||||
<serverlist type="CSVListField">
|
||||
<Required>N</Required>
|
||||
</serverlist>
|
||||
</items>
|
||||
</model>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2018 Michael Muenz <m.muenz@gmail.com>
|
||||
All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace OPNsense\Dnscryptproxy;
|
||||
|
||||
use OPNsense\Base\BaseModel;
|
||||
|
||||
class Server extends BaseModel
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<model>
|
||||
<mount>//OPNsense/dnscryptproxy/server</mount>
|
||||
<description>dnscrypt-proxy Server configuration</description>
|
||||
<version>1.0.0</version>
|
||||
<items>
|
||||
<servers>
|
||||
<server type="ArrayField">
|
||||
<enabled type="BooleanField">
|
||||
<default>1</default>
|
||||
<Required>Y</Required>
|
||||
</enabled>
|
||||
<name type="TextField">
|
||||
<Required>Y</Required>
|
||||
</name>
|
||||
<stamp type="TextField">
|
||||
<Required>Y</Required>
|
||||
</stamp>
|
||||
</server>
|
||||
</servers>
|
||||
</items>
|
||||
</model>
|
||||
@@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
<li><a data-toggle="tab" href="#forwards">{{ lang._('Forwarders') }}</a></li>
|
||||
<li><a data-toggle="tab" href="#cloaks">{{ lang._('Overrides') }}</a></li>
|
||||
<li><a data-toggle="tab" href="#whitelists">{{ lang._('Whitelists') }}</a></li>
|
||||
<li><a data-toggle="tab" href="#servers">{{ lang._('Servers') }}</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content content-box tab-content">
|
||||
@@ -128,11 +129,40 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
<br /><br />
|
||||
</div>
|
||||
</div>
|
||||
<div id="servers" class="tab-pane fade in">
|
||||
<table id="grid-servers" class="table table-responsive" data-editDialog="dialogEditDnscryptproxyServer">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="enabled" data-type="string" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
|
||||
<th data-column-id="name" data-type="string" data-visible="true">{{ lang._('Name') }}</th>
|
||||
<th data-column-id="stamp" data-type="string" data-visible="true">{{ lang._('SDNS Stamp') }}</th>
|
||||
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
|
||||
<th data-column-id="commands" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="5"></td>
|
||||
<td>
|
||||
<button data-action="add" type="button" class="btn btn-xs btn-default"><span class="fa fa-plus"></span></button>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<div class="col-md-12">
|
||||
<hr />
|
||||
<button class="btn btn-primary" id="saveAct_server" type="button"><b>{{ lang._('Save') }}</b><i id="saveAct_server_progress"></i></button>
|
||||
<br /><br />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{ partial("layout_partials/base_dialog",['fields':formDialogEditDnscryptproxyForward,'id':'dialogEditDnscryptproxyForward','label':lang._('Edit Forwarders')])}}
|
||||
{{ partial("layout_partials/base_dialog",['fields':formDialogEditDnscryptproxyCloak,'id':'dialogEditDnscryptproxyCloak','label':lang._('Edit Overrides')])}}
|
||||
{{ partial("layout_partials/base_dialog",['fields':formDialogEditDnscryptproxyWhitelist,'id':'dialogEditDnscryptproxyWhitelist','label':lang._('Edit Whitelists')])}}
|
||||
{{ partial("layout_partials/base_dialog",['fields':formDialogEditDnscryptproxyServer,'id':'dialogEditDnscryptproxyServer','label':lang._('Edit Servers')])}}
|
||||
|
||||
<script>
|
||||
|
||||
@@ -175,6 +205,16 @@ $( document ).ready(function() {
|
||||
}
|
||||
);
|
||||
|
||||
$("#grid-servers").UIBootgrid(
|
||||
{ 'search':'/api/dnscryptproxy/server/searchServer',
|
||||
'get':'/api/dnscryptproxy/server/getServer/',
|
||||
'set':'/api/dnscryptproxy/server/setServer/',
|
||||
'add':'/api/dnscryptproxy/server/addServer/',
|
||||
'del':'/api/dnscryptproxy/server/delServer/',
|
||||
'toggle':'/api/dnscryptproxy/server/toggleServer/'
|
||||
}
|
||||
);
|
||||
|
||||
$("#saveAct").click(function(){
|
||||
saveFormToEndpoint(url="/api/dnscryptproxy/general/set", formid='frm_general_settings',callback_ok=function(){
|
||||
$("#saveAct_progress").addClass("fa fa-spinner fa-pulse");
|
||||
@@ -215,5 +255,15 @@ $( document ).ready(function() {
|
||||
});
|
||||
});
|
||||
|
||||
$("#saveAct_server").click(function(){
|
||||
saveFormToEndpoint(url="/api/dnscryptproxy/server/set", formid='frm_general_settings',callback_ok=function(){
|
||||
$("#saveAct_server_progress").addClass("fa fa-spinner fa-pulse");
|
||||
ajaxCall(url="/api/dnscryptproxy/service/reconfigure", sendData={}, callback=function(data,status) {
|
||||
updateServiceControlUI('dnscryptproxy');
|
||||
$("#saveAct_server_progress").removeClass("fa fa-spinner fa-pulse");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
+15
-1
@@ -1,5 +1,9 @@
|
||||
{% if helpers.exists('OPNsense.dnscryptproxy.general.enabled') and OPNsense.dnscryptproxy.general.enabled == '1' %}
|
||||
|
||||
{% if helpers.exists('OPNsense.dnscryptproxy.general.serverlist') and OPNsense.dnscryptproxy.general.serverlist != '' %}
|
||||
server_names = [{{ "'" + ("','".join(OPNsense.dnscryptproxy.general.serverlist.split(','))) + "'" }}]
|
||||
{% endif %}
|
||||
|
||||
{% if helpers.exists('OPNsense.dnscryptproxy.general.listen_addresses') and OPNsense.dnscryptproxy.general.listen_addresses != '' %}
|
||||
listen_addresses = [{{ "'" + ("','".join(OPNsense.dnscryptproxy.general.listen_addresses.split(','))) + "'" }}]
|
||||
{% else %}
|
||||
@@ -103,7 +107,7 @@ block_ipv6 = false
|
||||
forwarding_rules = 'forwarding-rules.txt'
|
||||
cloaking_rules = 'cloaking-rules.txt'
|
||||
|
||||
{% if helpers.exists('OPNsense.dnscryptproxy.cache') and OPNsense.dnscryptproxy.cache == '1' %}
|
||||
{% if helpers.exists('OPNsense.dnscryptproxy.general.cache') and OPNsense.dnscryptproxy.general.cache == '1' %}
|
||||
cache = true
|
||||
cache_size = {{ OPNsense.dnscryptproxy.general.cache_size }}
|
||||
cache_min_ttl = {{ OPNsense.dnscryptproxy.general.cache_min_ttl }}
|
||||
@@ -135,4 +139,14 @@ cache = false
|
||||
refresh_delay = 72
|
||||
prefix = ''
|
||||
|
||||
[static]
|
||||
{% if helpers.exists('OPNsense.dnscryptproxy.server.servers.server') %}
|
||||
{% for server_list in helpers.toList('OPNsense.dnscryptproxy.server.servers.server') %}
|
||||
{% if server_list.enabled == '1' %}
|
||||
[static.'{{server_list.name}}']
|
||||
stamp = 'sdns://{{server_list.stamp}}'
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user