ich betreibe einen privaten Bittorrent-Tracker und habe leider das Problem, dass ab ca. 20.000 Peers der SQL-Server derart belastet ist, dass die Seite sich totlädt. Ich gehe davon aus, dass die Hauptbelastung von der "announce.php" kommt, weil diese mit den Clients kommuniziert.
Ist es möglich stattdessen eine Anwendung laufen zulassen?
Hier mal die PHP. Falls ihr noch irgendwelche Infos braucht, meldet Euch bitte.
PHP Code:
<?
/*
// +--------------------------------------------------------------------------+
// | Project: NVTracker - NetVision BitTorrent Tracker |
// +--------------------------------------------------------------------------+
// | This file is part of NVTracker. NVTracker is based on BTSource, |
// | originally by RedBeard of TorrentBits, extensively modified by |
// | Gartenzwerg. |
// | |
// | NVTracker is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation; either version 2 of the License, or |
// | (at your option) any later version. |
// | |
// | NVTracker is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with NVTracker; if not, write to the Free Software Foundation, |
// | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +--------------------------------------------------------------------------+
// | Obige Zeilen dürfen nicht entfernt werden! Do not remove above lines! |
// +--------------------------------------------------------------------------+
*/
for ($i=0;$i<strlen($hexdata);$i+=2) {
$bindata.=chr(hexdec(substr($hexdata,$i,2)));
}
return $bindata;
}
function err($msg)
{
benc_resp(array("failure reason" => array(type => "string", value => $msg)));
hit_end();
exit();
}
function benc_resp($d)
{
benc_resp_raw(benc(array(type => "dictionary", value => $d)));
}
function benc_resp_raw($x)
{
header("Content-Type: text/plain");
header("Pragma: no-cache");
print($x);
}
function check_ip_limit() {
global $userid;
// Check IP limit
$res = mysql_query("SELECT DISTINCT(ip) AS ip FROM peers WHERE userid=$userid");
$count = 0;
$found = FALSE;
while ($row = mysql_fetch_assoc($res)) {
$count++;
if ($row["ip"] == $ip) {
$found = TRUE;
break;
}
}
if (!$found && $count >= $GLOBALS["MAX_PASSKEY_IPS"])
err("Zu viele unterschiedliche IPs fuer diesen Benutzer (max ".$GLOBALS["MAX_PASSKEY_IPS"].")");
}
if (in_array($_SERVER["HTTP_USER_AGENT"], $GLOBALS["BAN_USERAGENTS"]))
err("Du benutzt einen gebannten Client. Bitte lies die FAQ!");
$req = "info_hash:peer_id:!ip:port:uploaded:downloaded:left:!event";
if ($GLOBALS["CLIENT_AUTH"] == CLIENT_AUTH_PASSKEY) {
if ($GLOBALS["PASSKEY_SOURCE"] == PASSKEY_USE_PARAM) {
$req .= ":passkey";
// Using announce.php?passkey={KEY} will lead to an incorrect parameter list,
// so the first parameter appended by the client gets appended to the passkey parameter.
// This match will extract the parameter to $_GET
if (preg_match("/^([a-f0-9]{16})\\?(.*?)\\=(.*)$/is", $_GET["passkey"], $m)) {
$_GET["passkey"] = $m[1];
$_GET[$m[2]] = $m[3];
}
}
if ($GLOBALS["PASSKEY_SOURCE"] == PASSKEY_USE_SUBDOMAIN) {
preg_match("/^([a-f0-9]{16})\\./i", $_SERVER["HTTP_HOST"], $m);
if (strlen($m[1])==16)
$passkey = $m[1];
else
err("Fehlender Parameter fuer Announce: passkey");
}
}
foreach (explode(":", $req) as $x)
{
if ($x[0] == "!")
{
$x = substr($x, 1);
$opt = 1;
}
else
$opt = 0;
if (!isset($_GET[$x]))
{
if (!$opt)
err("Fehlender Parameter fuer Announce: $x");
continue;
}
$GLOBALS[$x] = unesc($_GET[$x]);
}
foreach ($GLOBALS["BAN_PEERIDS"] as $banned_id)
{
if (substr($GLOBALS["peer_id"],0,strlen($banned_id)) == $banned_id)
err("Du benutzt einen gebannten Client. Bitte lies das FAQ!");
}
// Deny access made with a browser...
if (ereg("^Mozilla\\/", $agent) || ereg("^Opera\\/", $agent) || ereg("^Links ", $agent) || ereg("^Lynx\\/", $agent))
err("Dieser Torrent ist dem Tracker nicht bekannt");
if (!$port || $port > 0xffff)
err("Ungueltiges TCP-Port");
if (!isset($event))
$event = "";
$seeder = ($left == 0) ? "yes" : "no";
dbconn(false);
hit_count();
$res = mysql_query("SELECT id, name, category, banned, activated, seeders + leechers AS numpeers, UNIX_TIMESTAMP(added) AS ts FROM torrents WHERE " . hash_where("info_hash", $info_hash));
$torrent = mysql_fetch_assoc($res);
if (!$torrent)
err("Dieser Torrent ist dem Tracker nicht bekannt");
if ($torrent["activated"] != "yes")
err("Dieser Torrent ist dem Tracker nicht bekannt");
$selfwhere = "torrent = $torrentid AND " . hash_where("peer_id", $peer_id);
if (!isset($self))
{
$res = mysql_query("SELECT $fields FROM peers WHERE $selfwhere");
$row = mysql_fetch_assoc($res);
if ($row)
{
$userid = $row["userid"];
if (!isset($self))
{
if ($GLOBALS["CLIENT_AUTH"] == CLIENT_AUTH_PASSKEY) {
$rz = mysql_query("SELECT id, uploaded, downloaded, class, tlimitseeds, tlimitleeches, tlimitall FROM users WHERE passkey=".sqlesc(hex2bin($passkey))." AND enabled = 'yes' ORDER BY last_access DESC LIMIT 1") or err("Tracker error 2");
if ($MEMBERSONLY && mysql_num_rows($rz) == 0)
err("Ungueltiger PassKey. Lies das FAQ!");
} else {
$rz = mysql_query("SELECT id, uploaded, downloaded, class, tlimitseeds, tlimitleeches, tlimitall FROM users WHERE ip=".sqlesc($ip)." AND enabled = 'yes' ORDER BY last_access DESC LIMIT 1") or err("Tracker error 2");
if ($MEMBERSONLY && mysql_num_rows($rz) == 0)
err("Unbekannte IP. Lies das FAQ!");
}
// Create traffic log entry if not existent
$res = mysql_query("SELECT * FROM `traffic` WHERE `userid`=$userid AND `torrentid`=$torrentid");
if (@mysql_num_rows($res) == 0)
mysql_query("INSERT INTO `traffic` (`userid`,`torrentid`) VALUES ($userid, $torrentid)");
}
else
{
// We won't check the IP again, since this would disrupt a user's download if he
// uses another IP to continue browsing on the tracker.
if ($GLOBALS["CLIENT_AUTH"] == CLIENT_AUTH_PASSKEY) {
$res = mysql_query("SELECT passkey,id FROM users WHERE id=$userid AND enabled = 'yes'");
$pkrow = mysql_fetch_assoc($res);
$passkey = hex2bin($passkey);
if ($passkey != $pkrow["passkey"])
err("Ungueltiger PassKey. Lies das FAQ!");
$arr = mysql_fetch_assoc(mysql_query("SELECT UNIX_TIMESTAMP(last_action) AS lastaction FROM peers WHERE $selfwhere"));
$interval = time() - $arr["lastaction"];
if ($interval == 0) $interval = 1;
// If speed is higher than 4 MB/sec, the user is apparently cheating.
// Frustrate him by adding his desired upload to his download ^^
if (($upthis / $interval) > $GLOBALS["RATIOFAKER_THRESH"]) {
// Write mod comment
write_modcomment($userid, 0, "announce.php: Ratiofaker-Tool verwendet: ".mksize($upthis)." Upload, Fake Rate: ".mksize($upthis / $interval)."/sek");
// Add upload as download and zero out upload.
$downthis += $upthis;
$upthis = 0;
}
if ($upthis > 0 || $downthis > 0) {
// Update traffic for current torrent
if ($self["seeder"] == "yes")
mysql_query("UPDATE `traffic` SET `downloaded`=`downloaded`+$downthis, `uploaded`=`uploaded`+$upthis, `uploadtime`=`uploadtime`+$interval WHERE `userid`=$userid AND `torrentid`=$torrentid");
else
mysql_query("UPDATE `traffic` SET `downloaded`=`downloaded`+$downthis, `uploaded`=`uploaded`+$upthis, `downloadtime`=`downloadtime`+$interval,`uploadtime`=`uploadtime`+$interval WHERE `userid`=$userid AND `torrentid`=$torrentid");
mysql_query("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=$userid") or err("Tracker error 3");
}
}
// Bad user? If yes, we'll provide him with an invalid peer list :)
$acctdata = mysql_fetch_assoc(mysql_query("SELECT baduser FROM accounts WHERE userid=$userid"));
if ($acctdata["baduser"]==1) {
$resarr = bdec($resp);
for ($I=0; $I<count($resarr["value"]["peers"]["value"]); $I++) {
$tmpip = $resarr["value"]["peers"]["value"][$I]["value"]["ip"]["value"];
$resarr["value"]["peers"]["value"][$I]["value"]["port"]["value"] += mt_rand(100,250);
if (isset($self))
{
$announcedelay = @mysql_fetch_assoc(@mysql_query("SELECT * FROM `announcedelay` WHERE `peer_id`=".sqlesc($peer_id)));
if (is_array($announcedelay)) {
if ($announcedelay["second"] == 0)
mysql_query("UPDATE `announcedelay` SET `second`=UNIX_TIMESTAMP(),`quantity`=$uploaded WHERE `peer_id`=".sqlesc($peer_id));
}
Also z.B. Tracker mit XBT-Source können derart viele Peers verwalten, dass ich glaube, dass ein C++ Backend schon einen Vorteil bringt. Bitreactor zum Beispiel verwaltet derzeit rund 8 Mio Peers.
[S] Facebook anwendung [B] e*g 04/08/2012 - elite*gold Trading - 0 Replies Ich suche eine Facebook anwendung für meine page bietet mir einfach irgent eine an + Preis
Anwendung 01/16/2012 - Flyff Private Server - 8 Replies Hallo,
Ich habe eben den Antihack von Tom gestartet und dann
kam folgende Meldung:
Die Anwendung oder DLL C:\Dokumente und Einstellungen\user\Desktop\Toms \MSVCP100.dll ist keine gültige Windows-Date. Überprüfen Sie dies mit der Installationskette.
Habe die MSVCP100.dll schon einmal auf einer Seite runter geladen, aber leider kam diese Meldung auch.
Screen:
http://img337.imageshack.us/img337/5980/unbenannt lns.png
C++ MFC-Anwendung 11/07/2011 - C/C++ - 5 Replies Hallo alle zusammen.
Folgendes Problem ich habe Visual C++ also nicht die voll Version.
Und ich habe keine MFC-Anwendung in der Version.
Aber ich benötige sie kann mir jemand vielleicht sagen wie ich an die MFC-Anwendung rann kommen kann möglichst kostenlos?
Mit freundlichen Grüßen
Ko§oVo
Fehler in Anwendung HELP 09/21/2011 - Metin2 - 3 Replies Hallo leute..
Ich will Metin|Longju3 starten aber wenn ich starte kommt das : 1_longju3.exe |(oder metin2 jenachdem welches ich öffne )
Die Anwendung konnte nicht richtig initalisiert werden (0xe06d7363).Klicken Sie auf "OK",um die Anwendung zu beenden. (wenn es euch hilft : es kommt immer 2mal hintereinander) BITTE UM HILFE!
GUI in fremde Anwendung 11/11/2009 - AutoIt - 2 Replies Hi, weiß jmd wie man eine GUI (z.B. einen Button) in eine fremde Anwendung bekommt (z.B. World of Warcraft oder Guild Wars). Auf jeden Fall eine DirectX Anwendung...
Hab mal gelesen das ich da was hooken muss. Stimmt das? Hab leider nur noch nicht so viel Kenntnisse vom Hooken.
mfg
Markus