aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2010-03-24 22:09:21 +0000
committerErmal <eri@pfsense.org>2010-03-24 22:09:21 +0000
commit49d68e26c28919e536834a9204ec8e062b7c89ad (patch)
treef707b67bf632359c3bae63169f8781b0d8a586a9
parentd212dc59718c8c8f5a09b30d7c26cffeb0408964 (diff)
downloadpfsense-packages-49d68e26c28919e536834a9204ec8e062b7c89ad.tar.gz
pfsense-packages-49d68e26c28919e536834a9204ec8e062b7c89ad.tar.bz2
pfsense-packages-49d68e26c28919e536834a9204ec8e062b7c89ad.zip
Ticket #440. On 2.0 user /var/etc/nameserver_* from getting the DNS server list.
-rw-r--r--config/tinydns/tinydns.inc66
1 files changed, 36 insertions, 30 deletions
diff --git a/config/tinydns/tinydns.inc b/config/tinydns/tinydns.inc
index 8953df04..b9fa3852 100644
--- a/config/tinydns/tinydns.inc
+++ b/config/tinydns/tinydns.inc
@@ -894,41 +894,47 @@ function tinydns_get_dns_record_type($tinydnsrecord) {
/* This function will be replaced by an auto detect DNS cache servers routine */
/* At the moment there is no tagging of DNSroute to a WAN port. It needs to be added */
function tinydns_dnscache_forwarding_servers($index) {
- $fr = fopen("/var/etc/resolv.conf.dnscache", "r");
- if (! $fr) {
- printf("Error: cannot open resolv.conf.dnscache in tinydns_register_forwarding_servers().\n");
- return 1;
- }
- $lip = strlen("nameserver") + 1;
- $j = 0;
- $iprecords = "";
- while (!feof($fr)) {
- $routers = fgets($fr, 4096);
- $discard = ($routers[0] == "\n");
- if(!$discard) {
- if ($routerip = strstr($routers,"nameserver")) {
- $routerip = substr($routerip,$lip);
- if($routerip) {
- $j += 1;
- $routera = "{$routerip}";
- $iprecords .= $routera;
- }
- }
- }
- }
- fclose($fr);
+ global $config;
+
exec("echo 1 > /etc/dnscache{$index}/env/FORWARDONLY");
if(is_dir("/etc/dnscache{$index}/root/servers/"))
exec("rm -R /etc/dnscache/root/servers/");
exec("mkdir -p /etc/dnscache{$index}/root/servers/");
- $fr = fopen("/etc/dnscache{$index}/root/servers/@", "w");
- if (! $fr) {
- printf("Error: cannot write to /etc/dnscache{$index}/root/servers/@ in tinydns_dnscache_forwarding_servers().\n");
- return 1;
+ if (intval($config['version']) >= 6)
+ exec("/bin/cat /var/etc/nameserver_* > /etc/dnscache{$index}/root/servers/@");
+ else {
+ $fr = fopen("/var/etc/resolv.conf.dnscache", "r");
+ if (! $fr) {
+ printf("Error: cannot open resolv.conf.dnscache in tinydns_register_forwarding_servers().\n");
+ return 1;
+ }
+ $lip = strlen("nameserver") + 1;
+ $j = 0;
+ $iprecords = "";
+ while (!feof($fr)) {
+ $routers = fgets($fr, 4096);
+ $discard = ($routers[0] == "\n");
+ if(!$discard) {
+ if ($routerip = strstr($routers,"nameserver")) {
+ $routerip = substr($routerip,$lip);
+ if($routerip) {
+ $j += 1;
+ $routera = "{$routerip}";
+ $iprecords .= $routera;
+ }
+ }
+ }
+ }
+ fclose($fr);
+ $fr = fopen("/etc/dnscache{$index}/root/servers/@", "w");
+ if (! $fr) {
+ printf("Error: cannot write to /etc/dnscache{$index}/root/servers/@ in tinydns_dnscache_forwarding_servers().\n");
+ return 1;
+ }
+ if($iprecords)
+ fwrite($fr, $iprecords);
+ fclose($fr);
}
- if($iprecords)
- fwrite($fr, $iprecords);
- fclose($fr);
}
/* This routine adds filenames to /etc/dnscache/root/servers/ with the contents pointing to the tinyDNS server */