Skip to content

Commit

Permalink
system: allow up to 8 nameservers
Browse files Browse the repository at this point in the history
(cherry picked from commit b47c65b)
(cherry picked from commit ec3bcbe)
  • Loading branch information
fichtner committed May 19, 2017
1 parent fe952c6 commit 7e34c30
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/etc/inc/system.inc
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function system_resolvconf_generate($verbose = false)
chmod('/etc/resolv.conf', 0644);

/* setup static routes for DNS servers. */
for ($dnscounter=1; $dnscounter<5; $dnscounter++) {
for ($dnscounter = 1; $dnscounter < 9; $dnscounter++) {
/* setup static routes for dns servers */
$dnsgw = "dns{$dnscounter}gw";
if (isset($config['system'][$dnsgw])) {
Expand Down
45 changes: 17 additions & 28 deletions src/www/system_general.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@
$savemsg = htmlspecialchars(gettext($_GET['savemsg']));
}

$pconfig['dns1gw'] = null;
$pconfig['dns2gw'] = null;
$pconfig['dns3gw'] = null;
$pconfig['dns4gw'] = null ;
$pconfig['theme'] = null;
$pconfig['language'] = null;
$pconfig['timezone'] = "Etc/UTC";
Expand All @@ -52,17 +48,12 @@
$pconfig['hostname'] = $config['system']['hostname'];
$pconfig['domain'] = $config['system']['domain'];

if (isset($config['system']['dnsserver'])) {
list($pconfig['dns1'],$pconfig['dns2'],$pconfig['dns3'],$pconfig['dns4']) = $config['system']['dnsserver'];
} else {
list($pconfig['dns1'],$pconfig['dns2'],$pconfig['dns3'],$pconfig['dns4']) = null;
}
foreach (array('dns1gw', 'dns2gw', 'dns3gw', 'dns4gw') as $dnsgwopt) {
if (!empty($config['system'][$dnsgwopt])) {
$pconfig[$dnsgwopt] = $config['system'][$dnsgwopt];
} else {
$pconfig[$dnsgwopt] = "none";
}
for ($dnscounter = 1; $dnscounter < 9; $dnscounter++) {
$dnsname = "dns{$dnscounter}";
$pconfig[$dnsname] = !empty($config['system']['dnsserver'][$dnscounter - 1]) ? $config['system']['dnsserver'][$dnscounter - 1] : null;

$dnsgwname= "dns{$dnscounter}gw";
$pconfig[$dnsgwname] = !empty($config['system'][$dnsgwname]) ? $config['system'][$dnsgwname] : 'none';
}

$pconfig['dnsallowoverride'] = isset($config['system']['dnsallowoverride']);
Expand Down Expand Up @@ -96,7 +87,7 @@

$ignore_posted_dnsgw = array();

for ($dnscounter=1; $dnscounter<5; $dnscounter++){
for ($dnscounter = 1; $dnscounter < 9; $dnscounter++){
$dnsname="dns{$dnscounter}";
$dnsgwname="dns{$dnscounter}gw";
if (!empty($pconfig[$dnsname]) && !is_ipaddr($pconfig[$dnsname])) {
Expand All @@ -118,7 +109,7 @@
}
/* XXX cranky low-level call, please refactor */
$direct_networks_list = explode(' ', filter_get_direct_networks_list(filter_generate_optcfg_array()));
for ($dnscounter=1; $dnscounter<5; $dnscounter++) {
for ($dnscounter = 1; $dnscounter < 9; $dnscounter++) {
$dnsitem = "dns{$dnscounter}";
$dnsgwitem = "dns{$dnscounter}gw";
if (!empty($pconfig[$dnsgwitem])) {
Expand Down Expand Up @@ -154,14 +145,6 @@
unset($config['system']['gw_switch_default']);
}

$olddnsservers = $config['system']['dnsserver'];
$config['system']['dnsserver'] = array();
foreach (array('dns1', 'dns2', 'dns3', 'dns4') as $dnsopt) {
if (!empty($pconfig[$dnsopt])) {
$config['system']['dnsserver'][] = $pconfig[$dnsopt];
}
}

$config['system']['dnsallowoverride'] = !empty($pconfig['dnsallowoverride']);

if($pconfig['dnslocalhost'] == "yes") {
Expand All @@ -170,13 +153,19 @@
unset($config['system']['dnslocalhost']);
}

/* which interface should the dns servers resolve through? */
$olddnsservers = $config['system']['dnsserver'];
$config['system']['dnsserver'] = array();

$outdnscounter = 0;
for ($dnscounter=1; $dnscounter<5; $dnscounter++) {
for ($dnscounter = 1; $dnscounter < 9; $dnscounter++) {
$dnsname="dns{$dnscounter}";
$dnsgwname="dns{$dnscounter}gw";
$olddnsgwname = !empty($config['system'][$dnsgwname]) ? $config['system'][$dnsgwname] : "none" ;

if (!empty($pconfig[$dnsname])) {
$config['system']['dnsserver'][] = $pconfig[$dnsname];
}

if ($ignore_posted_dnsgw[$dnsgwname]) {
$thisdnsgwname = "none";
} else {
Expand Down Expand Up @@ -383,7 +372,7 @@
</thead>
<tbody>
<?php
for ($dnscounter=1; $dnscounter<5; $dnscounter++):
for ($dnscounter = 1; $dnscounter < 9; $dnscounter++):
$dnsgw = "dns{$dnscounter}gw";?>
<tr>
<td>
Expand Down

0 comments on commit 7e34c30

Please sign in to comment.