Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion plist
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,10 @@
/usr/local/opnsense/mvc/app/controllers/OPNsense/Monit/forms/tests.xml
/usr/local/opnsense/mvc/app/controllers/OPNsense/Ntpd/Api/ServiceController.php
/usr/local/opnsense/mvc/app/controllers/OPNsense/Ntpd/StatusController.php
/usr/local/opnsense/mvc/app/controllers/OPNsense/OpenDNS/Api/ServiceController.php
/usr/local/opnsense/mvc/app/controllers/OPNsense/OpenDNS/Api/SettingsController.php
/usr/local/opnsense/mvc/app/controllers/OPNsense/OpenDNS/SettingsController.php
/usr/local/opnsense/mvc/app/controllers/OPNsense/OpenDNS/forms/general.xml
/usr/local/opnsense/mvc/app/controllers/OPNsense/OpenVPN/Api/ClientOverwritesController.php
/usr/local/opnsense/mvc/app/controllers/OPNsense/OpenVPN/Api/ExportController.php
/usr/local/opnsense/mvc/app/controllers/OPNsense/OpenVPN/Api/InstancesController.php
Expand Down Expand Up @@ -866,6 +870,10 @@
/usr/local/opnsense/mvc/app/models/OPNsense/Monit/Monit.xml
/usr/local/opnsense/mvc/app/models/OPNsense/Ntpd/ACL/ACL.xml
/usr/local/opnsense/mvc/app/models/OPNsense/Ntpd/Menu/Menu.xml
/usr/local/opnsense/mvc/app/models/OPNsense/OpenDNS/ACL/ACL.xml
/usr/local/opnsense/mvc/app/models/OPNsense/OpenDNS/Menu/Menu.xml
/usr/local/opnsense/mvc/app/models/OPNsense/OpenDNS/OpenDNS.php
/usr/local/opnsense/mvc/app/models/OPNsense/OpenDNS/OpenDNS.xml
/usr/local/opnsense/mvc/app/models/OPNsense/OpenVPN/Export.php
/usr/local/opnsense/mvc/app/models/OPNsense/OpenVPN/Export.xml
/usr/local/opnsense/mvc/app/models/OPNsense/OpenVPN/FieldTypes/InstanceField.php
Expand Down Expand Up @@ -1016,6 +1024,7 @@
/usr/local/opnsense/mvc/app/views/OPNsense/Monit/index.volt
/usr/local/opnsense/mvc/app/views/OPNsense/Monit/status.volt
/usr/local/opnsense/mvc/app/views/OPNsense/Ntpd/status.volt
/usr/local/opnsense/mvc/app/views/OPNsense/OpenDNS/settings.volt
/usr/local/opnsense/mvc/app/views/OPNsense/OpenVPN/cso.volt
/usr/local/opnsense/mvc/app/views/OPNsense/OpenVPN/export.volt
/usr/local/opnsense/mvc/app/views/OPNsense/OpenVPN/instances.volt
Expand Down Expand Up @@ -1327,6 +1336,7 @@
/usr/local/opnsense/scripts/netflow/lib/parse.py
/usr/local/opnsense/scripts/ntpd/ntpd_status.php
/usr/local/opnsense/scripts/openssh/ssh_query.py
/usr/local/opnsense/scripts/opendns/configure.php
/usr/local/opnsense/scripts/openvpn/client_connect.php
/usr/local/opnsense/scripts/openvpn/client_disconnect.sh
/usr/local/opnsense/scripts/openvpn/genkey.py
Expand Down Expand Up @@ -1455,6 +1465,7 @@
/usr/local/opnsense/service/conf/actions.d/actions_monit.conf
/usr/local/opnsense/service/conf/actions.d/actions_netflow.conf
/usr/local/opnsense/service/conf/actions.d/actions_ntpd.conf
/usr/local/opnsense/service/conf/actions.d/actions_opendns.conf
/usr/local/opnsense/service/conf/actions.d/actions_openssh.conf
/usr/local/opnsense/service/conf/actions.d/actions_openvpn.conf
/usr/local/opnsense/service/conf/actions.d/actions_radvd.conf
Expand Down Expand Up @@ -2550,7 +2561,6 @@
/usr/local/www/services_ntpd.php
/usr/local/www/services_ntpd_gps.php
/usr/local/www/services_ntpd_pps.php
/usr/local/www/services_opendns.php
/usr/local/www/status_wireless.php
/usr/local/www/system_advanced_admin.php
/usr/local/www/system_advanced_firewall.php
Expand Down
15 changes: 11 additions & 4 deletions src/etc/inc/plugins.inc.d/opendns.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/*
* Copyright (C) 2026 Greelan
* Copyright (C) 2019 Deciso B.V.
* All rights reserved.
*
Expand Down Expand Up @@ -37,12 +38,17 @@ function opendns_configure()

function opendns_configure_do($verbose = false)
{
global $config;
$mdl = new \OPNsense\OpenDNS\OpenDNS();

if (!empty($config['opendns']['enable'])) {
if (!$mdl->enable->isEmpty()) {
service_log('Configure OpenDNS...', $verbose);

$result = opendns_register($config['opendns']);
$pconfig = [
'username' => (string)$mdl->username,
'password' => (string)$mdl->password,
'host' => (string)$mdl->host,
];
$result = opendns_register($pconfig);
log_msg("opendns response: $result");

service_log("done.\n", $verbose);
Expand All @@ -53,7 +59,7 @@ function opendns_xmlrpc_sync()
{
return [[
'description' => gettext('OpenDNS'),
'section' => 'opendns',
'section' => 'OPNsense.OpenDNS',
'id' => 'opendns',
]];
}
Expand All @@ -64,6 +70,7 @@ function opendns_register($pconfig)
curl_setopt($ch, CURLOPT_URL, sprintf('https://updates.opendns.com/nic/update?hostname=%s', $pconfig['host']));
curl_setopt($ch, CURLOPT_USERPWD, sprintf('%s:%s', $pconfig['username'], $pconfig['password']));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
$output = curl_exec($ch);
curl_close($ch);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/*
* Copyright (C) 2026 Greelan
* 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\OpenDNS\Api;

use OPNsense\Base\ApiControllerBase;
use OPNsense\Core\Backend;

class ServiceController extends ApiControllerBase
{
/**
* apply OpenDNS configuration
* @return array
*/
public function reconfigureAction()
{
$result = ['status' => 'failed'];
if ($this->request->isPost()) {
$result['status'] = trim((new Backend())->configdRun('opendns configure'));
}
return $result;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/*
* Copyright (C) 2026 Greelan
* 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\OpenDNS\Api;

use OPNsense\Base\ApiMutableModelControllerBase;

class SettingsController extends ApiMutableModelControllerBase
{
protected static $internalModelName = 'opendns';
protected static $internalModelClass = '\OPNsense\OpenDNS\OpenDNS';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/*
* Copyright (C) 2026 Greelan
* 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\OpenDNS;

/**
* Class SettingsController
* @package OPNsense\OpenDNS
*/
class SettingsController extends \OPNsense\Base\IndexController
{
public function indexAction()
{
$this->view->generalForm = $this->getForm('general');
$this->view->pick('OPNsense/OpenDNS/settings');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<form>
<field>
<id>opendns.enable</id>
<label>Enable OpenDNS</label>
<type>checkbox</type>
<help><![CDATA[If this option is enabled, DNS requests will be filtered using the DNS servers from <a href="https://www.opendns.com/" target="_blank">OpenDNS.com</a>, unless Standalone mode is enabled. The DNS servers configured under <a href="/system_general.php">System: Settings: General</a> will be overwritten, and any DNS servers learned by DHCP/PPP on WAN will be ignored. The previous DNS settings will be saved, and later restored when OpenDNS is disabled.]]></help>
</field>
<field>
<id>opendns.standalone</id>
<label>Standalone mode</label>
<type>checkbox</type>
<help>If this option is enabled, the system's DNS server settings will not be altered to use the DNS servers from OpenDNS.com. This mode is useful when the OpenDNS servers are used by a different network component but the periodic update behavior is still desired.</help>
</field>
<field>
<id>opendns.username</id>
<label>OpenDNS.com username</label>
<type>text</type>
<help>Login username for the OpenDNS.com dashboard. Used to automatically update the IP address of the registered network.</help>
</field>
<field>
<id>opendns.password</id>
<label>OpenDNS.com password</label>
<type>password</type>
<help>Login password for the OpenDNS.com dashboard.</help>
</field>
<field>
<id>opendns.host</id>
<label>OpenDNS.com network label</label>
<type>text</type>
<help><![CDATA[Network label (or 'friendly name') on the <a href="https://dashboard.opendns.com/settings/" target="_blank">settings dashboard of OpenDNS.com</a>. Used to update the node's IP address whenever the WAN interface changes its IP address.]]></help>
</field>
</form>
10 changes: 10 additions & 0 deletions src/opnsense/mvc/app/models/OPNsense/OpenDNS/ACL/ACL.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<acl>
<page-services-opendns>
<name>Services: OpenDNS</name>
<patterns>
<pattern>ui/opendns/settings</pattern>
<pattern>api/opendns/settings/*</pattern>
<pattern>api/opendns/service/*</pattern>
</patterns>
</page-services-opendns>
</acl>
5 changes: 5 additions & 0 deletions src/opnsense/mvc/app/models/OPNsense/OpenDNS/Menu/Menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<menu>
<Services>
<OpenDNS VisibleName="OpenDNS" url="/ui/opendns/settings" cssClass="fa fa-tags fa-fw"/>
</Services>
</menu>
58 changes: 58 additions & 0 deletions src/opnsense/mvc/app/models/OPNsense/OpenDNS/OpenDNS.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/*
* Copyright (C) 2026 Greelan
* 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\OpenDNS;

use OPNsense\Base\BaseModel;
use OPNsense\Base\Messages\Message;

class OpenDNS extends BaseModel
{
/**
* {@inheritdoc}
*/
public function performValidation($validateFullModel = false)
{
$messages = parent::performValidation($validateFullModel);
if ($this->enable->isEmpty()) {
return $messages;
}
foreach (['username', 'password', 'host'] as $fieldname) {
$node = $this->$fieldname;
if ($validateFullModel || $node->isFieldChanged()) {
if (trim((string)$node) === '') {
$messages->appendMessage(new Message(
gettext('A value is required when OpenDNS is enabled.'),
$fieldname
));
}
}
}
return $messages;
}
}
28 changes: 28 additions & 0 deletions src/opnsense/mvc/app/models/OPNsense/OpenDNS/OpenDNS.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<model>
<mount>//opendns</mount>
<version>1.0.0</version>
<description>OpenDNS configuration</description>
<items>
<enable type="BooleanField">
<Default>0</Default>
</enable>
<standalone type="BooleanField">
<Default>0</Default>
</standalone>
<username type="TextField"/>
<password type="TextField"/>
<host type="TextField">
<Mask>/^[a-zA-Z0-9 _\-\.]+$/</Mask>
<ValidationMessage>Please specify a valid OpenDNS network label.</ValidationMessage>
</host>
<backup>
<has_backup type="BooleanField">
<Default>0</Default>
</has_backup>
<dnsservers type="TextField"/>
<dnsallowoverride type="BooleanField">
<Default>1</Default>
</dnsallowoverride>
</backup>
</items>
</model>
Loading