tracker support authkey

This commit is contained in:
xiaomlove
2021-06-03 21:13:59 +08:00
parent 272b716f35
commit ed68efeeea
6 changed files with 117 additions and 20 deletions
+26 -1
View File
@@ -3,10 +3,35 @@ require_once('../include/bittorrent_announce.php');
require_once('../include/benc.php');
dbconn_announce();
do_log(nexus_json_encode($_SERVER));
$log = "";
//1. BLOCK ACCESS WITH WEB BROWSERS AND CHEATS!
$agent = $_SERVER["HTTP_USER_AGENT"];
block_browser();
//check authkey
if (!empty($_REQUEST['authkey'])) {
$arr = explode('|', $_REQUEST['authkey']);
if (count($arr) != 3) {
err('Invalid authkey');
}
$torrentId = $arr[0];
$uid = $arr[1];
$torrentRep = new \App\Repositories\TorrentRepository();
try {
$decrypted = $torrentRep->checkTrackerReportAuthKey($_REQUEST['authkey']);
} catch (\Exception $exception) {
err($exception->getMessage());
}
if (empty($decrypted)) {
err('Invalid authkey');
}
$userInfo = \App\Models\User::query()->where('id', $uid)->first(['id', 'passkey']);
if (!$userInfo) {
err('Invalid authkty');
}
$_GET['passkey'] = $userInfo->passkey;
}
//2. GET ANNOUNCE VARIABLES
// get string type passkey, info_hash, peer_id, event, ip from client
foreach (array("passkey","info_hash","peer_id","event") as $x)
+3 -1
View File
@@ -105,9 +105,11 @@ if (strlen($CURUSER['passkey']) != 32) {
sql_query("UPDATE users SET passkey=".sqlesc($CURUSER['passkey'])." WHERE id=".sqlesc($CURUSER['id']));
}
$trackerReportAuthKey = $torrentRep->getTrackerReportAuthKey($id, $CURUSER['id'], true);
$dict = bdec_file($fn, $max_torrent_size);
//$dict['value']['announce']['value'] = $ssl_torrent . $base_announce_url . "?passkey=$CURUSER[passkey]";
$dict['value']['announce']['value'] = getSchemeAndHttpHost() . "/announce.php?passkey=$CURUSER[passkey]";
$dict['value']['announce']['value'] = getSchemeAndHttpHost() . "/announce.php?authkey=$trackerReportAuthKey";
$dict['value']['announce']['string'] = strlen($dict['value']['announce']['value']).":".$dict['value']['announce']['value'];
$dict['value']['announce']['strlen'] = strlen($dict['value']['announce']['string']);
/*if ($announce_urls[1] != "") // add multi-tracker