mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 00:07:26 +00:00
dnsmasq: migrate to MVC/API - phase 1 : frontend migration (#8260)
* dnsmasq: migrate to MVC/API, initial boilerplate for https://github.com/opnsense/core/issues/7905 * dnsmasq: migrate to MVC/API, work in progress for https://github.com/opnsense/core/issues/7905 * add general tab fields * initial hosts tab with inline migration * dnsmasq: migrate to MVC/API, replace current frontend for https://github.com/opnsense/core/issues/7905 More or less feature complete refactory of the current frontend, which should be a drop-in replacement for the legacy frontend. The default migration will force an inline migration for aliases and domain ip addresses (which in legacy is a combined field). * dnsmasq: migrate to MVC/API, missing isset() -> !empty() for https://github.com/opnsense/core/issues/7905
This commit is contained in:
parent
49f7da283e
commit
e93833258b
15
plist
15
plist
@ -319,6 +319,12 @@
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Diagnostics/forms/ping.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Diagnostics/forms/portprobe.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Diagnostics/forms/traceroute.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Dnsmasq/Api/ServiceController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Dnsmasq/Api/SettingsController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Dnsmasq/IndexController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Dnsmasq/forms/dialogDomainOverride.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Dnsmasq/forms/dialogHostOverride.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Dnsmasq/forms/general.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Firewall/AliasController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Firewall/AliasUtilController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php
|
||||
@ -713,6 +719,10 @@
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Diagnostics/Traceroute.php
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Diagnostics/Traceroute.xml
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Dnsmasq/ACL/ACL.xml
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Dnsmasq/Dnsmasq.php
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Dnsmasq/Dnsmasq.xml
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Dnsmasq/FieldTypes/AliasesField.php
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Dnsmasq/FieldTypes/DomainIPField.php
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Dnsmasq/Menu/Menu.xml
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Firewall/ACL/ACL.xml
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Firewall/Alias.php
|
||||
@ -909,6 +919,7 @@
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Diagnostics/traffic.volt
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Diagnostics/treeview.volt
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Diagnostics/vip.volt
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Dnsmasq/index.volt
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Firewall/alias.volt
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Firewall/alias_util.volt
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Firewall/category.volt
|
||||
@ -1311,6 +1322,7 @@
|
||||
/usr/local/opnsense/service/conf/actions.d/actions_dhcpd6.conf
|
||||
/usr/local/opnsense/service/conf/actions.d/actions_dhcrelay.conf
|
||||
/usr/local/opnsense/service/conf/actions.d/actions_dns.conf
|
||||
/usr/local/opnsense/service/conf/actions.d/actions_dnsmasq.conf
|
||||
/usr/local/opnsense/service/conf/actions.d/actions_filter.conf
|
||||
/usr/local/opnsense/service/conf/actions.d/actions_firmware.conf
|
||||
/usr/local/opnsense/service/conf/actions.d/actions_health.conf
|
||||
@ -2415,9 +2427,6 @@
|
||||
/usr/local/www/services_dhcp_edit.php
|
||||
/usr/local/www/services_dhcpv6.php
|
||||
/usr/local/www/services_dhcpv6_edit.php
|
||||
/usr/local/www/services_dnsmasq.php
|
||||
/usr/local/www/services_dnsmasq_domainoverride_edit.php
|
||||
/usr/local/www/services_dnsmasq_edit.php
|
||||
/usr/local/www/services_ntpd.php
|
||||
/usr/local/www/services_ntpd_gps.php
|
||||
/usr/local/www/services_ntpd_pps.php
|
||||
|
||||
@ -144,64 +144,68 @@ function dnsmasq_configure_do($verbose = false)
|
||||
$args .= " --listen-address={$address} ";
|
||||
}
|
||||
|
||||
if (!empty($addresses) && isset($config['dnsmasq']['strictbind'])) {
|
||||
if (!empty($addresses) && !empty($config['dnsmasq']['strictbind'])) {
|
||||
$args .= ' --bind-interfaces ';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($config['dnsmasq']['no_private_reverse'])) {
|
||||
if (!empty($config['dnsmasq']['no_private_reverse'])) {
|
||||
$args .= ' --bogus-priv ';
|
||||
}
|
||||
|
||||
foreach (config_read_array('dnsmasq', 'domainoverrides') as $override) {
|
||||
if ($override['ip'] == '!') {
|
||||
$override['ip'] = '';
|
||||
$ip = $override['ip'];
|
||||
if (!empty($ip) && !empty($override['port'])) {
|
||||
$ip .= '#' . $override['port'];
|
||||
}
|
||||
if (!empty($ip) && !empty($override['srcip'])) {
|
||||
$ip .= '@' . $override['srcip'];
|
||||
}
|
||||
|
||||
$args .= ' --server=' . escapeshellarg('/' . $override['domain'] . '/' . $override['ip']);
|
||||
$args .= ' --server=' . escapeshellarg('/' . $override['domain'] . '/' . $ip);
|
||||
|
||||
if (!isset($config['system']['webgui']['nodnsrebindcheck'])) {
|
||||
$args .= ' --rebind-domain-ok=' . escapeshellarg('/' . $override['domain'] . '/') . ' ';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($config['dnsmasq']['strict_order'])) {
|
||||
if (!empty($config['dnsmasq']['strict_order'])) {
|
||||
$args .= ' --strict-order ';
|
||||
} else {
|
||||
$args .= ' --all-servers ';
|
||||
}
|
||||
|
||||
if (isset($config['dnsmasq']['domain_needed'])) {
|
||||
if (!empty($config['dnsmasq']['domain_needed'])) {
|
||||
$args .= ' --domain-needed ';
|
||||
}
|
||||
|
||||
if (isset($config['dnsmasq']['dnssec'])) {
|
||||
if (!empty($config['dnsmasq']['dnssec'])) {
|
||||
$args .= ' --dnssec ';
|
||||
$args .= ' --trust-anchor=.,20326,8,2,E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC683457104237C7F8EC8D ';
|
||||
$args .= ' --trust-anchor=.,38696,8,2,683D2D0ACB8C9B712A1948B27F741219298D0A450D612C483AF444A4C0FB2B16 ';
|
||||
}
|
||||
|
||||
if (isset($config['dnsmasq']['log_queries'])) {
|
||||
if (!empty($config['dnsmasq']['log_queries'])) {
|
||||
$args .= ' --log-queries=extra ';
|
||||
}
|
||||
|
||||
if (isset($config['dnsmasq']['no_hosts'])) {
|
||||
if (!empty($config['dnsmasq']['no_hosts'])) {
|
||||
$args .= ' --no-hosts ';
|
||||
}
|
||||
|
||||
if (isset($config['dnsmasq']['dns_forward_max'])) {
|
||||
if (!empty($config['dnsmasq']['dns_forward_max'])) {
|
||||
$args .= " --dns-forward-max={$config['dnsmasq']['dns_forward_max']} ";
|
||||
} else {
|
||||
$args .= ' --dns-forward-max=5000 ';
|
||||
}
|
||||
|
||||
if (isset($config['dnsmasq']['cache_size'])) {
|
||||
if (!empty($config['dnsmasq']['cache_size'])) {
|
||||
$args .= " --cache-size={$config['dnsmasq']['cache_size']} ";
|
||||
} else {
|
||||
$args .= ' --cache-size=10000 ';
|
||||
}
|
||||
|
||||
if (isset($config['dnsmasq']['local_ttl'])) {
|
||||
if (!empty($config['dnsmasq']['local_ttl'])) {
|
||||
$args .= " --local-ttl={$config['dnsmasq']['local_ttl']} ";
|
||||
} else {
|
||||
$args .= ' --local-ttl=1 ';
|
||||
@ -213,9 +217,9 @@ function dnsmasq_configure_do($verbose = false)
|
||||
|
||||
mwexec("/usr/local/sbin/dnsmasq {$args}");
|
||||
|
||||
if (isset($config['dnsmasq']['regdhcp'])) {
|
||||
if (!empty($config['dnsmasq']['regdhcp'])) {
|
||||
$domain = $config['system']['domain'];
|
||||
if (isset($config['dnsmasq']['regdhcpdomain'])) {
|
||||
if (!empty($config['dnsmasq']['regdhcpdomain'])) {
|
||||
$domain = $config['dnsmasq']['regdhcpdomain'];
|
||||
}
|
||||
mwexecf('/usr/local/opnsense/scripts/dhcp/dnsmasq_watcher.py --domain %s', $domain);
|
||||
@ -237,24 +241,24 @@ function _dnsmasq_add_host_entries()
|
||||
}
|
||||
|
||||
foreach ($dnsmasqcfg['hosts'] as $host) {
|
||||
if ($host['host']) {
|
||||
if (!empty($host['host'])) {
|
||||
/* XXX: The question is if we do want "host" as a global alias */
|
||||
$lhosts .= "{$host['ip']}\t{$host['host']}.{$host['domain']} {$host['host']}\n";
|
||||
} else {
|
||||
$lhosts .= "{$host['ip']}\t{$host['domain']}\n";
|
||||
}
|
||||
if (!isset($host['aliases']) || !is_array($host['aliases']) || !is_array($host['aliases']['item'])) {
|
||||
continue;
|
||||
}
|
||||
foreach ($host['aliases']['item'] as $alias) {
|
||||
if ($alias['host']) {
|
||||
$lhosts .= "{$host['ip']}\t{$alias['host']}.{$alias['domain']} {$alias['host']}\n";
|
||||
} else {
|
||||
$lhosts .= "{$host['ip']}\t{$alias['domain']}\n";
|
||||
if (!empty($host['aliases'])) {
|
||||
foreach (explode(",", $host['aliases']) as $alias) {
|
||||
/**
|
||||
* XXX: pre migration all hosts where added here as alias, when we combine host.domain we
|
||||
* miss some information, which is likely not a very good idea anyway.
|
||||
*/
|
||||
$lhosts .= "{$host['ip']}\t{$alias}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($dnsmasqcfg['regdhcpstatic'])) {
|
||||
if (!empty($dnsmasqcfg['regdhcpstatic'])) {
|
||||
foreach (plugins_run('static_mapping', [null, true, legacy_interfaces_details()]) as $map) {
|
||||
foreach ($map as $host) {
|
||||
if (empty($host['hostname'])) {
|
||||
@ -264,7 +268,7 @@ function _dnsmasq_add_host_entries()
|
||||
if (empty($host['domain'])) {
|
||||
$host['domain'] = $config['system']['domain'];
|
||||
}
|
||||
if (isset($host['ipaddr'])) {
|
||||
if (!empty($host['ipaddr'])) {
|
||||
$dhosts .= "{$host['ipaddr']}\t{$host['hostname']}.{$host['domain']} {$host['hostname']}\n";
|
||||
} else {
|
||||
$dhosts .= "{$host['ipaddrv6']}\t{$host['hostname']}.{$host['domain']} {$host['hostname']}\n";
|
||||
@ -273,7 +277,7 @@ function _dnsmasq_add_host_entries()
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($dnsmasqcfg['dhcpfirst'])) {
|
||||
if (!empty($dnsmasqcfg['dhcpfirst'])) {
|
||||
file_put_contents('/var/etc/dnsmasq-hosts', $dhosts . $lhosts);
|
||||
} else {
|
||||
file_put_contents('/var/etc/dnsmasq-hosts', $lhosts . $dhosts);
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2025 Deciso B.V.
|
||||
* 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\Dnsmasq\Api;
|
||||
|
||||
use OPNsense\Base\ApiMutableServiceControllerBase;
|
||||
|
||||
/**
|
||||
* Class ServiceController
|
||||
* @package OPNsense\Dnsmasq
|
||||
*/
|
||||
class ServiceController extends ApiMutableServiceControllerBase
|
||||
{
|
||||
protected static $internalServiceClass = '\OPNsense\Dnsmasq\Dnsmasq';
|
||||
//protected static $internalServiceTemplate = 'OPNsense/Dnsmasq';
|
||||
protected static $internalServiceEnabled = 'enable';
|
||||
protected static $internalServiceName = 'dnsmasq';
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2025 Deciso B.V.
|
||||
* 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\Dnsmasq\Api;
|
||||
|
||||
use OPNsense\Base\ApiMutableModelControllerBase;
|
||||
|
||||
class SettingsController extends ApiMutableModelControllerBase
|
||||
{
|
||||
protected static $internalModelName = 'dnsmasq';
|
||||
protected static $internalModelClass = '\OPNsense\Dnsmasq\Dnsmasq';
|
||||
|
||||
public function searchHostAction()
|
||||
{
|
||||
return $this->searchBase('hosts');
|
||||
}
|
||||
|
||||
public function getHostAction($uuid = null)
|
||||
{
|
||||
return $this->getBase('host', 'hosts', $uuid);
|
||||
}
|
||||
|
||||
public function setHostAction($uuid)
|
||||
{
|
||||
return $this->setBase('host', 'hosts', $uuid);
|
||||
}
|
||||
|
||||
public function addHostAction()
|
||||
{
|
||||
return $this->addBase('host', 'hosts');
|
||||
}
|
||||
|
||||
public function delHostAction($uuid)
|
||||
{
|
||||
return $this->delBase('hosts', $uuid);
|
||||
}
|
||||
|
||||
public function searchDomainAction()
|
||||
{
|
||||
return $this->searchBase('domainoverrides');
|
||||
}
|
||||
|
||||
public function getDomainAction($uuid = null)
|
||||
{
|
||||
return $this->getBase('domainoverride', 'domainoverrides', $uuid);
|
||||
}
|
||||
|
||||
public function setDomainAction($uuid)
|
||||
{
|
||||
return $this->setBase('domainoverride', 'domainoverrides', $uuid);
|
||||
}
|
||||
|
||||
public function addDomainAction()
|
||||
{
|
||||
return $this->addBase('domainoverride', 'domainoverrides');
|
||||
}
|
||||
|
||||
public function delDomainAction($uuid)
|
||||
{
|
||||
return $this->delBase('domainoverride', $uuid);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2025 Deciso B.V.
|
||||
* 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\Dnsmasq;
|
||||
|
||||
class IndexController extends \OPNsense\Base\IndexController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->generalForm = $this->getForm("general");
|
||||
$this->view->formDialogEditHostOverride = $this->getForm("dialogHostOverride");
|
||||
$this->view->formGridHostOverride = $this->getFormGrid("dialogHostOverride");
|
||||
$this->view->formDialogEditDomainOverride = $this->getForm("dialogDomainOverride");
|
||||
$this->view->formGridDomainOverride = $this->getFormGrid("dialogDomainOverride");
|
||||
$this->view->pick('OPNsense/Dnsmasq/index');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>domainoverride.domain</id>
|
||||
<label>Domain</label>
|
||||
<type>text</type>
|
||||
<help>Domain to override (NOTE: this does not have to be a valid TLD!)</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>domainoverride.ip</id>
|
||||
<label>IP address</label>
|
||||
<type>text</type>
|
||||
<help>IP address of the authoritative DNS server for this domain, leave empty to prevent lookups for this domain</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>domainoverride.port</id>
|
||||
<label>Port</label>
|
||||
<type>text</type>
|
||||
<help>Specify a non standard port number here, leave blank for default</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>domainoverride.srcip</id>
|
||||
<label>Domain</label>
|
||||
<type>text</type>
|
||||
<help>Source IP address for queries to the DNS server for the override domain. Best to leave empty</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>domainoverride.descr</id>
|
||||
<label>Description</label>
|
||||
<type>text</type>
|
||||
<help>You may enter a description here for your reference (not parsed)</help>
|
||||
</field>
|
||||
</form>
|
||||
@ -0,0 +1,45 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>host.host</id>
|
||||
<label>Host</label>
|
||||
<type>text</type>
|
||||
<help>Name of the host, without the domain part. Use "*" to create a wildcard entry.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>host.domain</id>
|
||||
<label>Domain</label>
|
||||
<type>text</type>
|
||||
<help>Domain of the host, e.g. example.com</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>host.ip</id>
|
||||
<label>IP address</label>
|
||||
<type>text</type>
|
||||
<help>IP address of the host, e.g. 192.168.100.100 or fd00:abcd::1</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>host.aliases</id>
|
||||
<label>Aliases</label>
|
||||
<type>select_multiple</type>
|
||||
<style>tokenize</style>
|
||||
<help>list of aliases (fqdn)</help>
|
||||
<grid_view>
|
||||
<visible>false</visible>
|
||||
</grid_view>
|
||||
</field>
|
||||
<field>
|
||||
<id>host.descr</id>
|
||||
<label>Description</label>
|
||||
<type>text</type>
|
||||
<help>You may enter a description here for your reference (not parsed)</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>host.comments</id>
|
||||
<label>Comments</label>
|
||||
<type>textbox</type>
|
||||
<help>You may enter a description here for your reference (not parsed)</help>
|
||||
<grid_view>
|
||||
<visible>false</visible>
|
||||
</grid_view>
|
||||
</field>
|
||||
</form>
|
||||
@ -0,0 +1,116 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>dnsmasq.enable</id>
|
||||
<label>Enable</label>
|
||||
<type>checkbox</type>
|
||||
<help>Enable Dnsmasq.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>dnsmasq.port</id>
|
||||
<label>Listen Port</label>
|
||||
<type>text</type>
|
||||
<help>The port used for responding to DNS queries. It should normally be left blank unless another service needs to bind to TCP/UDP port 53.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>dnsmasq.interface</id>
|
||||
<label>Interface</label>
|
||||
<type>select_multiple</type>
|
||||
<hint>All (recommended)</hint>
|
||||
<help>
|
||||
Interface IPs used by Dnsmasq for responding to queries from clients. If an interface has both IPv4 and IPv6 IPs, both are used. Queries to other interface IPs not selected below are discarded. The default behavior is to respond to queries on every available IPv4 and IPv6 address.
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>dnsmasq.strictbind</id>
|
||||
<label>Strict Interface Binding</label>
|
||||
<type>checkbox</type>
|
||||
<help>If this option is set, Dnsmasq will only bind to the interfaces containing the IP addresses selected above, rather than binding to all interfaces and discarding queries to other addresses. This option does not work with IPv6. If set, Dnsmasq will not bind to IPv6 addresses.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>dnsmasq.dnssec</id>
|
||||
<label>DNSSEC</label>
|
||||
<type>checkbox</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>dnsmasq.regdhcpstatic</id>
|
||||
<label>Register DHCP Static Mappings</label>
|
||||
<type>checkbox</type>
|
||||
<help>If this option is set, then DHCP static mappings will be registered in Dnsmasq, so that their name can be resolved.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>dnsmasq.dhcpfirst</id>
|
||||
<label>Prefer DHCP</label>
|
||||
<type>checkbox</type>
|
||||
<help>If this option is set, then DHCP mappings will be resolved before the manual list of names below. This only affects the name given for a reverse lookup (PTR).</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>dnsmasq.no_hosts</id>
|
||||
<label>No Hosts Lookup</label>
|
||||
<type>checkbox</type>
|
||||
<help>Do not read hostnames in /etc/hosts</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>dnsmasq.log_queries</id>
|
||||
<label>Log the results of DNS queries</label>
|
||||
<type>checkbox</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>dnsmasq.dns_forward_max</id>
|
||||
<label>Maximum concurrent queries</label>
|
||||
<type>text</type>
|
||||
<hint>5000</hint>
|
||||
<help>Set the maximum number of concurrent DNS queries. On configurations with tight resources, this value may need to be reduced.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>dnsmasq.cache_size</id>
|
||||
<label>Cache size</label>
|
||||
<type>text</type>
|
||||
<hint>10000</hint>
|
||||
<help>Set the size of the cache. Setting the cache size to zero disables caching. Please note that huge cache size impacts performance.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>dnsmasq.local_ttl</id>
|
||||
<label>Local DNS entry TTL</label>
|
||||
<type>text</type>
|
||||
<hint>1</hint>
|
||||
<help>This option allows a time-to-live (in seconds) to be given for local DNS entries, i.e. /etc/hosts or DHCP leases. This will reduce the load on the server at the expense of clients using stale data under some circumstances. A value of zero will disable client-side caching.</help>
|
||||
</field>
|
||||
<field>
|
||||
<type>header</type>
|
||||
<label>DNS Query Forwarding</label>
|
||||
</field>
|
||||
<field>
|
||||
<id>dnsmasq.strict_order</id>
|
||||
<label>Query DNS servers sequentially</label>
|
||||
<type>checkbox</type>
|
||||
<help>If this option is set, Dnsmasq will query the DNS servers sequentially in the order specified (System: General Setup: DNS Servers), rather than all at once in parallel.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>dnsmasq.domain_needed</id>
|
||||
<label>Require domain</label>
|
||||
<type>checkbox</type>
|
||||
<help>If this option is set, Dnsmasq will not forward A or AAAA queries for plain names, without dots or domain parts, to upstream name servers. If the name is not known from /etc/hosts or DHCP then a "not found" answer is returned.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>dnsmasq.no_private_reverse</id>
|
||||
<label>Do not forward private reverse lookups</label>
|
||||
<type>checkbox</type>
|
||||
<help>If this option is set, Dnsmasq will not forward reverse DNS lookups (PTR) for private addresses (RFC 1918) to upstream name servers. Any entries in the Domain Overrides section forwarding private "n.n.n.in-addr.arpa" names to a specific server are still forwarded. If the IP to name is not known from /etc/hosts, DHCP or a specific domain override then a "not found" answer is immediately returned.</help>
|
||||
</field>
|
||||
<field>
|
||||
<type>header</type>
|
||||
<label>ISC DHCP</label>
|
||||
</field>
|
||||
<field>
|
||||
<id>dnsmasq.regdhcp</id>
|
||||
<label>Register ISC DHCP4 Leases</label>
|
||||
<type>checkbox</type>
|
||||
<help>If this option is set, then machines that specify their hostname when requesting a DHCP lease will be registered in Dnsmasq, so that their name can be resolved.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>dnsmasq.regdhcpdomain</id>
|
||||
<label>DHCP Domain Override</label>
|
||||
<type>text</type>
|
||||
<help>The domain name to use for DHCP hostname registration. If empty, the default system domain is used. Note that all DHCP leases will be assigned to the same domain. If this is undesired, static DHCP lease registration is able to provide coherent mappings.</help>
|
||||
</field>
|
||||
</form>
|
||||
@ -2,21 +2,10 @@
|
||||
<page-services-dnsforwarder>
|
||||
<name>Services: Dnsmasq DNS: Settings</name>
|
||||
<patterns>
|
||||
<pattern>services_dnsmasq.php*</pattern>
|
||||
<pattern>ui/dnsmasq</pattern>
|
||||
<pattern>api/dnsmasq/*</pattern>
|
||||
</patterns>
|
||||
</page-services-dnsforwarder>
|
||||
<page-services-dnsforwarder-editdomainoverride>
|
||||
<name>Services: Dnsmasq DNS: Edit Domain Override</name>
|
||||
<patterns>
|
||||
<pattern>services_dnsmasq_domainoverride_edit.php*</pattern>
|
||||
</patterns>
|
||||
</page-services-dnsforwarder-editdomainoverride>
|
||||
<page-services-dnsforwarder-edithost>
|
||||
<name>Services: Dnsmasq DNS: Edit Host</name>
|
||||
<patterns>
|
||||
<pattern>services_dnsmasq_edit.php*</pattern>
|
||||
</patterns>
|
||||
</page-services-dnsforwarder-edithost>
|
||||
<page-diagnostics-logs-dnsmasq>
|
||||
<name>Services: Dnsmasq DNS: Log File</name>
|
||||
<patterns>
|
||||
|
||||
39
src/opnsense/mvc/app/models/OPNsense/Dnsmasq/Dnsmasq.php
Normal file
39
src/opnsense/mvc/app/models/OPNsense/Dnsmasq/Dnsmasq.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2025 Deciso B.V.
|
||||
* 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\Dnsmasq;
|
||||
|
||||
use OPNsense\Base\BaseModel;
|
||||
|
||||
/**
|
||||
* Class Dnsmasq
|
||||
* @package OPNsense\Dnsmasq
|
||||
*/
|
||||
class Dnsmasq extends BaseModel
|
||||
{
|
||||
}
|
||||
74
src/opnsense/mvc/app/models/OPNsense/Dnsmasq/Dnsmasq.xml
Normal file
74
src/opnsense/mvc/app/models/OPNsense/Dnsmasq/Dnsmasq.xml
Normal file
@ -0,0 +1,74 @@
|
||||
<model>
|
||||
<mount>/dnsmasq</mount>
|
||||
<version>1.0.0</version>
|
||||
<items>
|
||||
<enable type="BooleanField"/>
|
||||
<regdhcp type="BooleanField"/>
|
||||
<regdhcpstatic type="BooleanField"/>
|
||||
<dhcpfirst type="BooleanField"/>
|
||||
<strict_order type="BooleanField"/>
|
||||
<domain_needed type="BooleanField"/>
|
||||
<no_private_reverse type="BooleanField"/>
|
||||
<log_queries type="BooleanField"/>
|
||||
<no_hosts type="BooleanField"/>
|
||||
<strictbind type="BooleanField"/>
|
||||
<dnssec type="BooleanField"/>
|
||||
<regdhcpdomain type="HostnameField">
|
||||
<IsDNSName>Y</IsDNSName>
|
||||
</regdhcpdomain>
|
||||
<interface type="InterfaceField">
|
||||
<Multiple>Y</Multiple>
|
||||
</interface>
|
||||
<port type="PortField"/>
|
||||
<dns_forward_max type="IntegerField">
|
||||
<MinimumValue>0</MinimumValue>
|
||||
</dns_forward_max>
|
||||
<cache_size type="IntegerField">
|
||||
<MinimumValue>0</MinimumValue>
|
||||
</cache_size>
|
||||
<local_ttl type="IntegerField">
|
||||
<MinimumValue>0</MinimumValue>
|
||||
</local_ttl>
|
||||
<hosts type="ArrayField">
|
||||
<host type="HostnameField">
|
||||
<IsDNSName>Y</IsDNSName>
|
||||
<IpAllowed>N</IpAllowed>
|
||||
<Required>Y</Required>
|
||||
</host>
|
||||
<domain type="TextField">
|
||||
<Required>Y</Required>
|
||||
<Mask>/^(?:(?:[a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*(?:[a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])$/i</Mask>
|
||||
<ValidationMessage>A valid domain must be specified.</ValidationMessage>
|
||||
</domain>
|
||||
<ip type="NetworkField">
|
||||
<Required>Y</Required>
|
||||
<NetMaskAllowed>N</NetMaskAllowed>
|
||||
</ip>
|
||||
<descr type="TextField"/>
|
||||
<comments type="TextField"/>
|
||||
<!-- Intentionally last, AliasesField back references other fields (which should already be there) -->
|
||||
<aliases type=".\AliasesField">
|
||||
<AsList>Y</AsList>
|
||||
<FieldSeparator>,</FieldSeparator>
|
||||
<IsDNSName>Y</IsDNSName>
|
||||
<IpAllowed>N</IpAllowed>
|
||||
</aliases>
|
||||
</hosts>
|
||||
<domainoverrides type="ArrayField">
|
||||
<domain type="HostnameField">
|
||||
<IsDNSName>Y</IsDNSName>
|
||||
<IpAllowed>N</IpAllowed>
|
||||
<Required>Y</Required>
|
||||
</domain>
|
||||
<srcip type="NetworkField">
|
||||
<NetMaskAllowed>N</NetMaskAllowed>
|
||||
</srcip>
|
||||
<port type="PortField"/>
|
||||
<!-- Intentionally last, DomainIPField back references other fields (which should already be there) -->
|
||||
<ip type=".\DomainIPField">
|
||||
<NetMaskAllowed>N</NetMaskAllowed>
|
||||
</ip>
|
||||
<descr type="TextField"/>
|
||||
</domainoverrides>
|
||||
</items>
|
||||
</model>
|
||||
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2025 Deciso B.V.
|
||||
* 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\Dnsmasq\FieldTypes;
|
||||
|
||||
use OPNsense\Base\FieldTypes\HostnameField;
|
||||
|
||||
class AliasesField extends HostnameField
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
if (is_a($value, 'SimpleXMLElement') && isset($value->item)) {
|
||||
/* auto convert to simple text blob */
|
||||
$tmp = [];
|
||||
$comments = [];
|
||||
foreach ($value->item as $child) {
|
||||
if (empty((string)$child->domain)) {
|
||||
continue;
|
||||
}
|
||||
if (!empty((string)$child->host)) {
|
||||
$fqdn = sprintf("%s.%s", $child->host, $child->domain);
|
||||
} else {
|
||||
$fqdn = (string)$child->domain;
|
||||
}
|
||||
$tmp[] = $fqdn;
|
||||
if (!empty((string)$child->description)) {
|
||||
$comments[] = sprintf("[%s] %s", $fqdn, $child->description);
|
||||
}
|
||||
}
|
||||
$this->getParentNode()->comments = implode("\n", $comments);
|
||||
return parent::setValue(implode(",", $tmp));
|
||||
} elseif (!empty($value)) {
|
||||
/* update only */
|
||||
return parent::setValue($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2025 Deciso B.V.
|
||||
* 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\Dnsmasq\FieldTypes;
|
||||
|
||||
use OPNsense\Base\FieldTypes\NetworkField;
|
||||
|
||||
class DomainIPField extends NetworkField
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
if (is_a($value, 'SimpleXMLElement')) {
|
||||
if (strpos((string)$value, '#') > 1 || strpos((string)$value, '@') > 1) {
|
||||
/* convert legacy input */
|
||||
$parts = explode("@", (string)$value);
|
||||
if (count($parts) > 1) {
|
||||
$this->getParentNode()->srcip = $parts[1];
|
||||
}
|
||||
$parts = explode("#", $parts[0]);
|
||||
if (count($parts) > 1) {
|
||||
$this->getParentNode()->port = $parts[1];
|
||||
}
|
||||
return parent::setValue($parts[0]);
|
||||
} else {
|
||||
return parent::setValue($value);
|
||||
}
|
||||
} elseif ($value == '!') {
|
||||
return parent::setValue('');
|
||||
} elseif (!empty($value)) {
|
||||
/* update only */
|
||||
return parent::setValue($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,7 @@
|
||||
<menu>
|
||||
<Services>
|
||||
<Dnsmasq VisibleName="Dnsmasq DNS" cssClass="fa fa-tags fa-fw">
|
||||
<Settings order="10" url="/services_dnsmasq.php">
|
||||
<Hosts url="/services_dnsmasq_edit.php*" visibility="hidden"/>
|
||||
<Domains url="/services_dnsmasq_domainoverride_edit.php*" visibility="hidden"/>
|
||||
</Settings>
|
||||
<Settings order="10" url="/ui/dnsmasq"/>
|
||||
<LogFile VisibleName="Log File" order="50" url="/ui/diagnostics/log/core/dnsmasq"/>
|
||||
</Dnsmasq>
|
||||
</Services>
|
||||
|
||||
105
src/opnsense/mvc/app/views/OPNsense/Dnsmasq/index.volt
Normal file
105
src/opnsense/mvc/app/views/OPNsense/Dnsmasq/index.volt
Normal file
@ -0,0 +1,105 @@
|
||||
{#
|
||||
# Copyright (c) 2025 Deciso B.V.
|
||||
# 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.
|
||||
#}
|
||||
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
let data_get_map = {'frm_settings':"/api/dnsmasq/settings/get"};
|
||||
mapDataToFormUI(data_get_map).done(function(data){
|
||||
formatTokenizersUI();
|
||||
$('.selectpicker').selectpicker('refresh');
|
||||
updateServiceControlUI('dnsmasq');
|
||||
});
|
||||
|
||||
$("#{{formGridHostOverride['table_id']}}").UIBootgrid({
|
||||
'search':'/api/dnsmasq/settings/search_host',
|
||||
'get':'/api/dnsmasq/settings/get_host/',
|
||||
'set':'/api/dnsmasq/settings/set_host/',
|
||||
'add':'/api/dnsmasq/settings/add_host/',
|
||||
'del':'/api/dnsmasq/settings/del_host/'
|
||||
});
|
||||
|
||||
$("#{{formGridDomainOverride['table_id']}}").UIBootgrid({
|
||||
'search':'/api/dnsmasq/settings/search_domain',
|
||||
'get':'/api/dnsmasq/settings/get_domain/',
|
||||
'set':'/api/dnsmasq/settings/set_domain/',
|
||||
'add':'/api/dnsmasq/settings/add_domain/',
|
||||
'del':'/api/dnsmasq/settings/del_domain/'
|
||||
});
|
||||
|
||||
|
||||
$("#reconfigureAct").SimpleActionButton({
|
||||
onPreAction: function() {
|
||||
const dfObj = new $.Deferred();
|
||||
saveFormToEndpoint("/api/dnsmasq/settings/set", 'frm_settings', function () { dfObj.resolve(); }, true, function () { dfObj.reject(); });
|
||||
return dfObj;
|
||||
},
|
||||
onAction: function(data, status) {
|
||||
updateServiceControlUI('dnsmasq');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Navigation bar -->
|
||||
<ul class="nav nav-tabs" data-tabs="tabs" id="maintabs">
|
||||
<li class="active"><a data-toggle="tab" href="#general">{{ lang._('General') }}</a></li>
|
||||
<li><a data-toggle="tab" href="#hosts">{{ lang._('Hosts') }}</a></li>
|
||||
<li><a data-toggle="tab" href="#domains">{{ lang._('Domains') }}</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content content-box">
|
||||
<!-- general settings -->
|
||||
<div id="general" class="tab-pane fade in active">
|
||||
{{ partial("layout_partials/base_form",['fields':generalForm,'id':'frm_settings'])}}
|
||||
</div>
|
||||
<!-- Tab: Hosts -->
|
||||
<div id="hosts" class="tab-pane fade in">
|
||||
{{ partial('layout_partials/base_bootgrid_table', formGridHostOverride)}}
|
||||
</div>
|
||||
<!-- Tab: Domains -->
|
||||
<div id="domains" class="tab-pane fade in">
|
||||
{{ partial('layout_partials/base_bootgrid_table', formGridDomainOverride)}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="page-content-main">
|
||||
<div class="content-box">
|
||||
<div class="col-md-12">
|
||||
<br/>
|
||||
<button class="btn btn-primary" id="reconfigureAct"
|
||||
data-endpoint='/api/dnsmasq/service/reconfigure'
|
||||
data-label="{{ lang._('Apply') }}"
|
||||
data-error-title="{{ lang._('Error reconfiguring Dnsmasq') }}"
|
||||
type="button"
|
||||
></button>
|
||||
<br/><br/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
{{ partial("layout_partials/base_dialog",['fields':formDialogEditHostOverride,'id':formGridHostOverride['edit_dialog_id'],'label':lang._('Edit Host Override')])}}
|
||||
{{ partial("layout_partials/base_dialog",['fields':formDialogEditDomainOverride,'id':formGridDomainOverride['edit_dialog_id'],'label':lang._('Edit Domain Override')])}}
|
||||
24
src/opnsense/service/conf/actions.d/actions_dnsmasq.conf
Normal file
24
src/opnsense/service/conf/actions.d/actions_dnsmasq.conf
Normal file
@ -0,0 +1,24 @@
|
||||
[start]
|
||||
command:/usr/local/sbin/pluginctl -s dnsmasq start
|
||||
parameters:
|
||||
type:script
|
||||
message:Starting Dnsmasq
|
||||
|
||||
[stop]
|
||||
command:/usr/local/sbin/pluginctl -s dnsmasq stop
|
||||
parameters:
|
||||
type:script
|
||||
message:Stopping Dnsmasq
|
||||
|
||||
[restart]
|
||||
command:/usr/local/sbin/pluginctl -s dnsmasq restart
|
||||
parameters:
|
||||
type:script
|
||||
message:Restarting Dnsmasq
|
||||
description:Restart Dnsmasq DNS service
|
||||
|
||||
[status]
|
||||
command:/usr/local/sbin/pluginctl -s dnsmasq status
|
||||
parameters:
|
||||
type:script_output
|
||||
message:Request Dnsmasq status
|
||||
@ -155,7 +155,7 @@ if (!empty($_POST['secondarydnsserver']) && !is_ipaddrv4($_POST['secondarydnsser
|
||||
if (!empty($input_errors)) {
|
||||
$stepid--;
|
||||
} else {
|
||||
if (isset($config['dnsmasq']['enable'])) {
|
||||
if (!empty($config['dnsmasq']['enable'])) {
|
||||
unset($config['dnsmasq']['enable']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,546 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014-2016 Deciso B.V.
|
||||
* Copyright (C) 2003-2004 Bob Zoller <bob@kludgebox.com>
|
||||
* Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>
|
||||
* 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.
|
||||
*/
|
||||
|
||||
require_once("guiconfig.inc");
|
||||
require_once("interfaces.inc");
|
||||
require_once("filter.inc");
|
||||
require_once("system.inc");
|
||||
require_once("plugins.inc.d/dnsmasq.inc");
|
||||
|
||||
$a_dnsmasq = &config_read_array('dnsmasq');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
$pconfig = array();
|
||||
// booleans
|
||||
$pconfig['enable'] = isset($a_dnsmasq['enable']);
|
||||
$pconfig['regdhcp'] = isset($a_dnsmasq['regdhcp']);
|
||||
$pconfig['regdhcpdomain'] = !empty($a_dnsmasq['regdhcpdomain']) ? $a_dnsmasq['regdhcpdomain'] : null;
|
||||
$pconfig['regdhcpstatic'] = isset($a_dnsmasq['regdhcpstatic']);
|
||||
$pconfig['dhcpfirst'] = isset($a_dnsmasq['dhcpfirst']);
|
||||
$pconfig['strict_order'] = isset($a_dnsmasq['strict_order']);
|
||||
$pconfig['domain_needed'] = isset($a_dnsmasq['domain_needed']);
|
||||
$pconfig['no_private_reverse'] = isset($a_dnsmasq['no_private_reverse']);
|
||||
$pconfig['strictbind'] = isset($a_dnsmasq['strictbind']);
|
||||
$pconfig['dnssec'] = isset($a_dnsmasq['dnssec']);
|
||||
$pconfig['log_queries'] = isset($a_dnsmasq['log_queries']);
|
||||
$pconfig['no_hosts'] = isset($a_dnsmasq['no_hosts']);
|
||||
// simple text types
|
||||
$pconfig['port'] = !empty($a_dnsmasq['port']) ? $a_dnsmasq['port'] : "";
|
||||
$pconfig['dns_forward_max'] = !empty($a_dnsmasq['dns_forward_max']) ? $a_dnsmasq['dns_forward_max'] : "";
|
||||
$pconfig['cache_size'] = isset($a_dnsmasq['cache_size']) ? $a_dnsmasq['cache_size'] : '';
|
||||
$pconfig['local_ttl'] = isset($a_dnsmasq['local_ttl']) ? $a_dnsmasq['local_ttl'] : '';
|
||||
// arrays
|
||||
$pconfig['interface'] = !empty($a_dnsmasq['interface']) ? explode(",", $a_dnsmasq['interface']) : array();
|
||||
|
||||
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$pconfig = $_POST;
|
||||
$input_errors = array();
|
||||
if (isset($pconfig['submit'])) {
|
||||
// validate
|
||||
if (!empty($pconfig['regdhcpdomain']) && !is_domain($pconfig['regdhcpdomain'])) {
|
||||
$input_errors[] = gettext("The domain may only contain the characters a-z, 0-9, '-' and '.'.");
|
||||
}
|
||||
if (!empty($pconfig['port']) && !is_port($pconfig['port'])) {
|
||||
$input_errors[] = gettext("You must specify a valid port number");
|
||||
}
|
||||
if (!empty($pconfig['dns_forward_max']) && !is_numericint($pconfig['dns_forward_max'])) {
|
||||
$input_errors[] = gettext("You must specify a valid maximum number of DNS queries");
|
||||
}
|
||||
if (isset($pconfig['cache_size']) && $pconfig['cache_size'] !== '') {
|
||||
if (!is_numericint($pconfig['cache_size'])) {
|
||||
$input_errors[] = gettext("You must specify a valid cache size");
|
||||
} elseif (!empty($pconfig['dnssec']) && $pconfig['cache_size'] < 150) {
|
||||
$input_errors[] = gettext("You must specify a valid cache size of at least 150 when DNSSEC is enabled");
|
||||
}
|
||||
}
|
||||
if (isset($pconfig['local_ttl']) && $pconfig['local_ttl'] !== '' && !is_numericint($pconfig['local_ttl'])) {
|
||||
$input_errors[] = gettext("You must specify a valid TTL for local DNS");
|
||||
}
|
||||
|
||||
$dnsmasq_port = empty($pconfig['port']) ? "53" : $pconfig['port'];
|
||||
$port_conflict = service_by_filter(['dns_ports' => $dnsmasq_port]);
|
||||
if (!empty($pconfig['enable']) && !empty($port_conflict) && $port_conflict['name'] != 'dnsmasq') {
|
||||
$input_errors[] = sprintf(gettext('%s is currently using this port.'), $port_conflict['description']);
|
||||
}
|
||||
|
||||
if (count($input_errors) == 0) {
|
||||
// save form
|
||||
$a_dnsmasq['enable'] = !empty($pconfig['enable']);
|
||||
$a_dnsmasq['regdhcp'] = !empty($pconfig['regdhcp']);
|
||||
$a_dnsmasq['regdhcpstatic'] = !empty($pconfig['regdhcpstatic']);
|
||||
$a_dnsmasq['dhcpfirst'] = !empty($pconfig['dhcpfirst']);
|
||||
$a_dnsmasq['strict_order'] = !empty($pconfig['strict_order']);
|
||||
$a_dnsmasq['domain_needed'] = !empty($pconfig['domain_needed']);
|
||||
$a_dnsmasq['no_private_reverse'] = !empty($pconfig['no_private_reverse']);
|
||||
$a_dnsmasq['log_queries'] = !empty($pconfig['log_queries']);
|
||||
$a_dnsmasq['no_hosts'] = !empty($pconfig['no_hosts']);
|
||||
$a_dnsmasq['strictbind'] = !empty($pconfig['strictbind']);
|
||||
$a_dnsmasq['dnssec'] = !empty($pconfig['dnssec']);
|
||||
if (!empty($pconfig['regdhcpdomain'])) {
|
||||
$a_dnsmasq['regdhcpdomain'] = $pconfig['regdhcpdomain'];
|
||||
} elseif (isset($a_dnsmasq['regdhcpdomain'])) {
|
||||
unset($a_dnsmasq['regdhcpdomain']);
|
||||
}
|
||||
if (!empty($pconfig['interface'])) {
|
||||
$a_dnsmasq['interface'] = implode(",", $pconfig['interface']);
|
||||
} elseif (isset($a_dnsmasq['interface'])) {
|
||||
unset($a_dnsmasq['interface']);
|
||||
}
|
||||
if (!empty($pconfig['port'])) {
|
||||
$a_dnsmasq['port'] = $pconfig['port'];
|
||||
} elseif (isset($a_dnsmasq['port'])) {
|
||||
unset($a_dnsmasq['port']);
|
||||
}
|
||||
if (!empty($pconfig['dns_forward_max'])) {
|
||||
$a_dnsmasq['dns_forward_max'] = $pconfig['dns_forward_max'];
|
||||
} elseif (isset($a_dnsmasq['dns_forward_max'])) {
|
||||
unset($a_dnsmasq['dns_forward_max']);
|
||||
}
|
||||
if (isset($pconfig['cache_size']) && $pconfig['cache_size'] !== '') {
|
||||
$a_dnsmasq['cache_size'] = $pconfig['cache_size'];
|
||||
} elseif (isset($a_dnsmasq['cache_size'])) {
|
||||
unset($a_dnsmasq['cache_size']);
|
||||
}
|
||||
if (isset($pconfig['local_ttl'])&& $pconfig['local_ttl'] !== '') {
|
||||
$a_dnsmasq['local_ttl'] = $pconfig['local_ttl'];
|
||||
} elseif (isset($a_dnsmasq['local_ttl'])) {
|
||||
unset($a_dnsmasq['local_ttl']);
|
||||
}
|
||||
|
||||
write_config();
|
||||
|
||||
system_resolver_configure();
|
||||
dnsmasq_configure_do();
|
||||
plugins_configure('dhcp');
|
||||
|
||||
header(url_safe('Location: /services_dnsmasq.php'));
|
||||
exit;
|
||||
}
|
||||
} elseif (isset($pconfig['apply'])) {
|
||||
filter_configure();
|
||||
system_resolver_configure();
|
||||
dnsmasq_configure_do();
|
||||
plugins_configure('dhcp');
|
||||
clear_subsystem_dirty('hosts');
|
||||
header(url_safe('Location: /services_dnsmasq.php'));
|
||||
exit;
|
||||
} elseif (!empty($pconfig['act']) && $pconfig['act'] == 'del') {
|
||||
$a_hosts = &config_read_array('dnsmasq', 'hosts');
|
||||
if (isset($pconfig['id']) && !empty($a_hosts[$pconfig['id']])) {
|
||||
unset($a_hosts[$pconfig['id']]);
|
||||
write_config();
|
||||
mark_subsystem_dirty('hosts');
|
||||
/* ajax call, do not redirect */
|
||||
exit;
|
||||
}
|
||||
} elseif (!empty($pconfig['act']) && $pconfig['act'] == 'doverride') {
|
||||
$a_domainOverrides = &config_read_array('dnsmasq', 'domainoverrides');
|
||||
if (isset($pconfig['id']) && !empty($a_domainOverrides[$pconfig['id']])) {
|
||||
unset($a_domainOverrides[$pconfig['id']]);
|
||||
write_config();
|
||||
mark_subsystem_dirty('hosts');
|
||||
/* ajax call, do not redirect */
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
legacy_html_escape_form_data($pconfig);
|
||||
|
||||
$service_hook = 'dnsmasq';
|
||||
|
||||
include("head.inc");
|
||||
|
||||
?>
|
||||
<body>
|
||||
|
||||
<script>
|
||||
//<![CDATA[
|
||||
$( document ).ready(function() {
|
||||
// delete host action
|
||||
$(".act_delete_host").click(function(event){
|
||||
event.preventDefault();
|
||||
var id = $(this).data("id");
|
||||
// delete single
|
||||
BootstrapDialog.show({
|
||||
type:BootstrapDialog.TYPE_DANGER,
|
||||
title: "<?= gettext('Dnsmasq') ?>",
|
||||
message: "<?=gettext("Do you really want to delete this host?");?>",
|
||||
buttons: [{
|
||||
label: "<?= gettext("No");?>",
|
||||
action: function(dialogRef) {
|
||||
dialogRef.close();
|
||||
}}, {
|
||||
label: "<?= gettext("Yes");?>",
|
||||
action: function(dialogRef) {
|
||||
$.post(window.location, {act: 'del', id:id}, function(data) {
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
||||
$(".act_delete_override").click(function(event){
|
||||
event.preventDefault();
|
||||
var id = $(this).data("id");
|
||||
// delete single
|
||||
BootstrapDialog.show({
|
||||
type:BootstrapDialog.TYPE_DANGER,
|
||||
title: "<?= gettext('Dnsmasq') ?>",
|
||||
message: "<?=gettext("Do you really want to delete this domain override?");?>",
|
||||
buttons: [{
|
||||
label: "<?= gettext("No");?>",
|
||||
action: function(dialogRef) {
|
||||
dialogRef.close();
|
||||
}}, {
|
||||
label: "<?= gettext("Yes");?>",
|
||||
action: function(dialogRef) {
|
||||
$.post(window.location, {act: 'doverride', id:id}, function(data) {
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
}]
|
||||
});
|
||||
});
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
<?php include("fbegin.inc"); ?>
|
||||
|
||||
<section class="page-content-main">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?>
|
||||
<?php if (is_subsystem_dirty('hosts')): ?>
|
||||
<?php print_info_box_apply(gettext('The Dnsmasq configuration has been changed.') . ' ' . gettext('You must apply the changes in order for them to take effect.')) ?>
|
||||
<?php endif; ?>
|
||||
<section class="col-xs-12">
|
||||
<div class="content-box">
|
||||
<form method="post" name="iform" id="iform">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped opnsense_standard_table_form">
|
||||
<tr>
|
||||
<td style="width:22%"><strong><?=gettext("General options");?></strong></td>
|
||||
<td style="width:78%;text-align:right">
|
||||
<small><?=gettext("full help");?> </small>
|
||||
<i class="fa fa-toggle-off text-danger" style="cursor: pointer;" id="show_all_help_page"></i>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:22%"><i class="fa fa-info-circle text-muted"></i> <?=gettext("Enable");?></td>
|
||||
<td style="width:78%">
|
||||
<input name="enable" type="checkbox" id="enable" value="yes" <?=!empty($pconfig['enable']) ? "checked=\"checked\"" : "";?> />
|
||||
<?= gettext('Enable Dnsmasq') ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_port" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Listen Port");?></td>
|
||||
<td>
|
||||
<input name="port" type="text" id="port" size="6" placeholder="53" <?=!empty($pconfig['port']) ? "value=\"{$pconfig['port']}\"" : "";?> />
|
||||
<div class="hidden" data-for="help_for_port">
|
||||
<?=gettext("The port used for responding to DNS queries. It should normally be left blank unless another service needs to bind to TCP/UDP port 53.");?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_interfaces" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?= gettext('Network Interfaces') ?></td>
|
||||
<td>
|
||||
<select id="interface" name="interface[]" multiple="multiple" class="selectpicker" title="<?= html_safe(gettext('All (recommended)')) ?>">
|
||||
<?php foreach (get_configured_interface_with_descr() as $iface => $ifacename): ?>
|
||||
<option value="<?= html_safe($iface) ?>" <?=!empty($pconfig['interface']) && in_array($iface, $pconfig['interface']) ? 'selected="selected"' : "" ?>>
|
||||
<?= html_safe($ifacename) ?>
|
||||
</option>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
<div class="hidden" data-for="help_for_interfaces">
|
||||
<?=gettext("Interface IPs used by Dnsmasq for responding to queries from clients. If an interface has both IPv4 and IPv6 IPs, both are used. Queries to other interface IPs not selected below are discarded. The default behavior is to respond to queries on every available IPv4 and IPv6 address.");?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_strictbind" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Bind Mode') ?></td>
|
||||
<td>
|
||||
<input name="strictbind" type="checkbox" id="strictbind" value="yes" <?= !empty($pconfig['strictbind']) ? "checked=\"checked\"" : "";?> />
|
||||
<?= gettext('Strict Interface Binding') ?>
|
||||
<div class="hidden" data-for="help_for_strictbind">
|
||||
<?= gettext("If this option is set, Dnsmasq will only bind to the interfaces containing the IP addresses selected above, rather than binding to all interfaces and discarding queries to other addresses."); ?>
|
||||
<?= gettext("This option does not work with IPv6. If set, Dnsmasq will not bind to IPv6 addresses."); ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext('DNSSEC') ?></td>
|
||||
<td>
|
||||
<input name="dnssec" type="checkbox" value="yes" <?=!empty($pconfig['dnssec']) ? 'checked="checked"' : '' ?> />
|
||||
<?= gettext('Enable DNSSEC Support') ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_regdhcp" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Register ISC DHCP4 Leases");?></td>
|
||||
<td>
|
||||
<input name="regdhcp" type="checkbox" id="regdhcp" value="yes" <?=!empty($pconfig['regdhcp']) ? "checked=\"checked\"" : "";?> />
|
||||
<?= gettext('Register DHCP leases') ?>
|
||||
<div class="hidden" data-for="help_for_regdhcp">
|
||||
<?= gettext("If this option is set, then machines that specify " .
|
||||
"their hostname when requesting a DHCP lease will be registered " .
|
||||
"in Dnsmasq, so that their name can be resolved.") ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_regdhcpdomain" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("DHCP Domain Override");?></td>
|
||||
<td>
|
||||
<input name="regdhcpdomain" type="text" id="regdhcpdomain" value="<?= $pconfig['regdhcpdomain'] ?>"/>
|
||||
<div class="hidden" data-for="help_for_regdhcpdomain">
|
||||
<?= gettext("The domain name to use for DHCP hostname registration. " .
|
||||
"If empty, the default system domain is used. Note that all DHCP " .
|
||||
"leases will be assigned to the same domain. If this is undesired, " .
|
||||
"static DHCP lease registration is able to provide coherent mappings.") ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_regdhcpstatic" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Register DHCP Static Mappings");?></td>
|
||||
<td>
|
||||
<input name="regdhcpstatic" type="checkbox" id="regdhcpstatic" value="yes" <?=!empty($pconfig['regdhcpstatic']) ? "checked=\"checked\"" : "";?> />
|
||||
<?= gettext('Register DHCP static mappings') ?>
|
||||
<div class="hidden" data-for="help_for_regdhcpstatic">
|
||||
<?= sprintf(gettext("If this option is set, then DHCP static mappings will ".
|
||||
"be registered in Dnsmasq, so that their name can be ".
|
||||
"resolved. You should also set the domain in %s".
|
||||
"System: Settings: General%s to the proper value."),'<a href="system_general.php">','</a>');?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_dhcpfirst" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Prefer DHCP");?></td>
|
||||
<td>
|
||||
<input name="dhcpfirst" type="checkbox" id="dhcpfirst" value="yes" <?=!empty($pconfig['dhcpfirst']) ? "checked=\"checked\"" : "";?> />
|
||||
<?= gettext('Resolve DHCP mappings first') ?>
|
||||
<div class="hidden" data-for="help_for_dhcpfirst">
|
||||
<?= sprintf(gettext("If this option is set, then DHCP mappings will ".
|
||||
"be resolved before the manual list of names below. This only ".
|
||||
"affects the name given for a reverse lookup (PTR)."));?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_strict_order" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("DNS Query Forwarding");?></td>
|
||||
<td>
|
||||
<input name="strict_order" type="checkbox" id="strict_order" value="yes" <?=!empty($pconfig['strict_order']) ? "checked=\"checked\"" : "";?> />
|
||||
<?= gettext('Query DNS servers sequentially') ?>
|
||||
<div class="hidden" data-for="help_for_strict_order">
|
||||
<?= gettext("If this option is set, Dnsmasq will ".
|
||||
"query the DNS servers sequentially in the order specified (System: " .
|
||||
"General Setup: DNS Servers), rather than all at once in parallel.") ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<input name="domain_needed" type="checkbox" id="domain_needed" value="yes" <?=!empty($pconfig['domain_needed']) ? "checked=\"checked\"" : "";?> />
|
||||
<?= gettext('Require domain') ?>
|
||||
<div class="hidden" data-for="help_for_strict_order">
|
||||
<?= gettext('If this option is set, Dnsmasq will '.
|
||||
'not forward A or AAAA queries for plain names, without dots or ' .
|
||||
'domain parts, to upstream name servers. If the name is not known ' .
|
||||
'from /etc/hosts or DHCP then a "not found" answer is returned.') ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<input name="no_private_reverse" type="checkbox" id="no_private_reverse" value="yes" <?=!empty($pconfig['no_private_reverse']) ? "checked=\"checked\"" : "";?> />
|
||||
<?= gettext('Do not forward private reverse lookups') ?>
|
||||
<div class="hidden" data-for="help_for_strict_order">
|
||||
<?= gettext('If this option is set, Dnsmasq will '.
|
||||
'not forward reverse DNS lookups (PTR) for private addresses ' .
|
||||
'(RFC 1918) to upstream name servers. Any entries in the Domain ' .
|
||||
'Overrides section forwarding private "n.n.n.in-addr.arpa" names ' .
|
||||
'to a specific server are still forwarded. If the IP to name is ' .
|
||||
'not known from /etc/hosts, DHCP or a specific domain override ' .
|
||||
'then a "not found" answer is immediately returned.') ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext('No Hosts Lookup') ?></td>
|
||||
<td>
|
||||
<input name="no_hosts" type="checkbox" id="no_hosts" value="yes" <?= !empty($pconfig['no_hosts']) ? 'checked="checked"' : '' ?> />
|
||||
<?= gettext('Do not read hostnames in /etc/hosts') ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext('Log Queries') ?></td>
|
||||
<td>
|
||||
<input name="log_queries" type="checkbox" id="log_queries" value="yes" <?= !empty($pconfig['log_queries']) ? 'checked="checked"' : '' ?> />
|
||||
<?= gettext('Log the results of DNS queries') ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_dns_forward_max" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?= gettext('Maximum concurrent queries') ?></td>
|
||||
<td>
|
||||
<input name="dns_forward_max" type="text" id="dns_forward_max" size="6" placeholder="5000" <?= !empty($pconfig['dns_forward_max']) ? 'value="' . html_safe($pconfig['dns_forward_max']) . '"' : '' ?> />
|
||||
<div class="hidden" data-for="help_for_dns_forward_max">
|
||||
<?= gettext('Set the maximum number of concurrent DNS queries. On configurations with tight resources, this value may need to be reduced.') ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_cache_size" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?= gettext('Cache size') ?></td>
|
||||
<td>
|
||||
<input name="cache_size" type="text" id="cache_size" size="8" placeholder="10000" value="<?= html_safe($pconfig['cache_size']) ?>" />
|
||||
<div class="hidden" data-for="help_for_cache_size">
|
||||
<?= gettext('Set the size of the cache. Setting the cache size to zero disables caching. Please note that huge cache size impacts performance.') ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_local_ttl" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?= gettext('Local DNS entry TTL') ?></td>
|
||||
<td>
|
||||
<input name="local_ttl" type="text" id="local_ttl" size="5" placeholder="1" value="<?= html_safe($pconfig['local_ttl']) ?>"/>
|
||||
<div class="hidden" data-for="help_for_local_ttl">
|
||||
<?=gettext("This option allows a time-to-live (in seconds) to be given for local DNS entries, i.e. /etc/hosts or DHCP leases. This will reduce the load on the server at the expense of clients using stale data under some circumstances. A value of zero will disable client-side caching.");?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<input name="submit" type="submit" class="btn btn-primary" value="<?=html_safe(gettext('Save')); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
<section class="col-xs-12">
|
||||
<div class="content-box">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="5"><strong><?= gettext('Host Overrides') ?></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong><?= gettext('Host') ?></strong></td>
|
||||
<td><strong><?= gettext('Domain') ?></strong></td>
|
||||
<td><strong><?= gettext('IP') ?></strong></td>
|
||||
<td><strong><?= gettext('Description') ?></strong></td>
|
||||
<td class="text-nowrap">
|
||||
<a href="services_dnsmasq_edit.php" class="btn btn-primary btn-xs"><i class="fa fa-plus fa-fw"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php foreach (config_read_array('dnsmasq', 'hosts') as $i => $hostent): ?>
|
||||
<tr>
|
||||
<td><?=htmlspecialchars(strtolower($hostent['host']));?></td>
|
||||
<td><?=htmlspecialchars(strtolower($hostent['domain']));?></td>
|
||||
<td><?=htmlspecialchars($hostent['ip']);?></td>
|
||||
<td><?=htmlspecialchars($hostent['descr']);?></td>
|
||||
<td class="text-nowrap">
|
||||
<a href="services_dnsmasq_edit.php?id=<?=$i;?>" class="btn btn-default btn-xs"><i class="fa fa-pencil fa-fw"></i></a>
|
||||
<a href="#" data-id="<?=$i;?>" class="act_delete_host btn btn-xs btn-default"><i class="fa fa-trash fa-fw"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if (isset($hostent['aliases']['item'])): ?>
|
||||
<?php foreach ($hostent['aliases']['item'] as $alias): ?>
|
||||
<tr>
|
||||
<td><?=htmlspecialchars(strtolower($alias['host']));?></td>
|
||||
<td><?=htmlspecialchars(strtolower($alias['domain']));?></td>
|
||||
<td><?=gettext("Alias for");?> <?=$hostent['host'] ? htmlspecialchars($hostent['host'] . '.' . $hostent['domain']) : htmlspecialchars($hostent['domain']);?></td>
|
||||
<td><?=htmlspecialchars($alias['description']);?></td>
|
||||
<td class="text-nowrap">
|
||||
<a href="services_dnsmasq_edit.php?id=<?=$i;?>" class="btn btn-default btn-xs"><i class="fa fa-pencil fa-fw"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
<?=gettext("Entries in this section override individual results from the forwarders.");?>
|
||||
<?=gettext("Use these for changing DNS results or for adding custom DNS records.");?>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="col-xs-12">
|
||||
<div class="content-box">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="4"><strong><?= gettext('Domain Overrides') ?></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong><?= gettext('Domain') ?><strong></td>
|
||||
<td><strong><?= gettext('IP') ?></strong></td>
|
||||
<td><strong><?= gettext('Description') ?></strong></td>
|
||||
<td class="text-nowrap">
|
||||
<a href="services_dnsmasq_domainoverride_edit.php" class="btn btn-primary btn-xs">
|
||||
<i class="fa fa-plus fa-fw"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php foreach (config_read_array('dnsmasq', 'domainoverrides') as $i => $doment): ?>
|
||||
<tr>
|
||||
<td><?=htmlspecialchars(strtolower($doment['domain']));?></td>
|
||||
<td><?=htmlspecialchars($doment['ip']);?></td>
|
||||
<td><?=htmlspecialchars($doment['descr']);?></td>
|
||||
<td class="text-nowrap">
|
||||
<a href="services_dnsmasq_domainoverride_edit.php?id=<?=$i;?>" class="btn btn-default btn-xs">
|
||||
<i class="fa fa-pencil fa-fw"></i>
|
||||
</a>
|
||||
<a href="#" data-id="<?=$i;?>" class="act_delete_override btn btn-xs btn-default"><i class="fa fa-trash fa-fw"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<?=gettext("Entries in this area override an entire domain, and subdomains, by specifying an authoritative DNS server to be queried for that domain.");?>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php include("foot.inc"); ?>
|
||||
@ -1,211 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014-2016 Deciso B.V.
|
||||
* Copyright (C) 2003-2005 Bob Zoller <bob@kludgebox.com>
|
||||
* Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>
|
||||
* 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.
|
||||
*/
|
||||
|
||||
require_once("guiconfig.inc");
|
||||
require_once("system.inc");
|
||||
require_once("interfaces.inc");
|
||||
require_once("plugins.inc.d/dnsmasq.inc");
|
||||
|
||||
$a_domainOverrides = &config_read_array('dnsmasq', 'domainoverrides');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
if (isset($_GET['id']) && !empty($a_domainOverrides[$_GET['id']])) {
|
||||
$id = $_GET['id'];
|
||||
}
|
||||
$pconfig = array();
|
||||
|
||||
$pconfig['domain'] = isset($id) && !empty($a_domainOverrides[$id]['domain']) ? $a_domainOverrides[$id]['domain'] : null;
|
||||
$pconfig['descr'] = !empty($a_domainOverrides[$id]['descr']) ? $a_domainOverrides[$id]['descr'] : null;
|
||||
if (!isset($id) || empty($a_domainOverrides[$id]['ip'])) {
|
||||
$pconfig['ip'] = null;
|
||||
$pconfig['dnssrcip'] = null;
|
||||
} elseif (!empty($a_domainOverrides[$id]['ip'])) {
|
||||
// parse ip string, it would be better to have different fields here, but we don't want to break backwards
|
||||
// compatibility.
|
||||
$parts = explode("@", $a_domainOverrides[$id]['ip']);
|
||||
if (count($parts) > 1) {
|
||||
$pconfig['dnssrcip'] = $parts[1];
|
||||
} else {
|
||||
$pconfig['dnssrcip'] = null;
|
||||
}
|
||||
$parts = explode("#", $parts[0]);
|
||||
if (count($parts) > 1) {
|
||||
$pconfig['port'] = $parts[1];
|
||||
} else {
|
||||
$pconfig['port'] = null;
|
||||
}
|
||||
$pconfig['ip'] = $parts[0];
|
||||
|
||||
}
|
||||
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (isset($_POST['id']) && !empty($a_domainOverrides[$_POST['id']])) {
|
||||
$id = $_POST['id'];
|
||||
}
|
||||
$input_errors= array();
|
||||
$pconfig = $_POST;
|
||||
|
||||
/* input validation */
|
||||
$reqdfields = explode(" ", "domain ip");
|
||||
$reqdfieldsn = array(gettext("Domain"),gettext("IP address"));
|
||||
|
||||
do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
|
||||
|
||||
if (!empty($pconfig['domain']) && substr($pconfig['domain'], 0, 6) == '_msdcs') {
|
||||
$subdomainstr = substr($pconfig['domain'], 7);
|
||||
if ($subdomainstr && !is_domain($subdomainstr)) {
|
||||
$input_errors[] = gettext("A valid domain must be specified after _msdcs.");
|
||||
}
|
||||
} elseif (!empty($pconfig['domain']) && !is_domain($_POST['domain'])) {
|
||||
$input_errors[] = gettext("A valid domain must be specified.");
|
||||
}
|
||||
if (!empty($pconfig['ip']) && !is_ipaddr($pconfig['ip']) && ($pconfig['ip'] != '#') && ($pconfig['ip'] != '!')) {
|
||||
$input_errors[] = gettext("A valid IP address must be specified, or # for an exclusion or ! to not forward at all.");
|
||||
}
|
||||
if (!empty($pconfig['port']) && !is_port($pconfig['port'])) {
|
||||
$input_errors[] = gettext("A valid port number must be specified.");
|
||||
}
|
||||
if (!empty($pconfig['dnssrcip']) && !in_array($pconfig['dnssrcip'], array_keys(get_configured_ip_addresses()))) {
|
||||
$input_errors[] = gettext("An interface IP address must be specified for the DNS query source.");
|
||||
}
|
||||
if (count($input_errors) == 0) {
|
||||
$doment = array();
|
||||
$doment['domain'] = $pconfig['domain'];
|
||||
$doment['ip'] = $pconfig['ip'];
|
||||
if (!empty($pconfig['port'])) {
|
||||
$doment['ip'] .= "#" . $pconfig['port'];
|
||||
}
|
||||
if (!empty($pconfig['dnssrcip'])) {
|
||||
$doment['ip'] .= "@" . $pconfig['dnssrcip'];
|
||||
}
|
||||
$doment['descr'] = $pconfig['descr'];
|
||||
|
||||
if (isset($id)) {
|
||||
$a_domainOverrides[$id] = $doment;
|
||||
} else {
|
||||
$a_domainOverrides[] = $doment;
|
||||
}
|
||||
dnsmasq_configure_do();
|
||||
plugins_configure('dhcp');
|
||||
write_config();
|
||||
header(url_safe('Location: /services_dnsmasq.php'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$service_hook = 'dnsmasq';
|
||||
legacy_html_escape_form_data($pconfig);
|
||||
include("head.inc");
|
||||
?>
|
||||
<body>
|
||||
<?php include("fbegin.inc"); ?>
|
||||
<section class="page-content-main">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?>
|
||||
<section class="col-xs-12">
|
||||
<div class="content-box">
|
||||
<form method="post" name="iform" id="iform">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped opnsense_standard_table_form">
|
||||
<tr>
|
||||
<td style="width:22%"><strong><?=gettext("Edit Domain Override entry");?></strong></td>
|
||||
<td style="width:78%; text-align:right">
|
||||
<small><?=gettext("full help"); ?> </small>
|
||||
<i class="fa fa-toggle-off text-danger" style="cursor: pointer;" id="show_all_help_page"></i>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:22%"><a id="help_for_domain" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Domain");?></td>
|
||||
<td style="width:78%">
|
||||
<input name="domain" type="text" value="<?=$pconfig['domain'];?>" />
|
||||
<div class="hidden" data-for="help_for_domain">
|
||||
<?=gettext("Domain to override (NOTE: this does not have to be a valid TLD!)"); ?><br />
|
||||
<?=gettext("e.g."); ?> <em><?=gettext("test"); ?></em> <?=gettext("or"); ?> <em>mycompany.localdomain</em> <?=gettext("or"); ?> <em>1.168.192.in-addr.arpa</em>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_ip" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("IP address");?></td>
|
||||
<td>
|
||||
<input name="ip" type="text" value="<?=$pconfig['ip'];?>" />
|
||||
<div class="hidden" data-for="help_for_ip">
|
||||
<?=gettext("IP address of the authoritative DNS server for this domain"); ?><br />
|
||||
<?=gettext("e.g."); ?> <em>192.168.100.100</em><br /><?=gettext("Or enter # for an exclusion to pass through this host/subdomain to standard nameservers instead of a previous override."); ?><br /><?=gettext("Or enter ! for lookups for this host/subdomain to NOT be forwarded anywhere."); ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_port" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Port");?></td>
|
||||
<td>
|
||||
<input name="port" type="text" value="<?=$pconfig['port'];?>" />
|
||||
<div class="hidden" data-for="help_for_port">
|
||||
<?=gettext("Specify a non standard port number here, leave blank for default"); ?><br />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_dnssrcip" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Source IP");?></td>
|
||||
<td>
|
||||
<input name="dnssrcip" type="text" value="<?=$pconfig['dnssrcip'];?>" />
|
||||
<div class="hidden" data-for="help_for_dnssrcip">
|
||||
<?=gettext("Source IP address for queries to the DNS server for the override domain."); ?><br />
|
||||
<?=gettext("Leave blank unless your DNS server is accessed through a VPN tunnel."); ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_descr" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Description");?></td>
|
||||
<td>
|
||||
<input name="descr" type="text" value="<?=$pconfig['descr'];?>" />
|
||||
<div class="hidden" data-for="help_for_descr">
|
||||
<?=gettext("You may enter a description here"." for your reference (not parsed).");?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<input name="Submit" type="submit" class="btn btn-primary" value="<?=html_safe(gettext('Save'));?>" />
|
||||
<input type="button" class="btn btn-default" value="<?=html_safe(gettext('Cancel'));?>" onclick="window.location.href='/services_dnsmasq.php'" />
|
||||
<?php if (isset($id)): ?>
|
||||
<input name="id" type="hidden" value="<?=$id;?>" />
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<?php include("foot.inc"); ?>
|
||||
@ -1,295 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014-2016 Deciso B.V.
|
||||
* Copyright (C) 2003-2004 Bob Zoller <bob@kludgebox.com>
|
||||
* Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>
|
||||
* 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.
|
||||
*/
|
||||
|
||||
require_once("guiconfig.inc");
|
||||
require_once("interfaces.inc");
|
||||
|
||||
$a_hosts = &config_read_array('dnsmasq', 'hosts');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
if (isset($_GET['id']) && !empty($a_hosts[$_GET['id']])) {
|
||||
$id = $_GET['id'];
|
||||
}
|
||||
$config_copy_fieldnames = array('host', 'domain', 'ip', 'descr', 'aliases');
|
||||
foreach ($config_copy_fieldnames as $fieldname) {
|
||||
if (isset($id) && isset($a_hosts[$id][$fieldname])) {
|
||||
$pconfig[$fieldname] = $a_hosts[$id][$fieldname];
|
||||
} else {
|
||||
$pconfig[$fieldname] = null;
|
||||
}
|
||||
}
|
||||
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (isset($_POST['id']) && !empty($a_hosts[$_POST['id']])) {
|
||||
$id = $_POST['id'];
|
||||
}
|
||||
$input_errors = array();
|
||||
$pconfig = $_POST;
|
||||
|
||||
$pconfig['aliases'] = array();
|
||||
if (isset($pconfig['aliases_host'])) {
|
||||
$pconfig['aliases']['item'] = array();
|
||||
foreach ($pconfig['aliases_host'] as $opt_seq => $opt_host) {
|
||||
if (!empty($opt_host)) {
|
||||
$pconfig['aliases']['item'][] = array(
|
||||
'description' => $pconfig['aliases_description'][$opt_seq],
|
||||
'domain' => $pconfig['aliases_domain'][$opt_seq],
|
||||
'host' => $opt_host,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* input validation */
|
||||
$reqdfields = explode(" ", "domain ip");
|
||||
$reqdfieldsn = array(gettext("Domain"),gettext("IP address"));
|
||||
|
||||
do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
|
||||
|
||||
if (!empty($pconfig['host']) && !is_hostname($pconfig['host'])) {
|
||||
$input_errors[] = gettext("The hostname can only contain the characters A-Z, 0-9 and '-'.");
|
||||
}
|
||||
if (!empty($pconfig['domain']) && !is_domain($pconfig['domain'])) {
|
||||
$input_errors[] = gettext("A valid domain must be specified.");
|
||||
}
|
||||
|
||||
if (!empty($pconfig['ip']) && !is_ipaddr($pconfig['ip'])) {
|
||||
$input_errors[] = gettext("A valid IP address must be specified.");
|
||||
}
|
||||
|
||||
/* validate aliases */
|
||||
foreach ($pconfig['aliases']['item'] as $idx => $alias) {
|
||||
$aliasreqdfields = array('domain');
|
||||
$aliasreqdfieldsn = array(gettext("Alias Domain"));
|
||||
|
||||
do_input_validation($alias, $aliasreqdfields, $aliasreqdfieldsn, $input_errors);
|
||||
if (!empty($alias['host']) && !is_hostname($alias['host'])) {
|
||||
$input_errors[] = gettext("Hostnames in alias list can only contain the characters A-Z, 0-9 and '-'.");
|
||||
}
|
||||
if (!empty($alias['domain']) && !is_domain($alias['domain'])) {
|
||||
$input_errors[] = gettext("A valid domain must be specified in alias list.");
|
||||
}
|
||||
}
|
||||
|
||||
/* check for overlaps */
|
||||
foreach ($a_hosts as $hostent) {
|
||||
if (isset($id) && $a_hosts[$id] === $hostent) {
|
||||
continue;
|
||||
}
|
||||
if (($hostent['host'] == $pconfig['host']) && ($hostent['domain'] == $pconfig['domain'])
|
||||
&& ((is_ipaddrv4($hostent['ip']) && is_ipaddrv4($pconfig['ip'])) || (is_ipaddrv6($hostent['ip']) && is_ipaddrv6($pconfig['ip'])))) {
|
||||
$input_errors[] = gettext("This host/domain already exists.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($input_errors) == 0) {
|
||||
$hostent = array();
|
||||
$hostent['host'] = $pconfig['host'];
|
||||
$hostent['domain'] = $pconfig['domain'];
|
||||
$hostent['ip'] = $pconfig['ip'];
|
||||
$hostent['descr'] = $pconfig['descr'];
|
||||
$hostent['aliases'] = $pconfig['aliases'];
|
||||
|
||||
if (isset($id)) {
|
||||
$a_hosts[$id] = $hostent;
|
||||
} else {
|
||||
$a_hosts[] = $hostent;
|
||||
}
|
||||
usort($config['dnsmasq']['hosts'], function ($a, $b) {
|
||||
return strcasecmp($a['host'], $b['host']);
|
||||
});
|
||||
|
||||
write_config();
|
||||
mark_subsystem_dirty('hosts');
|
||||
header(url_safe('Location: /services_dnsmasq.php'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$service_hook = 'dnsmasq';
|
||||
legacy_html_escape_form_data($pconfig);
|
||||
include("head.inc");
|
||||
?>
|
||||
|
||||
<body>
|
||||
<?php include("fbegin.inc"); ?>
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
/**
|
||||
* Aliases
|
||||
*/
|
||||
function removeRow() {
|
||||
if ( $('#aliases_table > tbody > tr').length == 1 ) {
|
||||
$('#aliases_table > tbody > tr:last > td > input').each(function(){
|
||||
$(this).val("");
|
||||
});
|
||||
} else {
|
||||
$(this).parent().parent().remove();
|
||||
}
|
||||
}
|
||||
// add new detail record
|
||||
$("#addNew").click(function(){
|
||||
// copy last row and reset values
|
||||
$('#aliases_table > tbody').append('<tr>'+$('#aliases_table > tbody > tr:last').html()+'</tr>');
|
||||
$('#aliases_table > tbody > tr:last > td > input').each(function(){
|
||||
$(this).val("");
|
||||
});
|
||||
$(".act-removerow").click(removeRow);
|
||||
});
|
||||
$(".act-removerow").click(removeRow);
|
||||
});
|
||||
</script>
|
||||
|
||||
<section class="page-content-main">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?>
|
||||
<section class="col-xs-12">
|
||||
<div class="content-box">
|
||||
<form method="post" name="iform" id="iform">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped opnsense_standard_table_form">
|
||||
<tr>
|
||||
<td style="width:22%"><strong><?= gettext('Edit entry') ?></strong></td>
|
||||
<td style="width:78%; text-align:right">
|
||||
<small><?=gettext("full help"); ?> </small>
|
||||
<i class="fa fa-toggle-off text-danger" style="cursor: pointer;" id="show_all_help_page"></i>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_host" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Host");?></td>
|
||||
<td>
|
||||
<input name="host" type="text" id="host" value="<?=$pconfig['host'];?>" />
|
||||
<div class="hidden" data-for="help_for_host">
|
||||
<?=gettext("Name of the host, without"." domain part"); ?><br />
|
||||
<?=gettext("e.g."); ?> <em><?=gettext("myhost"); ?></em>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_domain" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Domain");?></td>
|
||||
<td>
|
||||
<input name="domain" type="text" id="domain" value="<?=$pconfig['domain'];?>" />
|
||||
<div class="hidden" data-for="help_for_domain">
|
||||
<?=gettext("Domain of the host"); ?><br />
|
||||
<?=gettext("e.g."); ?> <em><?=gettext("example.com"); ?></em>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_ip" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("IP address");?></td>
|
||||
<td>
|
||||
<input name="ip" type="text" id="ip" value="<?=$pconfig['ip'];?>" />
|
||||
<div class="hidden" data-for="help_for_ip">
|
||||
<?=gettext("IP address of the host"); ?><br />
|
||||
<?=gettext("e.g."); ?> <em>192.168.100.100</em> <?=gettext("or"); ?> <em>fd00:abcd::1</em><
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_descr" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Description");?></td>
|
||||
<td>
|
||||
<input name="descr" type="text" id="descr" value="<?=$pconfig['descr'];?>" />
|
||||
<div class="hidden" data-for="help_for_descr">
|
||||
<?=gettext("You may enter a description here"." for your reference (not parsed).");?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_alias" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Aliases"); ?></td>
|
||||
<td>
|
||||
<table class="table table-striped table-condensed" id="aliases_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th id="detailsHeading1"><?=gettext("Host"); ?></th>
|
||||
<th id="detailsHeading3"><?=gettext("Domain"); ?></th>
|
||||
<th id="updatefreqHeader" ><?=gettext("Description");?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if (empty($pconfig['aliases']['item'])) {
|
||||
$aliases = array();
|
||||
$aliases[] = array('number' => null, 'value' => null, 'type' => null);
|
||||
} else {
|
||||
$aliases = $pconfig['aliases']['item'];
|
||||
}
|
||||
foreach($aliases as $item):?>
|
||||
<tr>
|
||||
<td>
|
||||
<div style="cursor:pointer;" class="act-removerow btn btn-default btn-xs"><i class="fa fa-minus fa-fw"></i></div>
|
||||
</td>
|
||||
<td>
|
||||
<input name="aliases_host[]" type="text" value="<?=$item['host'];?>" />
|
||||
</td>
|
||||
<td>
|
||||
<input name="aliases_domain[]" type="text" value="<?=$item['domain'];?>" />
|
||||
</td>
|
||||
<td>
|
||||
<input name="aliases_description[]" type="text" value="<?=$item['description'];?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach;?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<div id="addNew" style="cursor:pointer;" class="btn btn-default btn-xs"><i class="fa fa-plus fa-fw"></i></div>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<div class="hidden" data-for="help_for_alias">
|
||||
<?=gettext("Enter additional names for this host."); ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<input name="Submit" type="submit" class="btn btn-primary" value="<?=html_safe(gettext('Save'));?>" />
|
||||
<input type="button" class="btn btn-default" value="<?=html_safe(gettext("Cancel"));?>" onclick="window.location.href='/services_dnsmasq.php'" />
|
||||
<?php if (isset($id)): ?>
|
||||
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php include("foot.inc"); ?>
|
||||
Loading…
x
Reference in New Issue
Block a user