From 25db588c95e693acf3681d71ebbe70e15b3cc0b2 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Sun, 6 Jun 2021 01:30:59 +0800 Subject: [PATCH] log not register torrent info_hash --- app/Console/Commands/Test.php | 9 +++++++-- public/announce.php | 9 ++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index bbc29dc3..ba10f477 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -52,8 +52,13 @@ class Test extends Command public function handle() { // $r = \Illuminate\Support\Facades\Schema::getColumnListing('torrents'); - $r = urldecode('%b5%8f%7c%a9%85%ed%e2%bb%09%fd1%ab%8d%11%e5%11%bb%18%deD'); - $r = bin2hex($r); +// $r = urldecode('%b5%8f%7c%a9%85%ed%e2%bb%09%fd1%ab%8d%11%e5%11%bb%18%deD'); +// $r = bin2hex($r); + $str = 'passkey=bef88d0cbe4ccbc1569b8404d09c4c5a&info_hash=%cd%8d%5b%09%08%d7%1d%01_o8%c0%e1Wd%ff%95%84J%e1&peer_id=-TR3000-zxcl8rs3my5o&port=51416&uploaded=0&downloaded=0&left=0&numwant=80&key=2d2ebd37&compact=1&supportcrypto=1&ipv6=240e%3A3b1%3A6400%3Ac20%3A211%3A32ff%3Afebb%3A9fb1'; + $firstNeedle = "info_hash="; + $start = strpos($str, $firstNeedle) + strlen($firstNeedle); + $end = strpos($str, "&", $start); + $r = substr($str, $start, $end - $start); dd($r); } diff --git a/public/announce.php b/public/announce.php index f934dc09..48f850df 100644 --- a/public/announce.php +++ b/public/announce.php @@ -112,7 +112,14 @@ if (!$torrent = $Cache->get_value('torrent_hash_'.$info_hash.'_content')){ $Cache->cache_value('torrent_hash_'.$info_hash.'_content', $torrent, 350); } if (!$torrent) { - do_log("[TORRENT NOT EXISTS] $checkTorrentSql, params: " . $_SERVER['QUERY_STRING']); + $firstNeedle = "info_hash="; + $queryString = $_SERVER['QUERY_STRING']; + $start = strpos($queryString, $firstNeedle) + strlen($firstNeedle); + $end = strpos($queryString, "&", $start); + $infoHashUrlEncode = substr($queryString, $start, $end - $start); + do_log("[TORRENT NOT EXISTS] $checkTorrentSql, params: $queryString"); + do_log("[TORRENT NOT EXISTS] infoHashUrlEncode: $infoHashUrlEncode"); + err("torrent not registered with this tracker"); } elseif ($torrent['banned'] == 'yes' && $az['class'] < $seebanned_class) err("torrent banned");