deny Bittorrent Protocol v2 torrents

This commit is contained in:
xiaomlove
2022-02-12 15:08:18 +08:00
parent 186bebfe12
commit 379b84b905
5 changed files with 12 additions and 10 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ return [
'stateful' => explode(',', env( 'stateful' => explode(',', env(
'SANCTUM_STATEFUL_DOMAINS', 'SANCTUM_STATEFUL_DOMAINS',
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1,'.parse_url(env('APP_URL'), PHP_URL_HOST) 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1,'.parse_url(env('APP_URL', ''), PHP_URL_HOST)
)), )),
/* /*
@@ -21,7 +21,7 @@ class CreateMedalsTable extends Migration
$table->string('image_large')->nullable(); $table->string('image_large')->nullable();
$table->string('image_small')->nullable(); $table->string('image_small')->nullable();
$table->integer('price')->default(0); $table->integer('price')->default(0);
$table->integer('duration')->default(0); $table->integer('duration')->nullable();
$table->timestamps(); $table->timestamps();
}); });
} }
+6 -8
View File
@@ -1,6 +1,5 @@
<?php <?php
# IMPORTANT: Do not edit below unless you know what you are doing! # IMPORTANT: Do not edit below unless you know what you are doing!
use Illuminate\Support\Facades\DB;
if(!defined('IN_TRACKER')) if(!defined('IN_TRACKER'))
die('Hacking attempt!'); die('Hacking attempt!');
@@ -127,12 +126,11 @@ function promotion($class, $down_floor_gb, $minratio, $time_week, $addinvite = 0
function demotion($class,$deratio){ function demotion($class,$deratio){
global $lang_cleanup_target; global $lang_cleanup_target;
$newclass = $class - 1; $newclass = $class - 1;
$minSeedPoints = \App\Models\User::getMinSeedPoints($class); $sql = "SELECT id FROM users WHERE class = $class AND uploaded / downloaded < $deratio";
if ($minSeedPoints === false) { $res = sql_query($sql) or sqlerr(__FILE__, __LINE__);
throw new \RuntimeException("class: $class can't get min seed points."); $matchUserCount = mysql_num_rows($res);
} do_log("sql: $sql, match user count: $matchUserCount");
$res = sql_query("SELECT id FROM users WHERE class = $class AND seed_points < $minSeedPoints AND uploaded / downloaded < $deratio") or sqlerr(__FILE__, __LINE__); if ($matchUserCount > 0)
if (mysql_num_rows($res) > 0)
{ {
$dt = sqlesc(date("Y-m-d H:i:s")); $dt = sqlesc(date("Y-m-d H:i:s"));
while ($arr = mysql_fetch_assoc($res)) while ($arr = mysql_fetch_assoc($res))
@@ -292,7 +290,7 @@ function docleanup($forceAll = 0, $printProgress = false) {
if ($is_donor == 'yes' && $donortimes_bonus > 0) if ($is_donor == 'yes' && $donortimes_bonus > 0)
$all_bonus = $all_bonus * $donortimes_bonus; $all_bonus = $all_bonus * $donortimes_bonus;
KPS("+",$all_bonus,$arr["userid"]); KPS("+",$all_bonus,$arr["userid"]);
\App\Models\User::query()->where('id', $arr["userid"])->update(['seed_points' => new \Illuminate\Database\Query\Expression("seed_points + $seedPoints")]); sql_query("update users set seed_points = seed_points + $seedPoints where id = {$arr["userid"]}");
} }
} }
$log = 'calculate seeding bonus'; $log = 'calculate seeding bonus';
+1
View File
@@ -98,6 +98,7 @@ return array (
'smtp_from' => NULL, 'smtp_from' => NULL,
'smtpaddress' => 'smtp.qq.com', 'smtpaddress' => 'smtp.qq.com',
'smtpport' => '25', 'smtpport' => '25',
'encryption' => 'ssl',
'accountname' => '', 'accountname' => '',
'accountpassword' => '', 'accountpassword' => '',
), ),
+3
View File
@@ -117,6 +117,9 @@ function checkTorrentDict($dict, $key, $type = null)
} }
$info = checkTorrentDict($dict, 'info'); $info = checkTorrentDict($dict, 'info');
if (isset($info['piece layers']) || isset($info['files tree']) || (isset($info['meta version']) && $info['meta version'] == 2)) {
bark('Torrent files created with Bittorrent Protocol v2, or hybrid torrents are not supported.');
}
$plen = checkTorrentDict($info, 'piece length', 'integer'); // Only Check without use $plen = checkTorrentDict($info, 'piece length', 'integer'); // Only Check without use
$dname = checkTorrentDict($info, 'name', 'string'); $dname = checkTorrentDict($info, 'name', 'string');
$pieces = checkTorrentDict($info, 'pieces', 'string'); $pieces = checkTorrentDict($info, 'pieces', 'string');