commit 9edffc92ebc5a764c50ba6030d89e84c520c1d4b Author: Alexander Popov Date: Sun May 8 22:49:56 2022 +0300 🏴‍☠️ diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9234622 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +root = true + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.php] +indent_style = space +indent_size = 4 + +[README.md] +trim_trailing_whitespace = false diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..cf1ab25 --- /dev/null +++ b/LICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/README.md b/README.md new file mode 100644 index 0000000..840d371 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +RuTracker.ORG announces server proxy +------------------------------------- + +Исходный код прокси для [анонс](https://ru.wikipedia.org/wiki/Анонс) +серверов торрент-трекера RuTracker.ORG 🏴‍☠️ + +Анонс сервер нужен для отдачи списка пиров, а также учёта статистики. +Если у тебя в списке трекеров ошибка подключения, то это то что нужно. + +Лицензия +-------- + +Свобоная 👻 +Код взят из открытого источника, где не было ни копирайтов, ни других данных автора. + +И вообще, какая блин _лицензия_, мы же пираты 💀 + +Оригинальный [код](https://pastebin.com/PBPDsdr1) всё также валяется на Pastebin.com... +там ещё логотип с Украинским флагом. diff --git a/proxy.php b/proxy.php new file mode 100644 index 0000000..11d6280 --- /dev/null +++ b/proxy.php @@ -0,0 +1,73 @@ + true, + + // Список "проксируемых" трекеров + 'allow' => [ + 'rutracker' => [ + 'hosts' => [ + 'bt.t-ru.org', 'bt2.t-ru.org', 'bt3.t-ru.org', 'bt4.t-ru.org', + 'bt.rutracker.cc', 'bt2.rutracker.cc', 'bt3.rutracker.cc', 'bt4.rutracker.cc', + ], + // Адрес анонсера на данном трекере + 'uri' => '/ann', + // Заменить на актуальный пасскей, либо закомментировать, если проверка не требуется + 'check' => [ 'pk' => '0123456789abcdef', ], + ], + ], +]; + +/******************************************************************************/ + +$_GET['ip'] = $_SERVER['REMOTE_ADDR']; + +$host = $_GET['dst']; +unset($_GET['dst']); + +$uri = null; +foreach ($config['allow'] as $item) { + // Разрешаем проксирование только для известных хостов + if (in_array($host, $item['hosts'])) { + $uri = $item['uri']; + // Проверяем допустимые для данного трекера параметры в запросе, например пасскей + foreach ($item['check'] as $key => $value) { + if (!isset($_GET[$key]) || $_GET[$key] != $value) { + $uri = null; + break; + } + } + break; + } +} + +if ($uri) { + $announce = "http://{$host}{$uri}?" . http_build_query($_GET); + $ses = curl_init($announce); + curl_setopt_array($ses, [ + CURLOPT_RETURNTRANSFER => true, + CURLOPT_TIMEOUT => 20, + CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'], // Может проверяться анонсером + ]); + $result = curl_exec($ses); + $info = curl_getinfo($ses); + header("Content-Type: {$info['content_type']}", true, $info['http_code']); + print $result; +} else { + header('Content-Type: text/plain', true, 404); +} + +if ($config['log']) { + // Сохраняем лог запроса/ответа для отладки + $logfile = __DIR__ . '/btlog/' . date('Y-m-d/U') . '.txt'; + mkdir(dirname($logfile), 0700, true); + file_put_contents( + $logfile, + var_export($_GET, true) . PHP_EOL . PHP_EOL . + var_export($_POST, true) . PHP_EOL . PHP_EOL . + var_export($_SERVER, true) . PHP_EOL . PHP_EOL . + var_export($info, true) . PHP_EOL . PHP_EOL . + $result + ); +} +?>