aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2006-12-08 19:38:02 +0000
committerScott Ullrich <sullrich@pfsense.org>2006-12-08 19:38:02 +0000
commit0d3b49ccd42e49548aed77abf524306e1bfe4770 (patch)
treee54fb2ab12bc7620aa36d837a7a9ff98dc2cf69b
parentee8ac9eed5455ee05bf9b43939ff8ed2c0fef3e4 (diff)
downloadpfsense-packages-0d3b49ccd42e49548aed77abf524306e1bfe4770.tar.gz
pfsense-packages-0d3b49ccd42e49548aed77abf524306e1bfe4770.tar.bz2
pfsense-packages-0d3b49ccd42e49548aed77abf524306e1bfe4770.zip
* Split tinydns data row code out to its own function
* Add load balancing support
-rw-r--r--packages/tinydns/tinydns.inc61
-rw-r--r--packages/tinydns/tinydns_domains.xml6
2 files changed, 45 insertions, 22 deletions
diff --git a/packages/tinydns/tinydns.inc b/packages/tinydns/tinydns.inc
index 67e49abb..48e12216 100644
--- a/packages/tinydns/tinydns.inc
+++ b/packages/tinydns/tinydns.inc
@@ -190,36 +190,27 @@ function tinydns_create_zone_file() {
$record_data = "";
$hostname = $domain['hostname'];
$ipaddress = $domain['ipaddress'];
- $ttl = $domain['ttl'];
- if($ttl)
- $ttl_string = "::{$ttl}";
- else
- $ttl_string = "";
/* check record status, if it is down request
* backup server if defined.
*/
$status = tinydns_get_record_status($ipaddress);
if(!$status)
$ipaddress = tinydns_get_backup_record($ipaddress);
- switch ($domain['recordtype']) {
- case "SOA":
- $record_data = ".{$hostname}::{$ipaddress}";
- break;
- case "MX":
- $record_data = "@{$hostname}:{$ipaddress}{$ttl_string}";
- break;
- case "A":
- $record_data = "+{$hostname}:{$ipaddress}{$ttl_string}";
- break;
- case "PTR":
- $record_data = "={$hostname}:{$ipaddress}{$ttl_string}";
- break;
- case "CNAME":
- $record_data = "C{$hostname}:{$ipaddress}{$ttl_string}";
- break;
- }
+ $record_data = tinydns_get_rowline_data($ipaddress, $domain['recordtype'], $ttl);
if($record_data)
fwrite($fd, $record_data . "\n");
+ /* process load balanced items */
+ if($domain['row']) {
+ foreach($domain['row'] as $row) {
+ if($row['loadbalance']) {
+ $status = tinydns_get_record_status($row['failoverip']);
+ if(!$status) {
+ $record_data = tinydns_get_rowline_data($row['failoverip'], $domain['recordtype'], $ttl);
+ fwrite($fd, $record_data . "\n");
+ }
+ }
+ }
+ }
}
}
fclose($fd);
@@ -228,4 +219,30 @@ function tinydns_create_zone_file() {
conf_mount_ro();
}
+/* formats data as a tinydns data row item */
+function tinydns_get_rowline_data($recordip, $recordtype, $ttl) {
+ if($ttl)
+ $ttl_string = "::{$ttl}";
+ else
+ $ttl_string = "";
+ switch ($recordtype) {
+ case "SOA":
+ $record_data = ".{$hostname}::{$ipaddress}";
+ break;
+ case "MX":
+ $record_data = "@{$hostname}:{$ipaddress}{$ttl_string}";
+ break;
+ case "A":
+ $record_data = "+{$hostname}:{$ipaddress}{$ttl_string}";
+ break;
+ case "PTR":
+ $record_data = "={$hostname}:{$ipaddress}{$ttl_string}";
+ break;
+ case "CNAME":
+ $record_data = "C{$hostname}:{$ipaddress}{$ttl_string}";
+ break;
+ }
+ return $record_data;
+}
+
?> \ No newline at end of file
diff --git a/packages/tinydns/tinydns_domains.xml b/packages/tinydns/tinydns_domains.xml
index 94a124c5..5814834e 100644
--- a/packages/tinydns/tinydns_domains.xml
+++ b/packages/tinydns/tinydns_domains.xml
@@ -79,6 +79,12 @@
<type>input</type>
<size>45</size>
</rowhelperfield>
+ <rowhelperfield>
+ <fielddescr>Load balance</fielddescr>
+ <fieldname>loadbalance</fieldname>
+ <description>Adds this member to active group when host is alive.</description>
+ <type>checkbox</type>
+ </rowhelperfield>
</rowhelper>
</field>
</fields>