Used new Bencoder library 🔩 (#791)

Co-authored-by: Constantine Kovalensky <45331093+kovalensky@users.noreply.github.com>
This commit is contained in:
Roman Kelesidis 2023-06-08 11:45:20 +07:00 committed by GitHub
commit 2369e4cc0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 154 additions and 75 deletions

View file

@ -139,7 +139,7 @@ function drop_fast_announce($lp_info)
function msg_die($msg)
{
$output = \Rych\Bencode\Bencode::encode([
$output = \SandFox\Bencode\Bencode::encode([
'min interval' => (int)1800,
'failure reason' => (string)$msg,
'warning message' => (string)$msg,
@ -409,6 +409,6 @@ if (!$output) {
}
// Return data to client
echo \Rych\Bencode\Bencode::encode($output);
echo \SandFox\Bencode\Bencode::encode($output);
exit;

View file

@ -32,7 +32,7 @@ function error_exit($msg = '')
{
silent_exit();
echo \Rych\Bencode\Bencode::encode(['failure reason' => str_compact($msg)]);
echo \SandFox\Bencode\Bencode::encode(['failure reason' => str_compact($msg)]);
exit;
}

View file

@ -30,7 +30,7 @@ $info_hash = $_GET['info_hash'];
function msg_die($msg)
{
$output = \Rych\Bencode\Bencode::encode([
$output = \SandFox\Bencode\Bencode::encode([
'min interval' => (int)1800,
'failure reason' => (string)$msg,
'warning message' => (string)$msg,
@ -57,6 +57,6 @@ $output['files'][$info_hash] = [
'incomplete' => (int)$row['leechers'],
];
echo \Rych\Bencode\Bencode::encode($output);
echo \SandFox\Bencode\Bencode::encode($output);
exit;

View file

@ -351,7 +351,7 @@ if (!defined('IN_TRACKER')) {
function dummy_exit($interval = 1800)
{
$output = \Rych\Bencode\Bencode::encode([
$output = \SandFox\Bencode\Bencode::encode([
'interval' => (int)$interval,
'min interval' => (int)$interval,
'peers' => (string)DUMMY_PEER,

View file

@ -31,6 +31,7 @@
},
"require": {
"php": "^7.4 || ^8.0",
"arokettu/bencode": "^1.8",
"bugsnag/bugsnag": "v3.29.1",
"egulias/email-validator": "^3.2",
"filp/whoops": "^2.15",
@ -40,7 +41,6 @@
"guzzlehttp/psr7": "^2.4",
"longman/ip-tools": "1.2.1",
"monolog/monolog": "^2.9",
"rych/bencode": "v1.0.0",
"samdark/sitemap": "2.4.0",
"symfony/mailer": "^5.4",
"symfony/polyfill": "v1.27.0",

203
composer.lock generated
View file

@ -4,8 +4,142 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "37120ee700fdd2297989239da1026e46",
"content-hash": "cbc309d56fdcd2fb85185ac081a1c053",
"packages": [
{
"name": "arokettu/bencode",
"version": "1.8.1",
"source": {
"type": "git",
"url": "https://github.com/arokettu/bencode.git",
"reference": "bc268a2ff135321f34d8cbd50fc65240c9979dc4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/arokettu/bencode/zipball/bc268a2ff135321f34d8cbd50fc65240c9979dc4",
"reference": "bc268a2ff135321f34d8cbd50fc65240c9979dc4",
"shasum": ""
},
"require": {
"arokettu/is-resource": "^1.0",
"php": "^7.0 | ^8.0"
},
"provide": {
"sandfoxme/bencode": "self.version"
},
"require-dev": {
"brick/math": "*",
"ext-gmp": "*",
"ext-json": "*",
"mikey179/vfsstream": "^1.6",
"pear/math_biginteger": "^1.0",
"phpunit/phpunit": ">=6.0.0 <10",
"psy/psysh": "*",
"sandfox.dev/code-standard": "^10@dev",
"squizlabs/php_codesniffer": "*"
},
"suggest": {
"brick/math": "In case you need integers larger than your architecture supports",
"ext-gmp": "In case you need integers larger than your architecture supports",
"pear/math_biginteger": "In case you need integers larger than your architecture supports",
"php-64bit": "Running 64 bit is recommended to prevent integer overflow"
},
"type": "library",
"autoload": {
"files": [
"autoload.php"
],
"psr-4": {
"SandFox\\Bencode\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Anton Smirnov",
"email": "sandfox@sandfox.me",
"homepage": "https://sandfox.me",
"role": "developer"
}
],
"description": "BitTorrent's Bencode encoder/decoder",
"homepage": "https://sandfox.dev/php/bencode.html",
"keywords": [
"bencode",
"bittorrent",
"serialize",
"torrent"
],
"support": {
"docs": "https://bencode.readthedocs.io/",
"issues": "https://gitlab.com/sandfox/bencode/-/issues",
"source": "https://gitlab.com/sandfox/bencode"
},
"time": "2022-12-14T19:14:48+00:00"
},
{
"name": "arokettu/is-resource",
"version": "1.0.2",
"source": {
"type": "git",
"url": "https://github.com/arokettu/is-resource.git",
"reference": "a89a239983de35d4916bbbe9acfef053010e3f3a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/arokettu/is-resource/zipball/a89a239983de35d4916bbbe9acfef053010e3f3a",
"reference": "a89a239983de35d4916bbbe9acfef053010e3f3a",
"shasum": ""
},
"require": {
"php": ">= 5.3 < 8.3"
},
"type": "library",
"autoload": {
"files": [
"src/functions.php"
],
"classmap": [
"gen/ResourceMap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Anton Smirnov",
"email": "sandfox@sandfox.me",
"homepage": "https://sandfox.me/",
"role": "developer"
}
],
"description": "Future compatible is_resource() and get_resource_type() that can understand opaque objects",
"homepage": "https://sandfox.dev/php/is-resource.html",
"keywords": [
"compatibility",
"curl",
"gd",
"get_resource_type",
"hash",
"is_resource",
"pgsql",
"php80",
"php81",
"resources",
"sockets"
],
"support": {
"docs": "https://is-resource.readthedocs.io/",
"issues": "https://gitlab.com/sandfox/is-resource/-/issues",
"source": "https://gitlab.com/sandfox/is-resource"
},
"time": "2022-09-01T22:54:06+00:00"
},
{
"name": "bugsnag/bugsnag",
"version": "v3.29.1",
@ -71,16 +205,16 @@
},
{
"name": "composer/ca-bundle",
"version": "1.3.5",
"version": "1.3.6",
"source": {
"type": "git",
"url": "https://github.com/composer/ca-bundle.git",
"reference": "74780ccf8c19d6acb8d65c5f39cd72110e132bbd"
"reference": "90d087e988ff194065333d16bc5cf649872d9cdb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/ca-bundle/zipball/74780ccf8c19d6acb8d65c5f39cd72110e132bbd",
"reference": "74780ccf8c19d6acb8d65c5f39cd72110e132bbd",
"url": "https://api.github.com/repos/composer/ca-bundle/zipball/90d087e988ff194065333d16bc5cf649872d9cdb",
"reference": "90d087e988ff194065333d16bc5cf649872d9cdb",
"shasum": ""
},
"require": {
@ -127,7 +261,7 @@
"support": {
"irc": "irc://irc.freenode.org/composer",
"issues": "https://github.com/composer/ca-bundle/issues",
"source": "https://github.com/composer/ca-bundle/tree/1.3.5"
"source": "https://github.com/composer/ca-bundle/tree/1.3.6"
},
"funding": [
{
@ -143,7 +277,7 @@
"type": "tidelift"
}
],
"time": "2023-01-11T08:27:00+00:00"
"time": "2023-06-06T12:02:59+00:00"
},
{
"name": "doctrine/deprecations",
@ -1491,61 +1625,6 @@
},
"time": "2019-03-08T08:55:37+00:00"
},
{
"name": "rych/bencode",
"version": "v1.0.0",
"target-dir": "Rych/Bencode",
"source": {
"type": "git",
"url": "https://github.com/rchouinard/bencode.git",
"reference": "d1b5c88f3fd7ff1f4167756f0ed63f970a32431c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/rchouinard/bencode/zipball/d1b5c88f3fd7ff1f4167756f0ed63f970a32431c",
"reference": "d1b5c88f3fd7ff1f4167756f0ed63f970a32431c",
"shasum": ""
},
"require": {
"php": ">=5.3.4"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-0": {
"Rych\\Bencode": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ryan Chouinard",
"email": "rchouinard@gmail.com",
"homepage": "http://ryanchouinard.com"
}
],
"description": "Bencode serializer for PHP 5.3+",
"homepage": "https://github.com/rchouinard/bencode",
"keywords": [
"bencode",
"serialize"
],
"support": {
"issues": "https://github.com/rchouinard/bencode/issues",
"source": "https://github.com/rchouinard/bencode/tree/master"
},
"time": "2014-01-13T00:34:03+00:00"
},
{
"name": "samdark/sitemap",
"version": "2.4.0",

View file

@ -32,7 +32,7 @@ if (file_exists($filename) && !$file_contents = file_get_contents($filename)) {
}
}
if (!$tor = \Rych\Bencode\Bencode::decode($file_contents)) {
if (!$tor = \SandFox\Bencode\Bencode::decode($file_contents)) {
return $lang['TORFILE_INVALID'];
}

View file

@ -316,14 +316,14 @@ class Torrent
if (!file_exists($filename)) {
return self::torrent_error_exit('File not exists');
}
if (!$tor = \Rych\Bencode\Bencode::decode($file_contents)) {
if (!$tor = \SandFox\Bencode\Bencode::decode($file_contents)) {
return self::torrent_error_exit('This is not a bencoded file');
}
if ($bb_cfg['bt_disable_dht']) {
$tor['info']['private'] = (int)1;
$fp = fopen($filename, 'wb+');
fwrite($fp, \Rych\Bencode\Bencode::encode($tor));
fwrite($fp, \SandFox\Bencode\Bencode::encode($tor));
fclose($fp);
}
@ -345,7 +345,7 @@ class Torrent
return self::torrent_error_exit($lang['TORFILE_INVALID']);
}
$info_hash = pack('H*', sha1(\Rych\Bencode\Bencode::encode($info)));
$info_hash = pack('H*', sha1(\SandFox\Bencode\Bencode::encode($info)));
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
$info_hash_md5 = md5($info_hash);
@ -496,7 +496,7 @@ class Torrent
$ann_url = $bb_cfg['bt_announce_url'];
$file_contents = file_get_contents($filename);
if (!$tor = \Rych\Bencode\Bencode::decode($file_contents)) {
if (!$tor = \SandFox\Bencode\Bencode::decode($file_contents)) {
bb_die('This is not a bencoded file');
}
@ -539,7 +539,7 @@ class Torrent
unset($tor['comment.utf-8']);
// Send torrent
$output = \Rych\Bencode\Bencode::encode($tor);
$output = \SandFox\Bencode\Bencode::encode($tor);
$dl_fname = '[' . $bb_cfg['server_name'] . '].t' . $topic_id . '.torrent';
if (!empty($_COOKIE['explain'])) {