diff --git a/src/etc/inc/plugins.inc.d/unbound.inc b/src/etc/inc/plugins.inc.d/unbound.inc index fd6ccdd51..6a9a98cb2 100644 --- a/src/etc/inc/plugins.inc.d/unbound.inc +++ b/src/etc/inc/plugins.inc.d/unbound.inc @@ -599,6 +599,9 @@ function unbound_add_host_entries() case 'MX': $unbound_entries .= "local-data: \"{$host['host']}{$host['domain']} IN MX {$host['mxprio']} {$host['mx']}\"\n"; break; + case 'CNAME': + $unbound_entries .= "local-data: \"{$host['host']}{$host['domain']} IN {$host['rr']} {$host['cname']}\"\n"; + break; } if (!empty($host['descr']) && isset($config['unbound']['txtsupport'])) { diff --git a/src/www/services_unbound_host_edit.php b/src/www/services_unbound_host_edit.php index 2b0f75c08..842e72ab2 100644 --- a/src/www/services_unbound_host_edit.php +++ b/src/www/services_unbound_host_edit.php @@ -48,7 +48,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $id = $_GET['id']; } $pconfig = array(); - foreach (array('rr', 'host', 'domain', 'ip', 'mxprio', 'mx', 'descr') as $fieldname) { + foreach (array('rr', 'host', 'domain', 'ip', 'mxprio', 'mx', 'descr', 'cname') as $fieldname) { if (isset($id) && !empty($a_hosts[$id][$fieldname])) { $pconfig[$fieldname] = $a_hosts[$id][$fieldname]; } else { @@ -100,6 +100,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $input_errors[] = gettext("A valid MX host must be specified."); } break; + case 'CNAME': + $reqdfields = explode(" ", "cname"); + $reqdfieldsn = array(gettext("Hostname")); + do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors); + + if (!empty($pconfig['cname']) && !is_hostname($pconfig['cname'])) { + $input_errors[] = gettext("A valid hostname must be specified."); + } + break; default: $input_errors[] = gettext("A valid resource record type must be specified."); break; @@ -113,6 +122,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $hostent['ip'] = $pconfig['ip']; $hostent['mxprio'] = $pconfig['mxprio']; $hostent['mx'] = $pconfig['mx']; + $hostent['cname'] = $pconfig['cname']; $hostent['descr'] = $pconfig['descr']; if (isset($id)) { @@ -139,19 +149,29 @@ include("head.inc"); $("#rr").change(function() { $(".a_aaa_rec").hide(); $(".mx_rec").hide(); + $(".cname_rec").hide(); switch ($(this).val()) { case 'A': $('#ip').prop('disabled', false); $('#mxprio').prop('disabled', true); $('#mx').prop('disabled', true); + $('#cname').prop('disabled', true); $(".a_aaa_rec").show(); break; case 'MX': $('#ip').prop('disabled', true); $('#mxprio').prop('disabled', false); $('#mx').prop('disabled', false); + $('#cname').prop('disabled', true); $(".mx_rec").show(); break; + case 'CNAME': + $('#ip').prop('disabled', true); + $('#mxprio').prop('disabled', true); + $('#mx').prop('disabled', true); + $('#cname').prop('disabled', false); + $(".cname_rec").show(); + break; } $( window ).resize(); // call window resize, which will re-apply zebra }); @@ -202,7 +222,7 @@ include("head.inc"); + + + diff --git a/src/www/services_unbound_overrides.php b/src/www/services_unbound_overrides.php index dac9b2791..453190f27 100644 --- a/src/www/services_unbound_overrides.php +++ b/src/www/services_unbound_overrides.php @@ -186,6 +186,9 @@ include_once("head.inc"); case 'MX': print $hostent['mxprio'] . " " . $hostent['mx']; break; + case 'CNAME': + print $hostent['cname']; + break; default: print ' '; break;