summaryrefslogtreecommitdiffstats
path: root/usr/local/www/system.php
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@world.inf.org>2014-02-15 08:04:28 -0800
committerPhil Davis <phil.davis@world.inf.org>2014-02-15 08:04:28 -0800
commitdf4471e228ba11c8efff5f809b23ab1f2ca5e9c7 (patch)
treeb977c6a38ddabc31b4e33731113fe0bb982743f5 /usr/local/www/system.php
parent52acb1ff90c438a3cad137dd7bfec0d259369f59 (diff)
downloadpfsense-df4471e228ba11c8efff5f809b23ab1f2ca5e9c7.zip
pfsense-df4471e228ba11c8efff5f809b23ab1f2ca5e9c7.tar.gz
Improve processing of DNS server changes
What a pain this was. The user can blank out a DNS server from a position in the middle of the list. e.g. they had all 4 entries previously filled, and then they blank out DNS server #3. The way the DNS servers are stored in the config, they are just the defined ones in an "un-indexed" array. So actually entries 1, 2 and 4 on the screen become 1st, 2nd and 3rd in the config. The selected gateways for 1, 2 and 4 then have to end up in positions 1, 2 and 3 to match the stored DNS servers. This fixes all that up, as well as allowing the user to leave a gateway selected against a blanked-out DNS server entry - in that case the whole entry is "removed/ignored".
Diffstat (limited to 'usr/local/www/system.php')
-rwxr-xr-xusr/local/www/system.php43
1 files changed, 35 insertions, 8 deletions
diff --git a/usr/local/www/system.php b/usr/local/www/system.php
index a5028c6..ead4700 100755
--- a/usr/local/www/system.php
+++ b/usr/local/www/system.php
@@ -115,6 +115,8 @@ if ($_POST) {
$input_errors[] = gettext("The domain may only contain the characters a-z, 0-9, '-' and '.'.");
}
+ $ignore_posted_dnsgw = array();
+
for ($dnscounter=1; $dnscounter<5; $dnscounter++){
$dnsname="dns{$dnscounter}";
$dnsgwname="dns{$dnscounter}gw";
@@ -131,8 +133,8 @@ if ($_POST) {
$input_errors[] = gettext("You can not specify IPv4 gateway '{$_POST[$dnsgwname]}' for IPv6 DNS server '{$_POST[$dnsname]}'");
}
} else {
- // The user selected a gateway but did not provide a DNS address.
- $input_errors[] = gettext("A valid IP address must be specified for DNS server $dnscounter when a gateway is selected.");
+ // The user selected a gateway but did not provide a DNS address. Be nice and set the gateway back to "none".
+ $ignore_posted_dnsgw[$dnsgwname] = true;
}
}
}
@@ -212,17 +214,40 @@ if ($_POST) {
unset($config['system']['dnslocalhost']);
/* which interface should the dns servers resolve through? */
+ $outdnscounter = 0;
for ($dnscounter=1; $dnscounter<5; $dnscounter++) {
$dnsname="dns{$dnscounter}";
$dnsgwname="dns{$dnscounter}gw";
$olddnsgwname = $config['system'][$dnsgwname];
- if($_POST[$dnsgwname]) {
- $config['system'][$dnsgwname] = $pconfig[$dnsgwname];
- } else {
- // Note: when no DNS GW name is chosen, the entry is set to "none", so actually this case never happens.
- unset($config['system'][$dnsgwname]);
+
+ if ($ignore_posted_dnsgw[$dnsgwname])
+ $thisdnsgwname = "none";
+ else
+ $thisdnsgwname = $pconfig[$dnsgwname];
+
+ // "Blank" out the settings for this index, then we set them below using the "outdnscounter" index.
+ $config['system'][$dnsgwname] = "none";
+ $pconfig[$dnsgwname] = "none";
+ $pconfig[$dnsname] = "";
+
+ if ($_POST[$dnsname]) {
+ // Only the non-blank DNS servers were put into the config above.
+ // So we similarly only add the corresponding gateways sequentially to the config (and to pconfig), as we find non-blank DNS servers.
+ // This keeps the DNS server IP and corresponding gateway "lined up" when the user blanks out a DNS server IP in the middle of the list.
+ $outdnscounter++;
+ $outdnsname="dns{$outdnscounter}";
+ $outdnsgwname="dns{$outdnscounter}gw";
+ $pconfig[$outdnsname] = $_POST[$dnsname];
+ if($_POST[$dnsgwname]) {
+ $config['system'][$outdnsgwname] = $thisdnsgwname;
+ $pconfig[$outdnsgwname] = $thisdnsgwname;
+ } else {
+ // Note: when no DNS GW name is chosen, the entry is set to "none", so actually this case never happens.
+ unset($config['system'][$outdnsgwname]);
+ $pconfig[$outdnsgwname] = "";
+ }
}
- if (($olddnsgwname != "") && ($olddnsgwname != "none") && (($olddnsgwname != $config['system'][$dnsgwname]) || ($olddnsservers[$dnscounter-1] != $dnsname))) {
+ if (($olddnsgwname != "") && ($olddnsgwname != "none") && (($olddnsgwname != $thisdnsgwname) || ($olddnsservers[$dnscounter-1] != $_POST[$dnsname]))) {
// A previous DNS GW name was specified. It has now gone or changed, or the DNS server address has changed.
// Remove the route. Later calls will add the correct new route if needed.
if (is_ipaddrv4($olddnsservers[$dnscounter-1]))
@@ -252,6 +277,8 @@ if ($_POST) {
$savemsg = get_std_save_message($retval);
}
+
+ unset($ignore_posted_dnsgw);
}
$pgtitle = array(gettext("System"),gettext("General Setup"));
OpenPOWER on IntegriCloud