From 8be89198b1f19b36f1f2c6b409ad5200df0829b8 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 2 Nov 2015 09:14:33 +0100 Subject: fix XMLRPC sync, cleanup useless junk --- config/tinydns/tinydns.xml | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/config/tinydns/tinydns.xml b/config/tinydns/tinydns.xml index 55ee3269..fef6e949 100644 --- a/config/tinydns/tinydns.xml +++ b/config/tinydns/tinydns.xml @@ -44,7 +44,7 @@ ]]> tinydns - 1.0 + 1.0.6.24 DNS Server: Settings /pkg_edit.php?xml=tinydns.xml&id=0 /usr/local/pkg/tinydns.inc @@ -59,13 +59,13 @@ svscan.sh svscan Daemontools service directory watcher - + DNS Server tinydns.sh tinydns TinyDNS DNS Server - + Settings @@ -98,10 +98,6 @@ /usr/local/pkg/ https://packages.pfsense.org/packages/config/tinydns/tinydns.inc - - /usr/local/pkg/pf/ - https://packages.pfsense.org/packages/config/tinydns/tinydns_xmlrpc_sync.php - /usr/local/pkg/ https://packages.pfsense.org/packages/config/tinydns/tinydns_domains.xml @@ -149,8 +145,7 @@ listtopic Binding IP Address - temp - + IP Address ipaddress @@ -160,8 +155,7 @@ listtopic Recursive DNS Resolver - temp - + Enable recursive DNS responder enableforwarding @@ -197,7 +191,6 @@ listtopic IP Monitoring - temp Enable IP monitoring @@ -214,18 +207,10 @@ listtopic Sync TinyDNS settings via XMLRPC - temp - - - XMLRPC Sync - syncxmlrpc - Sync TinyDNS configuration to backup firewalls - checkbox listtopic Zone transfers - temp Hosts allowed to perform DNS Zone Transfers - Note: this requires TCP port 53 firewall permit rule! @@ -245,7 +230,7 @@ Enter the DNS zone that this IP address is allowed to transfer (ex: domain.com) input 20 - + @@ -254,7 +239,7 @@ tinydns_custom_php_install_command(); tinydns_create_zone_file(); tinydns_setup_ping_items(); - tinydns_sync_on_changes(); + tinydns_sync_on_changes(); tinydns_validate(); @@ -264,26 +249,23 @@ tinydns_custom_php_install_command(); tinydns_create_zone_file(); tinydns_setup_ping_items(); - tinydns_sync_on_changes(); + tinydns_sync_on_changes(); tinydns_custom_php_changeip_command(); tinydns_custom_php_install_command(); tinydns_create_zone_file(); tinydns_setup_ping_items(); - tinydns_sync_on_changes(); + tinydns_sync_on_changes(); tinydns_custom_php_install_command(); - tinydns_sync_on_changes(); tinydns_custom_php_deinstall_command(); - tinydns_sync_on_changes(); start svscan to bring up the DNS Server"; } -- cgit v1.2.3 From 8bc70428d656ff1355c451041b5e561a96d70e2f Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 2 Nov 2015 09:15:29 +0100 Subject: Delete tinydns_xmlrpc_sync.php No-op plus no longer used. --- config/tinydns/tinydns_xmlrpc_sync.php | 59 ---------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 config/tinydns/tinydns_xmlrpc_sync.php diff --git a/config/tinydns/tinydns_xmlrpc_sync.php b/config/tinydns/tinydns_xmlrpc_sync.php deleted file mode 100644 index 0610e286..00000000 --- a/config/tinydns/tinydns_xmlrpc_sync.php +++ /dev/null @@ -1,59 +0,0 @@ - \ No newline at end of file -- cgit v1.2.3 From c20a7f7972d8db7afd3ff2cfec0b97f8d80b6173 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 2 Nov 2015 09:16:42 +0100 Subject: Redo XMLRPC sync from scratch --- config/tinydns/tinydns_sync.xml | 199 ++++++++++++++++++++++------------------ 1 file changed, 109 insertions(+), 90 deletions(-) diff --git a/config/tinydns/tinydns_sync.xml b/config/tinydns/tinydns_sync.xml index 5fe8ac77..e6875985 100644 --- a/config/tinydns/tinydns_sync.xml +++ b/config/tinydns/tinydns_sync.xml @@ -2,48 +2,48 @@ - - + - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ +/* ====================================================================================== */ + ]]> + tinydnssync - 1.0 - TinyDNS: Manual Sync + 1.0.6.24 + TinyDNS: XMLRPC Sync /usr/local/pkg/tinydns.inc @@ -76,71 +76,90 @@ listtopic - temp - Enable DNS zone sync + DNS zone synchronization - Enable DNS zone synchronization + Enable synchronization synconchanges - pfSense will automatically sync changes to the hosts defined below. + +
+ Important: While using "Sync to host(s) defined below", only sync from host A to B, A to C but do not enable XMLRPC sync to A. + This will result in a loop! + ]]> +
+ select + + disabled + + + + + checkbox
- listtopic - Sync host #1 - temp - - - IP Address - ipaddress - IP address of the first TinyDNS sync host. - input - - - Password - password - Admin password of the first TinyDNS sync host. - password - - - listtopic - Sync host #2 - temp - - - IP Address 2 - ipaddress2 - IP address of the second TinyDNS sync host. (optional) - input - - - Password 2 - password2 - Admin password of the second TinyDNS sync host. - password - - - listtopic - Sync host #3 - temp - - - IP Address 3 - ipaddress3 - IP address of the third TinyDNS sync host. (optional) - input + Sync Timeout + synctimeout + XMLRPC timeout in seconds. + select + + 250 + + + + + + + - Password 3 - password3 - Admin password of the third TinyDNS sync host. - password + Replication Targets + none + rowhelper + + + Enable + syncdestinenable + + checkbox + + + Protocol + syncprotocol + + select + HTTP + + + + + + + IP Address/Hostname + ipaddress + + input + 40 + + + Port + syncport + + input + 3 + + + Admin Password + password + + password + 20 + +
tinydns_sync_on_changes(); - - unset($_POST['temp']); - -
\ No newline at end of file + -- cgit v1.2.3 From 1d99c51cb7279d132a7329ad59240163e08e244f Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 2 Nov 2015 09:40:25 +0100 Subject: Redo XMLRPC sync from scratch, wipe obsolete junk, cleanups --- config/tinydns/tinydns.inc | 413 +++++++++++++++++++++++---------------------- 1 file changed, 215 insertions(+), 198 deletions(-) diff --git a/config/tinydns/tinydns.inc b/config/tinydns/tinydns.inc index 3bf64777..27059c52 100644 --- a/config/tinydns/tinydns.inc +++ b/config/tinydns/tinydns.inc @@ -1,11 +1,10 @@ $dnsif) { $dnscacheif = convert_friendly_interface_to_real_interface_name($dnsif); $dnscacheip = find_interface_ip($dnscacheif); - if (intval($config['version']) >= 6) - $ipmask = find_interface_subnet($dnscacheif); - else - $ipmask = $config['interfaces'][$dnsif]['subnet']; - - if (intval($config['version']) <= 8) { - if (is_ipaddr($ipaddress)) - $arr = tinydns_get_ip_subnet_arpa($ipaddress, $ipmask); - } else { - if (is_ipaddrv4($ipaddress)) { - $arr = tinydns_get_ip_subnet_arpa($ipaddress, $ipmask); - } elseif (is_ipaddrv6($ipaddress)) { - $arr = tinydns_get_ip6_subnet_arpa($ipaddress, $ipmask); - } + $ipmask = find_interface_subnet($dnscacheif); + + if (is_ipaddrv4($ipaddress)) { + $arr = tinydns_get_ip_subnet_arpa($ipaddress, $ipmask); + } elseif (is_ipaddrv6($ipaddress)) { + $arr = tinydns_get_ip6_subnet_arpa($ipaddress, $ipmask); } + $dnsuserip = $arr[0]; //exec("/bin/mkdir -p {$g['varetc_path']}/dnscache{$dnsidx}"); exec("/usr/local/bin/dnscache-conf Gdnscache Gdnslog {$g['varetc_path']}/dnscache{$dnsidx} {$dnscacheip}"); @@ -305,7 +333,7 @@ function tinydns_custom_php_changeip_command() { exec("{$svc_path} -xk {$g['varetc_path']}/dnscache{$dnsidx}"); } } else { - $interfaces = explode(",", $$config['installedpackages']['tinydns']['config'][0]['interface']); + $interfaces = explode(",", $config['installedpackages']['tinydns']['config'][0]['interface']); foreach ($interfaces as $dnsidx => $dnsif) { if(is_dir("{$g['varetc_path']}/dnscache{$dnsidx}")) dnscache_use_root_servers($dnsidx); @@ -517,10 +545,7 @@ function tinydns_create_zone_file() { foreach ($interfaces as $dnsif) { $dnsrif = convert_friendly_interface_to_real_interface_name($dnsif); $dnsrip = find_interface_ip($dnsrif); - if (intval($config['version']) >= 6) - $ipmask = find_interface_subnet($dnsrif); - else - $ipmask = $config['interfaces'][$dnsif]['subnet']; + $ipmask = find_interface_subnet($dnsrif); $dhcpdfqdn = "{$dhcpdhostname}.{$dhcpddomain}"; tinydns_complete_soa_record($fd, $dnsrip, $ipmask, $dhcpdhostname, $dhcpddomain); } @@ -544,10 +569,7 @@ function tinydns_create_zone_file() { $dnsrif = convert_friendly_interface_to_real_interface_name($dnsif); $dnsrip = find_interface_ip($dnsrif); - if (intval($config['version']) >= 6) - $ipmask = find_interface_subnet($dnsrif); - else - $ipmask = $config['interfaces'][$dnsif]['subnet']; + $ipmask = find_interface_subnet($dnsrif); $dhcpdfqdn = "{$dhcpdhostname}.{$dhcpddomain}"; tinydns_complete_soa_record($fd, $dnsrip, $ipmask, $dhcpdhostname, $dhcpddomain); @@ -606,15 +628,10 @@ function tinydns_create_zone_file() { if($record_data) { fwrite($fd, $record_data . "\n"); if ($domain['rdns'] || ($domain['recordtype'] == 'PTR')) { - if (intval($config['version']) <= 8) { - if (is_ipaddr($ipaddress)) - $rip = tinydns_get_ip_subnet_arpa($ipaddress, 32); - } else { - if (is_ipaddrv4($ipaddress)) { - $rip = tinydns_get_ip_subnet_arpa($ipaddress, 32); - } elseif (is_ipaddrv6($ipaddress)) { - $rip = tinydns_get_ip6_subnet_arpa($ipaddress, 128); - } + if (is_ipaddrv4($ipaddress)) { + $rip = tinydns_get_ip_subnet_arpa($ipaddress, 32); + } elseif (is_ipaddrv6($ipaddress)) { + $rip = tinydns_get_ip6_subnet_arpa($ipaddress, 128); } if($rip) @@ -651,95 +668,146 @@ function tinydns_create_zone_file() { function tinydns_sync_on_changes() { global $g, $config; - log_error("[tinydns] tinydns_xmlrpc_sync.php is starting."); - $synconchanges = $config['installedpackages']['tinydnssync']['config'][0]['synconchanges']; - if(!$synconchanges) - return; - $sync_hosts = $config['installedpackages']['tinydnssync']['config']; - $previous_ip = ""; - $x=0; - $sh = $config['installedpackages']['tinydnssync']['config'][0]; - for($x=1; $x<5; $x++) { - if($x > 1) - $counter = $x; - else - $counter = ""; - $sync_to_ip = ""; - $password = ""; - if($sh['ipaddress' . $counter]) { - $sync_to_ip = $sh['ipaddress' . $counter]; - $password = $sh['password' . $counter]; + + /* XMLRPC sync */ + if (is_array($config['installedpackages']['tinydnssync']['config'])) { + $tinydns_sync = $config['installedpackages']['tinydnssync']['config'][0]; + $synconchanges = $tinydns_sync['synconchanges']; + $synctimeout = $tinydns_sync['synctimeout'] ?: '250'; + switch ($synconchanges) { + case "manual": + if (is_array($tinydns_sync['row'])) { + $rs = $tinydns_sync['row']; + } else { + log_error("[tinydns] XMLRPC sync is enabled but there are no hosts configured as replication targets."); + return; + } + break; + case "auto": + if (is_array($config['hasync'])) { + $system_carp = $config['hasync']; + $rs[0]['ipaddress'] = $system_carp['synchronizetoip']; + $rs[0]['username'] = $system_carp['username']; + $rs[0]['password'] = $system_carp['password']; + $rs[0]['syncdestinenable'] = FALSE; + + // XMLRPC sync is currently only supported over connections using the same protocol and port as this system + if ($config['system']['webgui']['protocol'] == "http") { + $rs[0]['syncprotocol'] = "http"; + $rs[0]['syncport'] = $config['system']['webgui']['port'] ?: '80'; + } else { + $rs[0]['syncprotocol'] = "https"; + $rs[0]['syncport'] = $config['system']['webgui']['port'] ?: '443'; + } + if ($system_carp['synchronizetoip'] == "") { + log_error("[tinydns] XMLRPC CARP/HA sync is enabled but there are no system backup hosts configured as replication targets."); + return; + } else { + $rs[0]['syncdestinenable'] = TRUE; + } + } else { + log_error("[tinydns] XMLRPC CARP/HA sync is enabled but there are no system backup hosts configured as replication targets."); + return; + } + break; + default: + return; + break; } - if($password && $sync_to_ip) - tinydns_do_xmlrpc_sync($sync_to_ip, $password); - } - tinydns_create_zone_file(); - if ($config['installedpackages']['tinydns']['config'][0]['enableipmonitoring']) { - tinydns_setup_ping_items(); - } - log_error("[tinydns] tinydns_xmlrpc_sync.php is ending."); + if (is_array($rs)) { + log_error("[tinydns] XMLRPC sync is starting."); + foreach ($rs as $sh) { + // Only sync enabled replication targets + if ($sh['syncdestinenable']) { + $sync_to_ip = $sh['ipaddress']; + $port = $sh['syncport']; + $username = $sh['username'] ?: 'admin'; + $password = $sh['password']; + $protocol = $sh['syncprotocol']; + + $error = ''; + $valid = TRUE; + + if ($password == "") { + $error = "Password parameter is empty. "; + $valid = FALSE; + } + if (!is_ipaddr($sync_to_ip) && !is_hostname($sync_to_ip) && !is_domain($sync_to_ip)) { + $error .= "Misconfigured Replication Target IP Address or Hostname. "; + $valid = FALSE; + } + if (!is_port($port)) { + $error .= "Misconfigured Replication Target Port. "; + $valid = FALSE; + } + if ($valid) { + tinydns_do_xmlrpc_sync($sync_to_ip, $port, $protocol, $username, $password, $synctimeout); + } else { + log_error("[tinydns] XMLRPC sync with '{$sync_to_ip}' aborted due to the following error(s): {$error}"); + } + } + } + log_error("[tinydns] tinydns_xmlrpc_sync.php is ending."); + } + } } -function tinydns_do_xmlrpc_sync($sync_to_ip, $password) { +/* Do the actual XMLRPC sync. */ +function tinydns_do_xmlrpc_sync($sync_to_ip, $port, $protocol, $username, $password, $synctimeout) { global $config, $g; - if(!$password) + /* Detect boot process, do nothing during boot. */ + if (function_exists("platform_booting")) { + if (platform_booting()) { + return; + } + } elseif ($g['booting']) { return; + } - if(!$sync_to_ip) + if ($username == "" || $password == "" || $sync_to_ip == "" || $port == "" || $protocol == "") { + log_error("[tinydns] A required XMLRPC sync parameter (username, password, replication target, port or protocol) is empty ... aborting pkg sync"); return; + } - $xmlrpc_sync_neighbor = $sync_to_ip; - if($config['system']['webgui']['protocol'] != "") { - $synchronizetoip = $config['system']['webgui']['protocol']; - $synchronizetoip .= "://"; - } - $port = $config['system']['webgui']['port']; - /* if port is empty lets rely on the protocol selection */ - if($port == "") { - if($config['system']['webgui']['protocol'] == "http") - $port = "80"; - else - $port = "443"; - } - $synchronizetoip .= $sync_to_ip; + // Take care of IPv6 literal address + if (is_ipaddrv6($sync_to_ip)) { + $sync_to_ip = "[{$sync_to_ip}]"; + } - /* xml will hold the sections to sync */ + $url = "{$protocol}://{$sync_to_ip}"; + + /* XML will hold the sections to sync. */ $xml = array(); $xml['tinydnsdomains'] = $config['installedpackages']['tinydnsdomains']; + /* Assemble XMLRPC payload. */ + $params = array(XML_RPC_encode($password), XML_RPC_encode($xml)); - /* assemble xmlrpc payload */ - $params = array( - XML_RPC_encode($password), - XML_RPC_encode($xml) - ); - - /* set a few variables needed for sync code borrowed from filter.inc */ - $url = $synchronizetoip; - log_error("Beginning TinyDNS XMLRPC sync to {$url}:{$port}."); + /* Set a few variables needed for sync code */ $method = 'pfsense.merge_installedpackages_section_xmlrpc'; $msg = new XML_RPC_Message($method, $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); - $cli->setCredentials('admin', $password); - if($g['debug']) + $cli->setCredentials($username, $password); + if ($g['debug']) { $cli->setDebug(1); - /* send our XMLRPC message and timeout after 250 seconds */ - $resp = $cli->send($msg, "250"); - if(!$resp) { - $error = "A communications error occured while attempting tinydns XMLRPC sync with {$url}:{$port}."; - log_error($error); + } + /* Send our XMLRPC message and timeout after defined sync timeout value */ + $resp = $cli->send($msg, $synctimeout); + if (!$resp) { + $error = "A communications error occured while attempting XMLRPC sync with {$url}:{$port}."; + log_error("[tinydns] {$error}"); file_notice("sync_settings", $error, "tinydns Settings Sync", ""); - } elseif($resp->faultCode()) { + } elseif ($resp->faultCode()) { $cli->setDebug(1); - $resp = $cli->send($msg, "250"); - $error = "An error code was received while attempting tinydns XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); - log_error($error); + $resp = $cli->send($msg, $synctimeout); + $error = "An error code was received while attempting XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); + log_error("[tinydns] {$error}"); file_notice("sync_settings", $error, "tinydns Settings Sync", ""); } else { - log_error("tinydns XMLRPC sync successfully completed with {$url}:{$port}."); + log_error("[tinydns] XMLRPC sync successfully completed with {$url}:{$port}."); } - /* tell tinydns to reload our settings on the destionation sync host. */ + /* Tell tinydns to reload our settings on the destionation sync host. */ $method = 'pfsense.exec_php'; $execcmd = "require_once('functions.inc');\n"; $execcmd .= "require_once('/usr/local/pkg/tinydns.inc');\n"; @@ -749,31 +817,27 @@ function tinydns_do_xmlrpc_sync($sync_to_ip, $password) { $execcmd .= "tinydns_setup_ping_items();\n"; } - /* assemble xmlrpc payload */ - $params = array( - XML_RPC_encode($password), - XML_RPC_encode($execcmd) - ); + /* Assemble XMLRPC payload. */ + $params = array(XML_RPC_encode($password), XML_RPC_encode($execcmd)); - log_error("tinydns XMLRPC reload data {$url}:{$port}."); + log_error("[tinydns] XMLRPC reload data {$url}:{$port}."); $msg = new XML_RPC_Message($method, $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); - $cli->setCredentials('admin', $password); - $resp = $cli->send($msg, "250"); - if(!$resp) { - $error = "A communications error occured while attempting tinydns XMLRPC sync with {$url}:{$port} (pfsense.exec_php)."; - log_error($error); + $cli->setCredentials($username, $password); + $resp = $cli->send($msg, $synctimeout); + if (!$resp) { + $error = "A communications error occured while attempting XMLRPC sync with {$url}:{$port} (pfsense.exec_php)."; + log_error("[tinydns] {$error}"); file_notice("sync_settings", $error, "tinydns Settings Sync", ""); - } elseif($resp->faultCode()) { + } elseif ($resp->faultCode()) { $cli->setDebug(1); - $resp = $cli->send($msg, "250"); - $error = "An error code was received while attempting tinydns XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); - log_error($error); + $resp = $cli->send($msg, $synctimeout); + $error = "An error code was received while attempting XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); + log_error("[tinydns] {$error}"); file_notice("sync_settings", $error, "tinydns Settings Sync", ""); } else { - log_error("tinydns XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php)."); + log_error("[tinydns] XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php)."); } - } /* formats data as a tinydns data row item */ @@ -789,18 +853,15 @@ function tinydns_get_rowline_data($recordip, $recordtype, $ttl, $hostname, $rdns /* Note that some of these are simplistic versions of TinyDNS record handling. Uber-users can always do "raw" entries... */ case "SOA": // .fqdn:ip:x:ttl:timestamp:lo - if (intval($config['version']) <= 8) { - $record_data = ".{$hostname}::{$recordip}{$ttl_string}"; + if (is_ipaddrv6($hostname)) { + list($rip, $rmask) = explode("/", $hostname); + $rmask = empty($rmask) ? 128 : $rmask; + $ip6_arpa = tinydns_get_ip6_subnet_arpa($rip, $rmask); + $record_data = ".{$ip6_arpa[1]}::{$recordip}{$ttl_string}"; } else { - if (is_ipaddrv6($hostname)) { - list($rip, $rmask) = explode("/", $hostname); - $rmask = empty($rmask) ? 128 : $rmask; - $ip6_arpa = tinydns_get_ip6_subnet_arpa($rip, $rmask); - $record_data = ".{$ip6_arpa[1]}::{$recordip}{$ttl_string}"; - } else { - $record_data = ".{$hostname}::{$recordip}{$ttl_string}"; - } + $record_data = ".{$hostname}::{$recordip}{$ttl_string}"; } + break; case "NS": // &serious.panic.mil:1.8.248.6:a @@ -832,17 +893,11 @@ function tinydns_get_rowline_data($recordip, $recordtype, $ttl, $hostname, $rdns case "PTR": /* "^" creates "PTR" record only to allow reverse DNS */ // ^fqdn:p:ttl:timestamp:lo - - if (intval($config['version']) <= 8) { - if (is_ipaddr($recordip)) - $record_data = "^{$hostname}:{$recordip}{$ttl_string}"; - } else { - if (is_ipaddrv4($recordip)) { - $record_data = "^{$hostname}:{$recordip}{$ttl_string}"; - } elseif (is_ipaddrv6($recordip)) { - $ip6_arpa = tinydns_get_ip6_subnet_arpa($recordip, 128); - $record_data = "^{$ip6_arpa[1]}:{$hostname}{$ttl_string}"; - } + if (is_ipaddrv4($recordip)) { + $record_data = "^{$hostname}:{$recordip}{$ttl_string}"; + } elseif (is_ipaddrv6($recordip)) { + $ip6_arpa = tinydns_get_ip6_subnet_arpa($recordip, 128); + $record_data = "^{$ip6_arpa[1]}:{$hostname}{$ttl_string}"; } break; case "A": @@ -1016,15 +1071,10 @@ function tinydns_complete_soa_record($fd, $ip, $ipmask, $nsname, $domain) { global $config; $fqdn = "{$nsname}.{$domain}"; - if (intval($config['version']) <= 8) { - if (is_ipaddr($ipaddress)) - $rip = tinydns_get_ip_subnet_arpa($ipaddress, $ipmask); - } else { - if (is_ipaddrv4($ipaddress)) { - $rip = tinydns_get_ip_subnet_arpa($ipaddress, $ipmask); - } elseif (is_ipaddrv6($ipaddress)) { - $rip = tinydns_get_ip6_subnet_arpa($ipaddress, $ipmask); - } + if (is_ipaddrv4($ipaddress)) { + $rip = tinydns_get_ip_subnet_arpa($ipaddress, $ipmask); + } elseif (is_ipaddrv6($ipaddress)) { + $rip = tinydns_get_ip6_subnet_arpa($ipaddress, $ipmask); } $soa = ".{$domain}::{$fqdn}"; @@ -1181,53 +1231,20 @@ function tinydns_dnscache_forwarding_servers($index) { global $g, $config; exec("echo 1 > {$g['varetc_path']}/dnscache{$index}/env/FORWARDONLY"); - if(is_dir("{$g['varetc_path']}/dnscache{$index}/root/servers/")) + if (is_dir("{$g['varetc_path']}/dnscache{$index}/root/servers/")) { exec("rm -R {$g['varetc_path']}/dnscache/root/servers/"); + } exec("/bin/mkdir -p {$g['varetc_path']}/dnscache{$index}/root/servers/"); - if (intval($config['version']) >= 6) - if (!empty(glob("{$g['varetc_path']}/nameserver_*"))) { - exec("/bin/cat {$g['varetc_path']}/nameserver_* > {$g['varetc_path']}/dnscache{$index}/root/servers/@"); - } else { - $fw = fopen("{$g['varetc_path']}/dnscache{$index}/root/servers/@", "w"); - if (! $fw) { - printf("Error: cannot open dnscache/root/servers/@ in tinydns_register_forwarding_servers().\n"); - return 1; - } - fwrite($fw, $config['system']['dnsserver'][0]); - fclose($fw); - } - else { - $fr = fopen("{$g['varetc_path']}/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("{$g['varetc_path']}/dnscache{$index}/root/servers/@", "w"); - if (! $fr) { - printf("Error: cannot write to {$g['varetc_path']}/dnscache{$index}/root/servers/@ in tinydns_dnscache_forwarding_servers().\n"); + if (!empty(glob("{$g['varetc_path']}/nameserver_*"))) { + exec("/bin/cat {$g['varetc_path']}/nameserver_* > {$g['varetc_path']}/dnscache{$index}/root/servers/@"); + } else { + $fw = fopen("{$g['varetc_path']}/dnscache{$index}/root/servers/@", "w"); + if (!$fw) { + printf("Error: cannot open dnscache/root/servers/@ in tinydns_register_forwarding_servers().\n"); return 1; } - if($iprecords) - fwrite($fr, $iprecords); - fclose($fr); + fwrite($fw, $config['system']['dnsserver'][0]); + fclose($fw); } } -- cgit v1.2.3 From 9dbd3a72c38490e2854ac0934e535de2365f8c01 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 2 Nov 2015 09:41:53 +0100 Subject: Remove obsolete XMLRPC config on install --- config/tinydns/tinydns.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/tinydns/tinydns.xml b/config/tinydns/tinydns.xml index fef6e949..d538b560 100644 --- a/config/tinydns/tinydns.xml +++ b/config/tinydns/tinydns.xml @@ -260,6 +260,7 @@ tinydns_custom_php_install_command(); + tinydns_upgrade_config(); tinydns_custom_php_deinstall_command(); -- cgit v1.2.3 From 7e6cd8252dd237b7b4f9f08bdd63663302d7ebf9 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 2 Nov 2015 09:43:04 +0100 Subject: Bump tinydns package version --- pkg_config.10.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg_config.10.xml b/pkg_config.10.xml index 7775d4b1..cd70d4cf 100644 --- a/pkg_config.10.xml +++ b/pkg_config.10.xml @@ -702,7 +702,7 @@ pfSense version of TinyDNS which features failover host support. http://cr.yp.to/djbdns.html Services - 1.0.6.23 + 1.0.6.24 Beta https://doc.pfsense.org/index.php/Tinydns_package 2.2 -- cgit v1.2.3 From 4115cbccd737a810be850005c8cef7a1a88bb24e Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 2 Nov 2015 09:44:52 +0100 Subject: Bump tinydns package version --- pkg_config.8.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg_config.8.xml b/pkg_config.8.xml index 757738d7..926bb277 100644 --- a/pkg_config.8.xml +++ b/pkg_config.8.xml @@ -768,10 +768,10 @@ pfSense version of TinyDNS which features failover host support http://cr.yp.to/djbdns.html Services - 1.0.6.21 + 1.0.6.24 Beta https://doc.pfsense.org/index.php/Tinydns_package - 2.0 + 2.1 https://packages.pfsense.org/packages/config/tinydns/tinydns.xml tinydns.xml https://files.pfsense.org/packages/8/All/ -- cgit v1.2.3 From eb6387e8e189cddd929fb60d950bfc0c641e70c9 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 2 Nov 2015 09:45:35 +0100 Subject: Bump tinydns package version --- pkg_config.8.xml.amd64 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64 index 380225e2..f8a7ea5b 100644 --- a/pkg_config.8.xml.amd64 +++ b/pkg_config.8.xml.amd64 @@ -755,10 +755,10 @@ pfSense version of TinyDNS which features failover host support http://cr.yp.to/djbdns.html Services - 1.0.6.21 + 1.0.6.24 Beta https://doc.pfsense.org/index.php/Tinydns_package - 2.0 + 2.1 https://packages.pfsense.org/packages/config/tinydns/tinydns.xml tinydns.xml https://files.pfsense.org/packages/amd64/8/All/ -- cgit v1.2.3 From af048b5fa0f01ff981e4f8259b2223f8571bbf16 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 2 Nov 2015 09:51:18 +0100 Subject: Remove leftover listtopic field --- config/tinydns/tinydns.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/tinydns/tinydns.xml b/config/tinydns/tinydns.xml index d538b560..bbb1cfa2 100644 --- a/config/tinydns/tinydns.xml +++ b/config/tinydns/tinydns.xml @@ -204,10 +204,6 @@ Controls polling frequency of monitoring IP address input
- - listtopic - Sync TinyDNS settings via XMLRPC - listtopic Zone transfers -- cgit v1.2.3 From 03982740ed39ce777c9829d825521998de2a6f3a Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 2 Nov 2015 09:52:19 +0100 Subject: Remove leftover tag --- config/tinydns/tinydns_sync.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/config/tinydns/tinydns_sync.xml b/config/tinydns/tinydns_sync.xml index e6875985..299815dc 100644 --- a/config/tinydns/tinydns_sync.xml +++ b/config/tinydns/tinydns_sync.xml @@ -96,7 +96,6 @@ - checkbox Sync Timeout -- cgit v1.2.3 From 832e9e2a1b913fb7874bb52af96ccced21ae3bf2 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 2 Nov 2015 09:56:50 +0100 Subject: Fix filename in copyright header --- config/tinydns/tinydns.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/tinydns/tinydns.inc b/config/tinydns/tinydns.inc index 27059c52..5e61fc05 100644 --- a/config/tinydns/tinydns.inc +++ b/config/tinydns/tinydns.inc @@ -1,6 +1,6 @@ Date: Mon, 2 Nov 2015 09:57:26 +0100 Subject: Fix filename in copyright header --- config/tinydns/tinydns_sync.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/tinydns/tinydns_sync.xml b/config/tinydns/tinydns_sync.xml index 299815dc..2f7da455 100644 --- a/config/tinydns/tinydns_sync.xml +++ b/config/tinydns/tinydns_sync.xml @@ -7,7 +7,7 @@ /* $Id$ */ /* ====================================================================================== */ /* - checkmk.xml + tinydns_sync.xml part of pfSense (https://www.pfSense.org/) Copyright (C) 2008 Scott Ullrich Copyright (C) 2015 ESF, LLC -- cgit v1.2.3 From 89e1aa6abe20158691a496ca5c2f3b90b5ce1218 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 2 Nov 2015 10:08:38 +0100 Subject: Replace reference to obsoleted file, cleanup prehistoric junk, fix XHTML --- config/tinydns/tinydns_dhcp_filter.php | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/config/tinydns/tinydns_dhcp_filter.php b/config/tinydns/tinydns_dhcp_filter.php index 85f5f8e7..5b245d7f 100644 --- a/config/tinydns/tinydns_dhcp_filter.php +++ b/config/tinydns/tinydns_dhcp_filter.php @@ -1,10 +1,10 @@ - part of pfSense + Copyright (C) 2007 Goffredo Andreone + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -39,21 +39,17 @@ require("/usr/local/pkg/tinydns.inc"); require("guiconfig.inc"); +$closehead = false; $pgtitle = "TinyDNS: DHCP Domains"; include("head.inc"); -$pf_version=substr(trim(file_get_contents("/etc/version")),0,3); -if ($pf_version < 2.0) - $one_two = true; - ?> + + + - -

- -
@@ -64,7 +60,7 @@ if ($pf_version < 2.0) $tab_array[] = array(gettext("Add/Edit Record"), false, "/tinydns_filter.php"); $tab_array[] = array(gettext("Failover Status"), false, "/tinydns_status.php"); $tab_array[] = array(gettext("Logs"), false, "/tinydns_view_logs.php"); - $tab_array[] = array(gettext("Zone Sync"), false, "/tinydns_xmlrpc_sync.php"); + $tab_array[] = array(gettext("Zone Sync"), false, "/pkg_edit.php?xml=tinydns_sync.xml"); $tab_array[] = array(gettext("New domain wizard"), false, "/wizard.php?xml=new_zone_wizard.xml"); display_top_tabs($tab_array); ?> @@ -124,6 +120,5 @@ while ($startofrecord < $datalen ){
- -- cgit v1.2.3