aboutsummaryrefslogtreecommitdiffstats
path: root/packages/tinydns
diff options
context:
space:
mode:
Diffstat (limited to 'packages/tinydns')
-rw-r--r--packages/tinydns/tinydns.inc59
-rw-r--r--packages/tinydns/tinydns.xml26
2 files changed, 80 insertions, 5 deletions
diff --git a/packages/tinydns/tinydns.inc b/packages/tinydns/tinydns.inc
index 4983ccbe..c7d8befd 100644
--- a/packages/tinydns/tinydns.inc
+++ b/packages/tinydns/tinydns.inc
@@ -127,6 +127,7 @@ function tinydns_custom_php_deinstall_command() {
exec("/usr/sbin/pw userdel Gtinydns");
exec("/usr/sbin/pw userdel Gdnscache");
exec("/usr/sbin/pw userdel Gdnslog");
+ exec("/usr/sbin/pw groupdel Gaxfrdns");
exec("rm /usr/local/www/*tinydns*");
exec("rm /usr/local/pkg/*tinydns*");
exec("rm /usr/local/pkg/pf/*tinydns*");
@@ -155,6 +156,9 @@ function tinydns_custom_php_changeip_command() {
$updatecron = $config['installedpackages']['tinydns']['config'][0]['updatecron'];
+ /* Populate Zone Transfer array */
+ $ztipaddress = populate_zt_array();
+
/* setup daemon tools service area */
if(!is_dir("/service"))
exec("/bin/mkdir /service");
@@ -162,8 +166,15 @@ function tinydns_custom_php_changeip_command() {
exec("/usr/sbin/pw useradd Gtinydns");
exec("/usr/sbin/pw useradd Gdnslog");
exec("/usr/sbin/pw useradd Gdnscache");
+ exec("/usr/sbin/pw useradd Gaxfrdns");
+ /* TinyDNS Server */
exec("/usr/local/bin/tinydns-conf Gtinydns Gdnslog /etc/tinydns {$dnsserverip}");
+
+ /* AXFRDNS - Zone transfers */
+ if(is_array($ztipaddress))
+ exec("axfrdns-conf Gaxfrdns Gdnslog /etc/axfrdns /etc/tinydns {$dnsserverip}");
+
exec("/bin/ln -s /etc/tinydns /service/");
exec("echo {$dnsserverip} > /etc/tinydns/env/IP");
@@ -171,11 +182,11 @@ function tinydns_custom_php_changeip_command() {
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/");
- exec("/bin/cp /var/etc/resolv.conf /var/etc/resolv.conf.original");
- exec("/bin/cp /var/etc/resolv.conf /var/etc/resolv.conf.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/");
+ exec("/bin/cp /var/etc/resolv.conf /var/etc/resolv.conf.original");
+ exec("/bin/cp /var/etc/resolv.conf /var/etc/resolv.conf.dnscache");
}
exec("echo {$dnscacheip} > /etc/dnscache/env/IP");
tinydns_dnscache_forwarding_servers();
@@ -196,6 +207,44 @@ function tinydns_custom_php_changeip_command() {
filter_configure();
}
+function populate_zt_array() {
+ global $g, $config;
+ /* Populate Zone Transfer array */
+ if($config['installedpackages']['tinydns']['config'][0]['row']) {
+ $ztipaddress = array();
+ foreach($config['installedpackages']['tinydns']['config'][0]['row'] as $zt) {
+ $tmp = array();
+ $tmp['ztipaddress'] = $zt['ztipaddress'];
+ $tmp['dnszone'] = $zt['dnszone'];
+ $ztipaddress[] = $tmp;
+ }
+ }
+ return $ztipaddress;
+}
+
+function tinydns_setup_axfrdns() {
+ global $g, $config;
+ /* Populate Zone Transfer array */
+ $ztipaddress = populate_zt_array();
+ if(!is_array($ztipaddress))
+ return;
+ $fd = fopen("/etc/axfrdns/tcp","w");
+ if(!$fd) {
+ log_error("Could not open /etc/axfrdns/tcp for writing");
+ return;
+ }
+ foreach($ztipaddress as $zt) {
+ if($zt['ztipaddress'] && $zt['dnszone'])
+ $zonet = "{$zt['ztipaddress']}:allow";
+ if($zt['dnszone'] <> "*")
+ $zonet .= ",AXFR=\"{$zt['dnszone']}\"";
+ fwrite($fd, $zone . "\n");
+ }
+ fclose($fd);
+ // Recompile database
+ exec("cd /service/axfrdns && /usr/local/bin/tinydns-data");
+}
+
function tinydns_get_record_status($record, $pingthreshold = "", $wanpingthreshold = "") {
global $g, $config;
if(file_exists("/var/db/pingstatus/{$record}")) {
diff --git a/packages/tinydns/tinydns.xml b/packages/tinydns/tinydns.xml
index 171c408e..bc113d5b 100644
--- a/packages/tinydns/tinydns.xml
+++ b/packages/tinydns/tinydns.xml
@@ -209,6 +209,32 @@
</field>
<field>
<type>listtopic</type>
+ <name>Zone transfers</name>
+ <fieldname>temp</fieldname>
+ </field>
+ <field>
+ <fielddescr>Hosts allowed to perform DNS Zone Transfers</fielddescr>
+ <fieldname>none</fieldname>
+ <type>rowhelper</type>
+ <rowhelper>
+ <rowhelperfield>
+ <fielddescr>IP Address</fielddescr>
+ <fieldname>ztipaddress</fieldname>
+ <description>Enter the IP Address that is allowed to transfer zone records (ex: 4.2.2.1)</description>
+ <type>input</type>
+ <size>20</size>
+ </rowhelperfield>
+ <rowhelperfield>
+ <fielddescr>DNS Zone</fielddescr>
+ <fieldname>dnszone</fieldname>
+ <description>Enter the DNS zone that this IP address is allowed to transfer (ex: domain.com)</description>
+ <type>input</type>
+ <size>20</size>
+ </rowhelperfield>
+ </rowhelper>
+ </field>
+ <field>
+ <type>listtopic</type>
<name>Advanced tunables (OPTIONAL)</name>
<fieldname>temp</fieldname>
</field>