Skip to content

Commit

Permalink
听兔子的话
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
paulzzh and coderabbitai[bot] authored Nov 16, 2024
1 parent 6ff6618 commit 5d77cd8
Showing 1 changed file with 12 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 5d77cd8

Please sign in to comment.