From 1a7508a028869639588d0550ef1a6b7c5d183437 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Fri, 8 Dec 2006 23:14:08 +0000 Subject: Add wan congestion triggers based on MS --- packages/tinydns/tinydns.inc | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'packages/tinydns/tinydns.inc') 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"); -- cgit v1.2.3