aboutsummaryrefslogtreecommitdiffstats
path: root/packages/squid
diff options
context:
space:
mode:
Diffstat (limited to 'packages/squid')
-rw-r--r--packages/squid/squid.inc23
-rw-r--r--packages/squid/squid_traffic.xml21
2 files changed, 44 insertions, 0 deletions
diff --git a/packages/squid/squid.inc b/packages/squid/squid.inc
index 674f38cd..54834649 100644
--- a/packages/squid/squid.inc
+++ b/packages/squid/squid.inc
@@ -426,6 +426,25 @@ function squid_validate_traffic($post, $input_errors) {
if (!is_numeric($value) || ($value < 0))
$input_errors[] = "The field '$name' must contain a positive number";
}
+
+ if (!empty($post['quick_abort_min'])) {
+ $value = trim($post['quick_abort_min']);
+ if (!is_numeric($value))
+ $input_errors[] = "The field 'Finish when remaining KB' must contain a positive number";
+ }
+
+ if (!empty($post['quick_abort_max'])) {
+ $value = trim($post['quick_abort_max']);
+ if (!is_numeric($value))
+ $input_errors[] = "The field 'Abort when remaining KB' must contain a positive number";
+ }
+
+ if (!empty($post['quick_abort_pct'])) {
+ $value = trim($post['quick_abort_pct']);
+ if (!is_numeric($value) || ($value > 100))
+ $input_errors[] = "The field 'Finish when remaining %' must contain a percentaged value";
+ }
+
}
function squid_validate_auth($post, $input_errors) {
@@ -700,6 +719,10 @@ function squid_resync_traffic() {
$conf .= "request_body_max_size $up_limit KB\n";
$conf .= 'reply_body_max_size ' . ($down_limit * 1024) . " allow all\n";
+ if (!empty($settings['quick_abort_min'])) $conf .= "quick_abort_min {$settings['quick_abort_min']} KB\n";
+ if (!empty($settings['quick_abort_max'])) $conf .= "quick_abort_max {$settings['quick_abort_max']} KB\n";
+ if (!empty($settings['quick_abort_pct'])) $conf .= "quick_abort_pct {$settings['quick_abort_pct']}\n";
+
// Only apply throttling past 10MB
// XXX: Should this really be hardcoded?
$threshold = 10 * 1024 * 1024;
diff --git a/packages/squid/squid_traffic.xml b/packages/squid/squid_traffic.xml
index 1556be66..1330cac9 100644
--- a/packages/squid/squid_traffic.xml
+++ b/packages/squid/squid_traffic.xml
@@ -146,6 +146,27 @@
<type>input</type>
<size>60</size>
</field>
+ <field>
+ <fielddescr>Finish transfer if less than x KB remaining</fielddescr>
+ <fieldname>quick_abort_min</fieldname>
+ <description>If the transfer has less than x KB remaining, it will finish the retrieval. Set to 0 to abort the transfer immediately.</description>
+ <type>input</type>
+ <default_value>0</default_value>
+ </field>
+ <field>
+ <fielddescr>Abort transfer if more than x KB remaining</fielddescr>
+ <fieldname>quick_abort_max</fieldname>
+ <description>If the transfer has more than x KB remaining, it will abort the retrieval. Set to 0 to abort the transfer immediately.</description>
+ <type>input</type>
+ <default_value>0</default_value>
+ </field>
+ <field>
+ <fielddescr>Finish transfer if more than x % finished</fielddescr>
+ <fieldname>quick_abort_pct</fieldname>
+ <description>If more than x % of the transfer has completed, it will finish the retrieval.</description>
+ <type>input</type>
+ <default_value>0</default_value>
+ </field>
</fields>
<custom_php_validation_command>
squid_validate_traffic($_POST, &amp;$input_errors);