aboutsummaryrefslogtreecommitdiffstats
path: root/packages/tinydns
diff options
context:
space:
mode:
Diffstat (limited to 'packages/tinydns')
-rw-r--r--packages/tinydns/tinydns.inc63
-rw-r--r--packages/tinydns/tinydns.xml5
-rw-r--r--packages/tinydns/tinydns_sync.xml31
-rw-r--r--packages/tinydns/tinydns_xmlrpc_sync.php81
4 files changed, 110 insertions, 70 deletions
diff --git a/packages/tinydns/tinydns.inc b/packages/tinydns/tinydns.inc
index 4cb6c316..0cfad1df 100644
--- a/packages/tinydns/tinydns.inc
+++ b/packages/tinydns/tinydns.inc
@@ -356,4 +356,67 @@ function tinydns_get_rowline_data($recordip, $recordtype, $ttl, $hostname,$rdns)
return $record_data;
}
+function tinydns_do_xmlrpc_sync($sync_to_ip, $password) {
+ global $config, $g;
+
+ if(!$password)
+ return;
+
+ log_error("[tinydns] tinydns_xmlrpc_sync.php is starting to {$sync_to_ip}.");
+ $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;
+
+ /* xml will hold the sections to sync */
+ $xml = array();
+ $xml['installedpackages']['tinydns'] = $config['installedpackages']['tinydns'];
+ $xml['installedpackages']['tinydnsdomains'] = $config['installedpackages']['tinydnsdomains'];
+
+ //print_r($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;
+ $method = 'pfsense.merge_config_section';
+
+ /* Sync! */
+ log_error("Beginning tinydns XMLRPC sync to {$url}:{$port}.");
+ $msg = new XML_RPC_Message($method, $params);
+ $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
+ $cli->setCredentials('admin', $password);
+ if($g['debug'])
+ $cli->setDebug(1);
+ /* send our XMLRPC message and timeout after 240 seconds */
+ $resp = $cli->send($msg, "999");
+ if(!$resp) {
+ $error = "A communications error occured while attempting tinydns XMLRPC sync with {$url}:{$port}.";
+ log_error($error);
+ file_notice("sync_settings", $error, "tinydns Settings Sync", "");
+ } elseif($resp->faultCode()) {
+ $error = "An error code was received while attempting tinydns XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
+ log_error($error);
+ file_notice("sync_settings", $error, "tinydns Settings Sync", "");
+ } else {
+ log_error("tinydns XMLRPC sync successfully completed with {$url}:{$port}.");
+ }
+ log_error("[tinydns] tinydns_xmlrpc_sync.php is ending.");
+}
+
?> \ No newline at end of file
diff --git a/packages/tinydns/tinydns.xml b/packages/tinydns/tinydns.xml
index e355f335..74a09fdb 100644
--- a/packages/tinydns/tinydns.xml
+++ b/packages/tinydns/tinydns.xml
@@ -75,6 +75,11 @@
<chmod>077</chmod>
<item>http://www.pfsense.com/packages/config/tinydns/tinydns_view_logs.php</item>
</additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>077</chmod>
+ <item>http://www.pfsense.com/packages/config/tinydns/tinydns_sync.xml</item>
+ </additional_files_needed>
<custom_php_install_command>
tinydns_custom_php_install_command();
</custom_php_install_command>
diff --git a/packages/tinydns/tinydns_sync.xml b/packages/tinydns/tinydns_sync.xml
new file mode 100644
index 00000000..f275ec73
--- /dev/null
+++ b/packages/tinydns/tinydns_sync.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<packagegui>
+ <name>tinydns</name>
+ <version>1.0</version>
+ <configpath>installedpackages->package->tinydns</configpath>
+ <title>TinyDNS: Manual Sync</title>
+ <custom_php_install_command>
+ tinydns_custom_php_install_command();
+ </custom_php_install_command>
+ <custom_php_deinstall_command>
+ tinydns_custom_php_deinstall_command();
+ </custom_php_deinstall_command>
+ <custom_php_resync_config_command>
+ tinydns_do_xmlrpc_sync($ipaddress, $password);
+ </custom_php_resync_config_command>
+ <include_file>/usr/local/pkg/tinydns.inc</include_file>
+ <fields>
+ <field>
+ <fieldname>ipaddress</fieldname>
+ <fielddescr>IP Address</fielddescr>
+ <description>The IP address that TinyDNS will Sync its data to.</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fieldname>password</fieldname>
+ <fielddescr>Password</fielddescr>
+ <description>Admin password on remote firewall to faciliate sync</description>
+ <type>input</type>
+ </field>
+ </fields>
+</packagegui>
diff --git a/packages/tinydns/tinydns_xmlrpc_sync.php b/packages/tinydns/tinydns_xmlrpc_sync.php
index 35968616..6872fc4b 100644
--- a/packages/tinydns/tinydns_xmlrpc_sync.php
+++ b/packages/tinydns/tinydns_xmlrpc_sync.php
@@ -34,81 +34,22 @@ require_once("/usr/local/pkg/tinydns.inc");
require_once("service-utils.inc");
if(!$config) {
- log_error("\$config is not enabled!!");
+ log_error("\$config is not enabled from tinydns_xmlrpc_sync.php!!");
} else {
if(!$g['booting'])
tinydns_do_xmlrpc_sync();
}
-function tinydns_do_xmlrpc_sync() {
- global $config, $g;
- $syncxmlrpc = $config['installedpackages']['tinydns']['config'][0]['syncxmlrpc'];
+ if($config['installedpackages']['carpsettings']['config'])
+ $password = $config['installedpackages']['carpsettings']['config'][0]['password'];
+ if($config['installedpackages']['carpsettings']['config'])
+ $syncip = $config['installedpackages']['carpsettings']['config'][0]['synchronizetoip'];
+ if($config['installedpackages']['carpsettings']['config'])
+ $syncxmlrpc = $config['installedpackages']['tinydns']['config'][0]['syncxmlrpc'];
+
/* option enabled? */
- if(!$syncxmlrpc)
- return;
-
- $password = $config['installedpackages']['carpsettings']['config'][0]['password'];
-
- if(!$config['installedpackages']['carpsettings']['config'][0]['synchronizetoip'])
- return;
-
- $sync_to_ip = $config['installedpackages']['carpsettings']['config'][0]['synchronizetoip'];
-
- log_error("[tinydns] tinydns_xmlrpc_sync.php is starting.");
- $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;
-
- /* xml will hold the sections to sync */
- $xml = array();
- $xml['installedpackages']['tinydns'] = $config['installedpackages']['tinydns'];
- $xml['installedpackages']['tinydnsdomains'] = $config['installedpackages']['tinydnsdomains'];
-
- //print_r($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;
- $method = 'pfsense.merge_config_section';
-
- /* Sync! */
- log_error("Beginning tinydns XMLRPC sync to {$url}:{$port}.");
- $msg = new XML_RPC_Message($method, $params);
- $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
- $cli->setCredentials('admin', $password);
- if($g['debug'])
- $cli->setDebug(1);
- /* send our XMLRPC message and timeout after 240 seconds */
- $resp = $cli->send($msg, "999");
- if(!$resp) {
- $error = "A communications error occured while attempting tinydns XMLRPC sync with {$url}:{$port}.";
- log_error($error);
- file_notice("sync_settings", $error, "tinydns Settings Sync", "");
- } elseif($resp->faultCode()) {
- $error = "An error code was received while attempting tinydns XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
- log_error($error);
- file_notice("sync_settings", $error, "tinydns Settings Sync", "");
- } else {
- log_error("tinydns XMLRPC sync successfully completed with {$url}:{$port}.");
- }
- log_error("[tinydns] tinydns_xmlrpc_sync.php is ending.");
-}
+ if($syncxmlrpc)
+ if($syncip)
+ tinydns_do_xmlrpc_sync($syncip, $password)
?> \ No newline at end of file