From 5a2a83493cdb3f647b4913f3b84ef864103148f5 Mon Sep 17 00:00:00 2001 From: Lorenz Schori Date: Sat, 5 May 2012 13:07:04 +0200 Subject: Add support for aliases in DNS Forwarder, fixes #2410 --- usr/local/www/services_dnsmasq.php | 19 ++++++ usr/local/www/services_dnsmasq_edit.php | 114 +++++++++++++++++++++++++++++++- 2 files changed, 132 insertions(+), 1 deletion(-) (limited to 'usr') diff --git a/usr/local/www/services_dnsmasq.php b/usr/local/www/services_dnsmasq.php index d010d0a..9dbfc3a 100755 --- a/usr/local/www/services_dnsmasq.php +++ b/usr/local/www/services_dnsmasq.php @@ -277,6 +277,25 @@ function show_advanced_dns() { + + + +   + + +   + + + Alias for   + + +   + + + + + + diff --git a/usr/local/www/services_dnsmasq_edit.php b/usr/local/www/services_dnsmasq_edit.php index 9aea153..e69d2ee 100755 --- a/usr/local/www/services_dnsmasq_edit.php +++ b/usr/local/www/services_dnsmasq_edit.php @@ -68,6 +68,7 @@ if (isset($id) && $a_hosts[$id]) { $pconfig['domain'] = $a_hosts[$id]['domain']; $pconfig['ip'] = $a_hosts[$id]['ip']; $pconfig['descr'] = $a_hosts[$id]['descr']; + $pconfig['aliases'] = $a_hosts[$id]['aliases']; } if ($_POST) { @@ -90,6 +91,43 @@ if ($_POST) { if (($_POST['ip'] && !is_ipaddr($_POST['ip']))) $input_errors[] = gettext("A valid IP address must be specified."); + /* collect aliases */ + $aliases = array(); + foreach ($_POST as $key => $value) { + $entry = ''; + if (!substr_compare('aliashost', $key, 0, 9)) { + $entry = substr($key, 9); + $field = 'host'; + } + elseif (!substr_compare('aliasdomain', $key, 0, 11)) { + $entry = substr($key, 11); + $field = 'domain'; + } + elseif (!substr_compare('aliasdescription', $key, 0, 16)) { + $entry = substr($key, 16); + $field = 'description'; + } + if (ctype_digit($entry)) { + $aliases[$entry][$field] = $value; + } + } + $pconfig['aliases']['item'] = $aliases; + + /* validate aliases */ + foreach ($aliases as $idx => $alias) { + $aliasreqdfields = array('aliasdomain' . $idx); + $aliasreqdfieldsn = array(gettext("Alias Domain")); + + var_dump(array('fields' => $aliasreqdfields, 'names' => $aliasreqdfieldsn, 'alias' => $alias)); + do_input_validation($_POST, $aliasreqdfields, $aliasreqdfieldsn, &$input_errors); + if (($alias['host'] && !is_hostname($alias['host']))) { + $input_errors[] = gettext("Hostnames in alias list can only contain the characters A-Z, 0-9 and '-'."); + } + if (($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]) && ($a_hosts[$id] === $hostent)) @@ -108,6 +146,7 @@ if ($_POST) { $hostent['domain'] = $_POST['domain']; $hostent['ip'] = $_POST['ip']; $hostent['descr'] = $_POST['descr']; + $hostent['aliases']['item'] = $aliases; if (isset($id) && $a_hosts[$id]) $a_hosts[$id] = $hostent; @@ -129,8 +168,24 @@ include("head.inc"); ?> - +"> + + + + +
@@ -166,6 +221,63 @@ include("head.inc");
+ + + +
+ + + + + + + + + + + + + + + + + + + +
+
+ +
+
+ + + + + + + " /> +
+ + " /> + + +
  -- cgit v1.1