Right here we go. For the Gentoo users here:
echo "net-misc/trickle ~x86" >> /etc/portage/package.keywords
emerge trickle
touch /etc/trickled.conf
Edit 'config.php' and look for:
$cfg["hide_offline"] = ....
insert after this line:
// Location of the Trickle binaries - leave blank to disable Trickle support
$cfg["trickle"] = "/usr/bin/trickle";
$cfg["trickled"] = "/usr/bin/trickled -t 0.2"; // Options are allowed here, do not append max up/download here, look below for those
// Maximum total speeds using Trickle
$cfg["trickle_max_upload"] = 90; // Speed in kb/s - make 0 to ommit
$cfg["trickle_max_download"] = 0; // Speed in kb/s - make 0 to ommit
Next, open up 'index.php' and find the following code:
if (usingTornado())
{
$command = ...
Replace everything between the { } with the following:
$trickle_command = ""; // We default to no trickle command
if ((!empty($cfg["trickle"])) && (!empty($cfg["trickled"]))) {
// Test if the daemon is running - if not, start it
$t_command = "ps aux | grep trickled | awk '{ print $11 }' | grep trickled";
$result = shell_exec($t_command);
//echo "executed: $t_command<br>result: $result<br>";
// Fire up the daemon if result is empty (the program is not running)
if ($result == "") {
$t_command = $cfg["trickled"] . (($cfg["trickle_max_upload"] > 0) ? " -u " . $cfg["trickle_max_upload"] : "") .
(($cfg["trickle_max_download"] > 0) ? " -d " . $cfg["trickle_max_download"] : "");
$result = exec($t_command);
//echo "executed: $t_command<br>result code: " . $result;
}
// Actualy start trickle
$trickle_command = $cfg["trickle"] . " ";
}
$command = "cd " . $cfg["path"] . $owner . "; HOME=".$cfg["path"]."; export HOME; nohup ". $trickle_command
.$cfg["btphpbin"] . " ".$runtime." ".$sharekill." ".$cfg["torrent_file_path"].$alias.".stat ".$owner." --responsefile
'".$cfg["torrent_file_path"].$torrent."' --display_interval 5 --max_download_rate ". $drate ." --max_upload_rate ".$rate."
--max_uploads ".$maxuploads." --minport ".$minport." --maxport ".$maxport." --super_seeder ".$superseeder."
".$cfg["cmd_options"]." > /dev/null &";
I've made the long lines into multiple lines here for the sake of keeping the forum layout in tact - please make them into the same line again when using this code snippet.
Note that I just hacked it into the BitTornado part - if you want to make it for both clients move the Trickle code outside the if statement and modify the BT execute string to include the Trickle start.
It works like a charm for me!

P.S. I see a high CPU load which slows down my server when I run 15 torrents at once but I think I can fix that by nice-ing the bt client - this should be possible by simply editing cfg["trickle"] and appending something like "nice -n20" to the end of the command (the script simply executes the command, it does not care we also start nice along the way). *This is untested*
P.P.S. Adjust the -t parameter in cfg["trickled"] to smooth data limiting - my troughput goes from 84 to 96 which I find perfectly acceptable as the maximum is 120kb/s (leaves me room for webpages and email traffic).
P.P.P.S. I'll post this under the 2.0 hacks as well
