Skip to content

Commit

Permalink
Merge pull request #256 from PBH-BTN/master
Browse files Browse the repository at this point in the history
v5.0.1
  • Loading branch information
Ghost-chu authored Jul 17, 2024
2 parents 4c475b8 + 139bfc8 commit 5d2c2a3
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 40 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,11 @@ server:
### 为什么有些应该封禁的 Peers 没有封禁

部分规则模块只会在对方和你有速度的时候才会封禁。如果速度为 0,PBH 可能会跳过一些检查以避免误判。
如果是 XunLei 0.0.1.9,新版迅雷下载过程中现在会正常上传,所以在配置文件中默认排除了。
~~如果是 XunLei 0.0.1.9,新版迅雷下载过程中现在会正常上传,所以在配置文件中默认排除了。~~ 自 5.0.1 开始,PBH 将重新封禁所有 XL0019 客户端:[[社区通报] 重新封禁 -XL0019- (Xunlei 0.0.1.9) 客户端](https://github.com/PBH-BTN/PeerBanHelper/issues/254)

### 反吸血进度检查器为什么显示进度超过 100% (例如:102%),是不是出错了?怎么还能超过 100% 的?

不是的,进度检查器会累加此 IP 地址在特定种子上的下载进度。如果对方出现进度回退、断开更换端口重连、更换 PeerID、更换 Client name 重新下载时,下载器会认为这是一个新客户端,并从头开始计算下载数据(吸血者也使用此手段绕过吸血检查)。但对于 PBH 来说,只要对方 IP 地址未改变(或者处于特定区间内),并且下载的种子未更换的情况下,下载进度会持续增量累积,避免对方欺骗反吸血检查。例如一个文件大小是 1000MB,对方下载 102% 代表对方在这个 1000MB 大小的种子上,实际下载了 1020MB 的数据。

## Install4j

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.ghostchu.peerbanhelper</groupId>
<artifactId>peerbanhelper</artifactId>
<version>5.0.0</version>
<version>5.0.1</version>
<packaging>takari-jar</packaging>

<name>PeerBanHelper</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.bspfsystems.yamlconfiguration.configuration.InvalidConfigurationException;
import org.bspfsystems.yamlconfiguration.file.YamlConfiguration;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
Expand All @@ -24,6 +25,20 @@ public ProfileUpdateScript(YamlConfiguration conf) {
this.conf = conf;
}

@UpdateScript(version = 11)
public void reAddXL0019() {
List<String> bannedPeerIds = conf.getStringList("module.peer-id-blacklist.banned-peer-id");
bannedPeerIds.removeIf(s -> s.contains("-xl0019"));
conf.set("module.peer-id-blacklist.banned-peer-id", bannedPeerIds);
List<String> bannedClientNames = conf.getStringList("module.client-name-blacklist.banned-client-name");
bannedClientNames.removeIf(s -> s.contains("xunlei 0019") || s.contains("xunlei 0.0.1.9"));
conf.set("module.client-name-blacklist.banned-client-name", bannedClientNames);
File scripts = new File(Main.getDataDirectory(), "scripts");
File thunderCheckScript = new File(scripts, "thunder-check.av");
if (thunderCheckScript.exists()) {
thunderCheckScript.delete();
}
}
@UpdateScript(version = 10)
public void addBanDuration() {
var module = conf.getConfigurationSection("module");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,23 @@
import com.j256.ormlite.support.BaseConnectionSource;
import com.j256.ormlite.table.TableUtils;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.sql.SQLException;

@Component
@Getter
@Slf4j
public class DatabaseHelper {
private final Database database;

public DatabaseHelper(@Autowired Database database) throws SQLException {
this.database = database;
Logger.setGlobalLogLevel(Level.WARNING);
createTables();

performUpgrade();
}


Expand All @@ -39,14 +41,17 @@ private void createTables() throws SQLException {

private void performUpgrade() throws SQLException {
Dao<MetadataEntity, String> metadata = DaoManager.createDao(getDataSource(), MetadataEntity.class);
MetadataEntity version = metadata.createIfNotExists(new MetadataEntity("version", "1"));
MetadataEntity version = metadata.createIfNotExists(new MetadataEntity("version", "2"));
int v = Integer.parseInt(version.getValue());
if (v == 0) {
if (v < 2) {
try {
// so something
} catch (Exception ignored) {
var historyDao = DaoManager.createDao(getDataSource(), HistoryEntity.class);
historyDao.executeRaw("ALTER TABLE " + historyDao.getTableName() + " ADD COLUMN downloader VARCHAR DEFAULT ''");
} catch (Exception err) {
log.error("Unable to upgrade database schema", err);
}
v++;
v = 2;
}
version.setValue(String.valueOf(v));
metadata.update(version);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ public final class HistoryEntity {
private TranslationComponent description;
@DatabaseField
private String flags;
@DatabaseField(canBeNull = false)
private String downloader;
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void initLoggerRedirection() {
invokeLater(() -> {
JTextArea textArea = mainWindow.getLoggerTextArea();
try {
textArea.append(event.message());
textArea.append(event.message() + "\n");
int linesToCut = (textArea.getLineCount() - event.maxLines()) + (event.maxLines() / 5);
linesToCut = Math.min(linesToCut, textArea.getLineCount());
if (linesToCut > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public void recordPeerBan(PeerAddress address, BanMetadata metadata) {
torrentEntity,
rule,
metadata.getDescription(),
metadata.getPeer().getFlags() == null ? null : metadata.getPeer().getFlags().toString()
metadata.getPeer().getFlags() == null ? null : metadata.getPeer().getFlags().toString(),
metadata.getDownloader()
));
} catch (SQLException e) {
log.error(tlUI(Lang.DATABASE_SAVE_BUFFER_FAILED), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ static class BanLogResponse {
private String module;
private String rule;
private String description;
private String downloader;

public BanLogResponse(String locale, HistoryEntity history) {
this.banAt = history.getBanAt().getTime();
Expand All @@ -198,6 +199,7 @@ public BanLogResponse(String locale, HistoryEntity history) {
this.module = history.getRule().getModule().getName();
this.rule = tl(locale, history.getRule().getRule());
this.description = tl(locale, history.getDescription());
this.downloader = history.getDownloader();
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/profile.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
config-version: 10
config-version: 11
# 检查频率(单位:毫秒)
check-interval: 5000
# 更新 Peers UI 频率(单位:毫秒),此项仅用于显示数据,不影响封禁,建议设置一个不会给下载器增加太多压力的值
Expand Down Expand Up @@ -44,7 +44,7 @@ module:
# miss = 匹配失败返回的行为代码(与上相同)
# 规则从上到下执行
banned-peer-id:
- '{"method":"STARTS_WITH","content":"-xl0019", hit: "FALSE"}' # 排除新版迅雷(会提供上传)
#- '{"method":"STARTS_WITH","content":"-xl0019", hit: "FALSE"}' # 排除新版迅雷(会提供上传,但上传比十分感人 1:2000
- '{"method":"STARTS_WITH","content":"-xl"}'
- '{"method":"STARTS_WITH","content":"-hp"}'
- '{"method":"STARTS_WITH","content":"-xm"}'
Expand All @@ -68,8 +68,8 @@ module:
# 封禁时间,单位:毫秒,使用 default 则跟随全局设置
ban-duration: default
banned-client-name:
- '{"method":"CONTAINS","content":"xunlei 0019", "hit": "FALSE"}' # 排除新版迅雷(会提供上传)
- '{"method":"CONTAINS","content":"xunlei 0.0.1.9", "hit": "FALSE"}' # 排除新版迅雷(会提供上传)
#- '{"method":"CONTAINS","content":"xunlei 0019", "hit": "FALSE"}' # 排除新版迅雷(会提供上传,但上传比十分感人 1:2000
#- '{"method":"CONTAINS","content":"xunlei 0.0.1.9", "hit": "FALSE"}' # 排除新版迅雷(会提供上传,但上传比十分感人 1:2000
- '{"method":"CONTAINS","content":"xunlei"}'
- '{"method":"STARTS_WITH","content":"-xl"}'
- '{"method":"STARTS_WITH","content":"hp/torrent"}'
Expand Down
27 changes: 0 additions & 27 deletions src/main/resources/scripts/thunder-check.av

This file was deleted.

0 comments on commit 5d2c2a3

Please sign in to comment.