Commit 57b8d60d authored by Manuel Faux's avatar Manuel Faux

unbound: removed no-duplicate host restriction

Previously it was not possible to add two host override entries for the same
host-domain combination. Technically this restriction does not exist neither
within unbound nor DNS.
parent 23c805dc
...@@ -515,32 +515,27 @@ function unbound_add_host_entries() { ...@@ -515,32 +515,27 @@ function unbound_add_host_entries() {
$host_entries = ""; $host_entries = "";
$added_item = array(); $added_item = array();
foreach($config['unbound']['hosts'] as $host) { foreach($config['unbound']['hosts'] as $host) {
$current_host = $host['host']; if ($host['host'] != "") {
if ($host['host'] != "")
$host['host'] = $host['host']."."; $host['host'] = $host['host'].".";
if (!$added_item[$current_host]) { }
/* Backwards compatibility for records created before introducing RR types. */ /* Backwards compatibility for records created before introducing RR types. */
if (!isset($host['rr'])) { if (!isset($host['rr'])) {
$host['rr'] = (is_ipaddrv6($host['ip'])) ? 'AAAA' : 'A'; $host['rr'] = (is_ipaddrv6($host['ip'])) ? 'AAAA' : 'A';
} }
switch ($host['rr']) {
case 'A':
case 'AAAA':
$host_entries .= "local-data-ptr: \"{$host['ip']} {$host['host']}{$host['domain']}\"\n";
$host_entries .= "local-data: \"{$host['host']}{$host['domain']} IN {$host['rr']} {$host['ip']}\"\n";
break;
case 'MX':
$host_entries .= "local-data: \"{$host['host']}{$host['domain']} IN MX {$host['mxprio']} {$host['mx']}\"\n";
break;
}
if (!empty($host['descr']) && isset($config['unbound']['txtsupport'])) { switch ($host['rr']) {
$host_entries .= "local-data: '{$host['host']}{$host['domain']} TXT \"".addslashes($host['descr'])."\"'\n"; case 'A':
} case 'AAAA':
$host_entries .= "local-data-ptr: \"{$host['ip']} {$host['host']}{$host['domain']}\"\n";
$host_entries .= "local-data: \"{$host['host']}{$host['domain']} IN {$host['rr']} {$host['ip']}\"\n";
break;
case 'MX':
$host_entries .= "local-data: \"{$host['host']}{$host['domain']} IN MX {$host['mxprio']} {$host['mx']}\"\n";
break;
}
// Do not add duplicate entries if (!empty($host['descr']) && isset($config['unbound']['txtsupport'])) {
$added_item[$current_host] = true; $host_entries .= "local-data: '{$host['host']}{$host['domain']} TXT \"".addslashes($host['descr'])."\"'\n";
} }
} }
$unbound_entries .= $host_entries; $unbound_entries .= $host_entries;
......
...@@ -158,18 +158,6 @@ if ($_POST) { ...@@ -158,18 +158,6 @@ if ($_POST) {
$input_errors[] = gettext("A valid domain must be specified in alias list."); $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]) && ($a_hosts[$id] === $hostent))
continue;
if (($hostent['host'] == $_POST['host']) && ($hostent['domain'] == $_POST['domain'])
&& ((is_ipaddrv4($hostent['ip']) && is_ipaddrv4($_POST['ip'])) || (is_ipaddrv6($hostent['ip']) && is_ipaddrv6($_POST['ip'])))) {
$input_errors[] = gettext("This host/domain already exists.");
break;
}
}
if (!$input_errors) { if (!$input_errors) {
$hostent = array(); $hostent = array();
$hostent['host'] = $_POST['host']; $hostent['host'] = $_POST['host'];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment