Skip to content

Commit

Permalink
fix announce check upload speed
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomlove committed Jul 30, 2022
1 parent bb585ec commit 60326b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
3 changes: 3 additions & 0 deletions app/Repositories/TrackerRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,9 @@ private function checkSeedBox(Torrent $torrent, $queries, $dataTraffic, User $us
return;
}
$duration = Carbon::now()->diffInSeconds($peer->last_action);
if ($duration <= 0) {
return;
}
$upSpeedMbps = number_format(($dataTraffic['uploaded_increment'] / $duration / 1024 / 1024) * 8);
$notSeedBoxMaxSpeedMbps = Setting::get('seed_box.not_seed_box_max_speed');
do_log("upSpeedMbps: $upSpeedMbps, notSeedBoxMaxSpeedMbps: $notSeedBoxMaxSpeedMbps");
Expand Down
17 changes: 9 additions & 8 deletions public/announce.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,17 @@
$snatchInfo = mysql_fetch_assoc(sql_query(sprintf('select * from snatched where torrentid = %s and userid = %s order by id desc limit 1', $torrentid, $userid)));
$upthis = $trueupthis = max(0, $uploaded - $self["uploaded"]);
$downthis = $truedownthis = max(0, $downloaded - $self["downloaded"]);

$announcetime = ($self["seeder"] == "yes" ? "seedtime = seedtime + {$self['announcetime']}" : "leechtime = leechtime + {$self['announcetime']}");
$is_cheater = false;
$notSeedBoxMaxSpeedMbps = get_setting('seed_box.not_seed_box_max_speed');
$upSpeedMbps = number_format(($trueupthis / $self['announcetime'] / 1024 / 1024) * 8);
do_log("notSeedBoxMaxSpeedMbps: $notSeedBoxMaxSpeedMbps, upSpeedMbps: $upSpeedMbps");
if ($isSeedBoxRuleEnabled && !($az['class'] >= \App\Models\User::CLASS_VIP || $isDonor) && !$isIPSeedBox && $upSpeedMbps > $notSeedBoxMaxSpeedMbps) {
(new \App\Repositories\UserRepository())->updateDownloadPrivileges(null, $userid, 'no');
do_log("user: $userid downloading privileges have been disabled! (over speed)", 'error');
err("Your downloading privileges have been disabled! (over speed)");
if ($self['announcetime'] > 0 && $isSeedBoxRuleEnabled && !($az['class'] >= \App\Models\User::CLASS_VIP || $isDonor) && !$isIPSeedBox) {
$notSeedBoxMaxSpeedMbps = get_setting('seed_box.not_seed_box_max_speed');
$upSpeedMbps = number_format(($trueupthis / $self['announcetime'] / 1024 / 1024) * 8);
do_log("notSeedBoxMaxSpeedMbps: $notSeedBoxMaxSpeedMbps, upSpeedMbps: $upSpeedMbps");
if ($upSpeedMbps > $notSeedBoxMaxSpeedMbps) {
(new \App\Repositories\UserRepository())->updateDownloadPrivileges(null, $userid, 'no');
do_log("user: $userid downloading privileges have been disabled! (over speed)", 'error');
err("Your downloading privileges have been disabled! (over speed)");
}
}

if ($cheaterdet_security){
Expand Down

0 comments on commit 60326b2

Please sign in to comment.