Skip to content

Commit

Permalink
dns/dnscrypt-proxy: new plugin (opnsense#965)
Browse files Browse the repository at this point in the history
  • Loading branch information
mimugmail authored and fichtner committed Nov 19, 2018
1 parent c7bc65a commit bface5b
Show file tree
Hide file tree
Showing 31 changed files with 1,355 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dns/dnscrypt-proxy/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PLUGIN_NAME= dnscrypt-proxy
PLUGIN_VERSION= 0.1
PLUGIN_COMMENT= Flexible DNS proxy supportung DNSCrypt and DoH
PLUGIN_DEPENDS= dnscrypt-proxy2
PLUGIN_MAINTAINER= [email protected]
PLUGIN_DEVEL= yes

.include "../../Mk/plugins.mk"
4 changes: 4 additions & 0 deletions dns/dnscrypt-proxy/pkg-descr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
A flexible DNS proxy, with support for modern encrypted DNS protocols
such as DNSCrypt v2 and DNS-over-HTTPS.

WWW: https://github.com/jedisct1/dnscrypt-proxy
55 changes: 55 additions & 0 deletions dns/dnscrypt-proxy/src/etc/inc/plugins.inc.d/dnscryptproxy.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

/*
Copyright (C) 2018 Michael Muenz <[email protected]>
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.
*/

function dnscryptproxy_enabled()
{
$model = new \OPNsense\Dnscryptproxy\General();
return (string)$model->enabled == '1';
}

function dnscryptproxy_services()
{
$services = array();

if (!dnscryptproxy_enabled()) {
return $services;
}

$services[] = array(
'description' => gettext('DNSCrypt-Proxy'),
'configd' => array(
'restart' => array('dnscryptproxy restart'),
'start' => array('dnscryptproxy start'),
'stop' => array('dnscryptproxy stop'),
),
'name' => 'dnscrypt-proxy',
'pid' => '/var/run/dnscrypt-proxy.pid'
);

return $services;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
/**
* Copyright (C) 2018 Michael Muenz <[email protected]>
*
* 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 CloakController extends ApiMutableModelControllerBase
{
static protected $internalModelName = 'cloak';
static protected $internalModelClass = '\OPNsense\Dnscryptproxy\Cloak';

public function searchCloakAction()
{
return $this->searchBase('cloaks.cloak', array("enabled", "name", "destination"));
}
public function getCloakAction($uuid = null)
{
$this->sessionClose();
return $this->getBase('cloak', 'cloaks.cloak', $uuid);
}
public function addCloakAction()
{
return $this->addBase('cloak', 'cloaks.cloak');
}
public function delCloakAction($uuid)
{
return $this->delBase('cloaks.cloak', $uuid);
}
public function setCloakAction($uuid)
{
return $this->setBase('cloak', 'cloaks.cloak', $uuid);
}
public function toggleCloakAction($uuid)
{
return $this->toggleBase('cloaks.cloak', $uuid);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
/**
* Copyright (C) 2018 Michael Muenz <[email protected]>
*
* 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 ForwardController extends ApiMutableModelControllerBase
{
static protected $internalModelName = 'forward';
static protected $internalModelClass = '\OPNsense\Dnscryptproxy\Forward';

public function searchForwardAction()
{
return $this->searchBase('forwards.forward', array("enabled", "domain", "dnsserver"));
}
public function getForwardAction($uuid = null)
{
$this->sessionClose();
return $this->getBase('forward', 'forwards.forward', $uuid);
}
public function addForwardAction()
{
return $this->addBase('forward', 'forwards.forward');
}
public function delForwardAction($uuid)
{
return $this->delBase('forwards.forward', $uuid);
}
public function setForwardAction($uuid)
{
return $this->setBase('forward', 'forwards.forward', $uuid);
}
public function toggleForwardAction($uuid)
{
return $this->toggleBase('forwards.forward', $uuid);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/**
* Copyright (C) 2018 Michael Muenz <[email protected]>
*
* 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;

class GeneralController extends ApiMutableModelControllerBase
{
static protected $internalModelClass = '\OPNsense\Dnscryptproxy\General';
static protected $internalModelName = 'general';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

/**
* Copyright (C) 2018 Michael Muenz <[email protected]>
*
* 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\ApiMutableServiceControllerBase;
use OPNsense\Core\Backend;
use OPNsense\Dnscryptproxy\General;

/**
* Class ServiceController
* @package OPNsense\Dnscrypt-proxy
*/
class ServiceController extends ApiMutableServiceControllerBase
{
static protected $internalServiceClass = '\OPNsense\Dnscryptproxy\General';
static protected $internalServiceTemplate = 'OPNsense/Dnscryptproxy';
static protected $internalServiceEnabled = 'enabled';
static protected $internalServiceName = 'dnscryptproxy';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
/**
* Copyright (C) 2018 Michael Muenz <[email protected]>
*
* 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 WhitelistController extends ApiMutableModelControllerBase
{
static protected $internalModelName = 'whitelist';
static protected $internalModelClass = '\OPNsense\Dnscryptproxy\Whitelist';

public function searchWhitelistAction()
{
return $this->searchBase('whitelists.whitelist', array("enabled", "name"));
}
public function getWhitelistAction($uuid = null)
{
$this->sessionClose();
return $this->getBase('whitelist', 'whitelists.whitelist', $uuid);
}
public function addWhitelistAction()
{
return $this->addBase('whitelist', 'whitelists.whitelist');
}
public function delWhitelistAction($uuid)
{
return $this->delBase('whitelists.whitelist', $uuid);
}
public function setWhitelistAction($uuid)
{
return $this->setBase('whitelist', 'whitelists.whitelist', $uuid);
}
public function toggleWhitelistAction($uuid)
{
return $this->toggleBase('whitelists.whitelist', $uuid);
}
}
Loading

0 comments on commit bface5b

Please sign in to comment.