From 5d77cd8363c8dbdb1c2b59e9ccab496166d52da3 Mon Sep 17 00:00:00 2001 From: paulzzh <28055560+paulzzh@users.noreply.github.com> Date: Sun, 17 Nov 2024 03:43:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=AC=E5=85=94=E5=AD=90=E7=9A=84=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../impl/rule/ProgressCheatBlocker.java | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ProgressCheatBlocker.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ProgressCheatBlocker.java index a980efbcd1..ca4024d3d0 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ProgressCheatBlocker.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ProgressCheatBlocker.java @@ -255,31 +255,22 @@ private void reloadConfig() { final double clientProgress = peer.getProgress(); // 客户端汇报进度 // actualUploaded = -1 代表客户端不支持统计此 Peer 总上传量 if (actualUploaded != -1 && blockExcessiveClients) { - if (actualUploaded > torrentSize) { - // 下载量超过种子大小,检查 - long maxAllowedExcessiveThreshold = (long) (torrentSize * excessiveThreshold); + long referenceSize = (completedSize > 0 && actualUploaded > completedSize) ? completedSize : torrentSize; + if (actualUploaded > referenceSize) { + long maxAllowedExcessiveThreshold = (long) (referenceSize * excessiveThreshold); if (actualUploaded > maxAllowedExcessiveThreshold) { clientTask.setBanDelayWindowEndAt(0L); - progressRecorder.invalidate(client); // 封禁时,移除缓存 - return new CheckResult(getClass(), PeerAction.BAN, banDuration, new TranslationComponent(Lang.PCB_RULE_REACHED_MAX_ALLOWED_EXCESSIVE_THRESHOLD), - new TranslationComponent(Lang.MODULE_PCB_EXCESSIVE_DOWNLOAD, - torrentSize, - actualUploaded, - maxAllowedExcessiveThreshold)); - } - } else if (completedSize > 0 && (actualUploaded > completedSize)) { - // 下载量超过任务大小,检查 - long maxAllowedExcessiveThreshold = (long) (completedSize * excessiveThreshold); - if (actualUploaded > maxAllowedExcessiveThreshold) { - clientTask.setBanDelayWindowEndAt(0L); - progressRecorder.invalidate(client); // 封禁时,移除缓存 - return new CheckResult(getClass(), PeerAction.BAN, banDuration, new TranslationComponent(Lang.PCB_RULE_REACHED_MAX_ALLOWED_EXCESSIVE_THRESHOLD), - new TranslationComponent(Lang.MODULE_PCB_EXCESSIVE_DOWNLOAD, - completedSize, - actualUploaded, - maxAllowedExcessiveThreshold)); + progressRecorder.invalidate(client); // Remove from cache upon banning + return new CheckResult(getClass(), PeerAction.BAN, banDuration, + new TranslationComponent(Lang.PCB_RULE_REACHED_MAX_ALLOWED_EXCESSIVE_THRESHOLD), + new TranslationComponent(Lang.MODULE_PCB_EXCESSIVE_DOWNLOAD, + referenceSize, + actualUploaded, + maxAllowedExcessiveThreshold)); } } + } + } } // 如果客户端报告自己进度更多,则跳过检查 if (actualProgress <= clientProgress) {