Tracker announce & scrape improvements 🥳 (#901)

* Tracker announce & scrape improvements

* Fixed null variables

Co-Authored-By: Constantine Kovalensky <45331093+kovalensky@users.noreply.github.com>

* Hybrid topics handling in announcer

* Updated

* Use correct data types

* Revert "Use correct data types"

This reverts commit bc9f0e4d6f.

* Update announce.php

* Showing downloaded times in stats

* Updated

* Updated

* Debugging variables

* Update scrape.php

* Updated

* Update announce.php

* Update announce.php

* Code re-formatting

* Code re-formatting

* Updated

* Update config.php

* Update tr_make_snapshot.php

* Update tr_complete_count.php

* Stopped event should be handled before cache check

* Include torrent download name in magnet link

* Magnet name re-formatting

* Smart cache management

---------

Co-authored-by: Constantine Kovalensky <45331093+kovalensky@users.noreply.github.com>
This commit is contained in:
Roman Kelesidis 2023-09-14 08:38:07 +07:00 committed by GitHub
commit c654a9ae36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 125 additions and 86 deletions

View file

@ -27,16 +27,23 @@ $info_hash = isset($_GET['info_hash']) ? (string)$_GET['info_hash'] : null;
// Verify info_hash
if (!isset($info_hash)) {
msg_die('info_hash does not exist');
msg_die('info_hash was not provided');
}
// Store info hash in hex format
$info_hash_hex = bin2hex($info_hash);
// Check info_hash version
if (strlen($info_hash) == 32) {
$is_bt_v2 = true;
} elseif (strlen($info_hash) == 20) {
$is_bt_v2 = false;
} else {
msg_die('Invalid info_hash: ' . $info_hash);
msg_die('Invalid info_hash: ' . $info_hash_hex);
}
if ($lp_scrape_info = CACHE('tr_cache')->get(SCRAPE_LIST_PREFIX . $info_hash_hex)) {
die(\SandFox\Bencode\Bencode::encode($lp_scrape_info));
}
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
@ -55,7 +62,7 @@ $row = DB()->fetch_row("
");
if (!$row) {
msg_die('Torrent not registered, info_hash = ' . bin2hex($info_hash));
msg_die('Torrent not registered, info_hash = ' . $info_hash_hex);
}
$output['files'][$info_hash] = [
@ -64,6 +71,8 @@ $output['files'][$info_hash] = [
'incomplete' => (int)$row['leechers'],
];
$peers_list_cached = CACHE('tr_cache')->set(SCRAPE_LIST_PREFIX . $info_hash_hex, $output, SCRAPE_LIST_EXPIRE);
echo \SandFox\Bencode\Bencode::encode($output);
exit;