aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/tinydns/tinydns.inc22
-rw-r--r--packages/tinydns/tinydns_domains.xml6
2 files changed, 26 insertions, 2 deletions
diff --git a/packages/tinydns/tinydns.inc b/packages/tinydns/tinydns.inc
index 501ba8d9..792b6a86 100644
--- a/packages/tinydns/tinydns.inc
+++ b/packages/tinydns/tinydns.inc
@@ -160,13 +160,23 @@ function tinydns_custom_php_changeip_command() {
conf_mount_ro();
}
-function tinydns_get_record_status($record) {
+function tinydns_get_record_status($record, $pingthreshold, $wanpingthreshold) {
global $g, $config;
if(file_exists("/var/db/pingstatus/{$record}")) {
$status = file_get_contents("/var/db/pingstatus/{$record}");
if($status == "DOWN")
return false;
}
+ if($pingthreshold) {
+ $current_ms = file_get_contents("/var/db/pingmsstatus/$record");
+ if($pingthreshold > $current_ms)
+ return false;
+ }
+ if($wanpingthreshold) {
+ $current_avg = file_get_contents("/var/db/wanaverage");
+ if($wanpingthreshold > $current_avg)
+ return false;
+ }
return true;
}
@@ -248,7 +258,15 @@ function tinydns_create_zone_file() {
if($domain['row']) {
foreach($domain['row'] as $row) {
if($row['loadbalance']) {
- $status = tinydns_get_record_status($row['failoverip']);
+ if($row['pingthreshold'])
+ $pingthreshold = $row['pingthreshold'];
+ else
+ $pingthreshold = "";
+ if($row['wanpingthreshold'])
+ $wanpingthreshold = $row['wanpingthreshold'];
+ else
+ $wanpingthreshold = "";
+ $status = tinydns_get_record_status($row['failoverip'], $pingthreshold, $wanpingthreshold);
if($status) {
$record_data = tinydns_get_rowline_data($row['failoverip'], $domain['recordtype'], $ttl, $hostname);
fwrite($fd, $record_data . "\n");
diff --git a/packages/tinydns/tinydns_domains.xml b/packages/tinydns/tinydns_domains.xml
index 907d77e8..1c1ce7fb 100644
--- a/packages/tinydns/tinydns_domains.xml
+++ b/packages/tinydns/tinydns_domains.xml
@@ -96,6 +96,12 @@
<description>When the MS time is surpassed, item will failover to next host</description>
<type>input</type>
</rowhelperfield>
+ <rowhelperfield>
+ <fielddescr>Wan ping threshold</fielddescr>
+ <fieldname>wanpingthreshold</fieldname>
+ <description>When the WAN MS ping time is surpassed, item will failover to next host</description>
+ <type>input</type>
+ </rowhelperfield>
</rowhelper>
</field>
</fields>