aboutsummaryrefslogtreecommitdiffstats
path: root/packages/tinydns/tinydns.inc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2007-02-12 18:14:40 +0000
committerScott Ullrich <sullrich@pfsense.org>2007-02-12 18:14:40 +0000
commitfe948c97c1ef4c1b624730a196152d190c070b7e (patch)
tree492a3439b9022a835063ea8812ef0c9c71037d15 /packages/tinydns/tinydns.inc
parent2259758674f6b5f3a93c274909a574ee8b2a50ee (diff)
downloadpfsense-packages-fe948c97c1ef4c1b624730a196152d190c070b7e.tar.gz
pfsense-packages-fe948c97c1ef4c1b624730a196152d190c070b7e.tar.bz2
pfsense-packages-fe948c97c1ef4c1b624730a196152d190c070b7e.zip
Add custom sync to function allowing a Admin to sync their tinydns to remote firewalls with ease.
Diffstat (limited to 'packages/tinydns/tinydns.inc')
-rw-r--r--packages/tinydns/tinydns.inc63
1 files changed, 63 insertions, 0 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