aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/tinydns/tinydns.inc103
-rw-r--r--packages/tinydns/tinydns.xml2
-rw-r--r--packages/tinydns/tinydns_view_logs.php13
3 files changed, 69 insertions, 49 deletions
diff --git a/packages/tinydns/tinydns.inc b/packages/tinydns/tinydns.inc
index 302f76f5..2736f3e2 100644
--- a/packages/tinydns/tinydns.inc
+++ b/packages/tinydns/tinydns.inc
@@ -141,8 +141,12 @@ function tinydns_custom_php_changeip_command() {
$dnscacheip = $ip;
$dnsuserip = $arr[0];
}
- $dnsserverip = $config['installedpackages']['tinydns']['config'][0]['ipaddress'];
- if($config['installedpackages']['tinydns']['config'][0]['enableforwarding'])
+/* For now force $dnsserverip to to 127.0.0.1 when registration of 'local' DNS data is required */
+ if($config['installedpackages']['tinydns']['config'][0]['enableforwarding'])
+ $dnsserverip = "127.0.0.1";
+ if($config['installedpackages']['tinydns']['config'][0]['ipaddress'])
+ $dnsserverip = $config['installedpackages']['tinydns']['config'][0]['ipaddress'];
+ if($config['installedpackages']['tinydns']['config'][0]['regdhcpstatic'] OR $config['installedpackages']['tinydns']['config'][0]['regdhcp'])
$dnsserverip = "127.0.0.1";
$updatecron = $config['installedpackages']['tinydns']['config'][0]['updatecron'];
@@ -157,9 +161,8 @@ function tinydns_custom_php_changeip_command() {
exec("echo {$dnsserverip} > /etc/tinydns/env/IP");
exec("/usr/bin/killall -9 tinydns");
- if($config['installedpackages']['tinydns']['config'][0]['enableforwarding'])
- {
- if(!is_dir("/service/dnscache")){
+ if($config['installedpackages']['tinydns']['config'][0]['enableforwarding']) {
+ if(!is_dir("/service/dnscache")) {
exec("/usr/sbin/pw useradd Gdnscache");
exec("/usr/local/bin/dnscache-conf Gdnscache Gdnslog /etc/dnscache {$dnscacheip}");
exec("/bin/ln -s /etc/dnscache /service/");
@@ -174,12 +177,13 @@ function tinydns_custom_php_changeip_command() {
exec("echo domain {$config['system']['domain']} > /var/etc/resolv.conf");
exec("echo nameserver {$dnscacheip} >> /var/etc/resolv.conf");
exec("/usr/bin/killall -9 dnscache");
- }
- else
- {
- exec("/bin/cp /var/etc/resolv.conf.original /var/etc/resolv.conf");
- exec("echo > /etc/dnscache/env/IP");
- exec("/usr/bin/killall -9 dnscache");
+ } else {
+ if(file_exists("/var/etc/resolv.conf.original"))
+ exec("/bin/cp /var/etc/resolv.conf.original /var/etc/resolv.conf");
+ if(is_dir("/etc/dnscache")) {
+ exec("echo > /etc/dnscache/env/IP");
+ exec("/usr/bin/killall -9 dnscache");
+ }
}
conf_mount_ro();
filter_configure();
@@ -307,45 +311,48 @@ function tinydns_create_zone_file() {
return;
}
- /* Load the root servers if Forwarding is enabled */
- /* Register LAN IP and SOA Forward and Reverse DNS recors in TinyDNS Server*/
- if($config['installedpackages']['tinydns']['config'][0]['enableforwarding']) {
- $forwardingservers = tinydns_register_root_servers();
- if($forwardingservers)fwrite($fd, $forwardingservers);
- if($config['system']['hostname']['domain']) {
- $dhcpdhostname = $config['system']['hostname'];
- if($config['dhcpd']['lan'])$dhcpddomain = $config['system']['domain'];
- $dhcpdlanip = $config['interfaces']['lan']['ipaddr'];
- $dhcpdipmask = $config['interfaces']['lan']['subnet'];
- $dhcpdfqdn = "{$dhcpdhostname}.{$dhcpddomain}";
- tinydns_complete_soa_record($fd, $dhcpdlanip, $dhcpdipmask, $dhcpdhostname, $dhcpddomain);
- }
- }
-
- /* Register Static IPs */
- if($config['installedpackages']['tinydns']['config'][0]['regdhcpstatic']) {
- if(is_array($config['dhcpd']['lan']['staticmap'])) {
- foreach($config['dhcpd']['lan']['staticmap'] as $dhcpdstatic){
- $dhcpdhostname = $dhcpdstatic['hostname'];
+ /* For now do not allow registration of 'local' DNS data if tinyDNS not bound to 127.0.0.1 */
+ if($dnsserverip == "127.0.0.1") {
+ /* Load the root servers if Forwarding is enabled */
+ /* Register LAN IP and SOA Forward and Reverse DNS recors in TinyDNS Server*/
+ if($config['installedpackages']['tinydns']['config'][0]['enableforwarding']) {
+ $forwardingservers = tinydns_register_root_servers();
+ if($forwardingservers)fwrite($fd, $forwardingservers);
+ if($config['system']['hostname']['domain']) {
+ $dhcpdhostname = $config['system']['hostname'];
+ if($config['dhcpd']['lan'])$dhcpddomain = $config['system']['domain'];
+ $dhcpdlanip = $config['interfaces']['lan']['ipaddr'];
+ $dhcpdipmask = $config['interfaces']['lan']['subnet'];
$dhcpdfqdn = "{$dhcpdhostname}.{$dhcpddomain}";
- $dhcpdlanip = $dhcpdstatic['ipaddr'];
- $dhcpda = "={$dhcpdfqdn}:{$dhcpdlanip}";
- if($dhcpdhostname)fwrite($fd, $dhcpda . "\n");
+ tinydns_complete_soa_record($fd, $dhcpdlanip, $dhcpdipmask, $dhcpdhostname, $dhcpddomain);
}
}
- }
-
- /* Register Dynamic IPs */
- if($config['installedpackages']['tinydns']['config'][0]['regdhcp']) {
- $leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases";
- $fl = fopen($leasesfile, "r");
- if(!$fl) {
- log_error("Could not open {$leasesfile} for reading.");
- return;
+
+ /* Register Static IPs */
+ if($config['installedpackages']['tinydns']['config'][0]['regdhcpstatic']) {
+ if(is_array($config['dhcpd']['lan']['staticmap'])) {
+ foreach($config['dhcpd']['lan']['staticmap'] as $dhcpdstatic){
+ $dhcpdhostname = $dhcpdstatic['hostname'];
+ $dhcpdfqdn = "{$dhcpdhostname}.{$dhcpddomain}";
+ $dhcpdlanip = $dhcpdstatic['ipaddr'];
+ $dhcpda = "={$dhcpdfqdn}:{$dhcpdlanip}";
+ if($dhcpdhostname)fwrite($fd, $dhcpda . "\n");
+ }
+ }
}
- tinydns_add_active_leases($fl,$fd, $dhcpddomain);
- }
+ /* Register Dynamic IPs */
+ if($config['installedpackages']['tinydns']['config'][0]['regdhcp']) {
+ $leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases";
+ $fl = fopen($leasesfile, "r");
+ if(!$fl) {
+ log_error("Could not open {$leasesfile} for reading.");
+ return;
+ }
+ tinydns_add_active_leases($fl,$fd, $dhcpddomain);
+ }
+ }
+
if($config['installedpackages']['tinydnsdomains']) {
foreach($config['installedpackages']['tinydnsdomains']['config'] as $domain) {
$record_data = "";
@@ -682,15 +689,19 @@ function tinydns_dnscache_forwarding_servers() {
}
}
fclose($fr);
+ if(is_dir("/etc/dnscache/root/servers/"))
+ exec("rm -R /etc/dnscache/root/servers/");
+ exec("mkdir /etc/dnscache/root/servers/");
$fr = fopen("/etc/dnscache/root/servers/@", "w");
if (! $fr) {
- printf("Error: cannot open resolv.conf in tinydns_dnscache_forwarding_servers().\n");
+ printf("Error: cannot write to /etc/dnscache/root/servers/@ in tinydns_dnscache_forwarding_servers().\n");
return 1;
}
if($iprecords)fwrite($fr, $iprecords);
fclose($fr);
}
+/* This routine adds filenames to /etc/dnscache/root/servers/ with the contents pointing to the tinyDNS server */
function tinydns_create_soa_domain_list($dnsserverip){
if(file_exists("/service/tinydns/root/data"))
$tinydns_data = file_get_contents("/service/tinydns/root/data");
diff --git a/packages/tinydns/tinydns.xml b/packages/tinydns/tinydns.xml
index cfe3524e..0a789446 100644
--- a/packages/tinydns/tinydns.xml
+++ b/packages/tinydns/tinydns.xml
@@ -140,7 +140,7 @@
<field>
<fieldname>ipaddress</fieldname>
<fielddescr>IP Address</fielddescr>
- <description>Bind TinyDNS to this IP address. Enable DNS Forwarders bind it to the LAN IP.</description>
+ <description>Bind TinyDNS to this IP address. Enable DNS Forwarders bind TinyDNS to the LAN IP.</description>
<type>input</type>
</field>
<field>
diff --git a/packages/tinydns/tinydns_view_logs.php b/packages/tinydns/tinydns_view_logs.php
index 99faeeeb..3d6242a4 100644
--- a/packages/tinydns/tinydns_view_logs.php
+++ b/packages/tinydns/tinydns_view_logs.php
@@ -38,8 +38,16 @@ if(!$config['installedpackages']['tinydns']['config'][0])
$pgtitle = "TinyDNS: View Logs";
include("head.inc");
+/* NEED TO FIX there are 2 logs /etc/tinydns/log/main/current and /etc/dnscache/log/main/current */
+
$tinydnslogs = `cat /etc/tinydns/log/main/current | /usr/local/bin/tai64nlocal | php -f /usr/local/pkg/tinydns_parse_logs.php | grep -v ":0"`;
+/* NEED TO FIX */
+if ($_POST['clear']) {
+// exec("rm /etc/tinydns/log/main/current");
+// exec("touch /etc/tinydns/log/main/current");
+}
+
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
@@ -62,14 +70,14 @@ $tinydnslogs = `cat /etc/tinydns/log/main/current | /usr/local/bin/tai64nlocal |
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="tabcont" >
- <form action="tinydns_status.php" method="post">
+ <form action="tinydns_view_logs.php" method="post">
<br>
<pre><?=$tinydnslogs?></pre>
</td>
</tr>
</table>
<td align="left" valign="top">
- <form id="filterform" name="filterform" action="diag_logs.php" method="post" style="margin-top: 14px;">
+ <form id="filterform" name="filterform" action="tinydns_view_logs.php" method="post" style="margin-top: 14px;">
<input id="submit" name="clear" type="submit" class="formbtn" value="<?=gettext("Clear log");?>" />
</form>
</td>
@@ -79,3 +87,4 @@ $tinydnslogs = `cat /etc/tinydns/log/main/current | /usr/local/bin/tai64nlocal |
</body>
</html>
+?> \ No newline at end of file