Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v7.3.2 #904

Merged
merged 27 commits into from
Jan 13, 2025
Merged

v7.3.2 #904

merged 27 commits into from
Jan 13, 2025

Conversation

Ghost-chu
Copy link
Collaborator

@Ghost-chu Ghost-chu commented Jan 13, 2025

v7.3.2 是 v7.3.0 的一个补丁,有关 v7.3.0 的主要更新内容,请参见 v7.3.0 更新日志

发布日期的近 3 天内的其它次要更新:

错误修复

  • [WebUI] 在更新或重启 PeerBanHelper 时没有在浏览器中关闭已经打开的 WebUI 标签页时,可能引发多次失败请求,以致触发防暴力破解保护,封禁用户 IP @Gaojianli
    • 此修复需要下次升级时生效,本次升级前仍需要您关闭所有 PeerBanHelper WebUI 页面
  • [WebUI] 修复当种子名称过长时,悬浮显示的 InfoHash 气泡可能被遮挡的问题 @Ghost-chu
  • 修复某些 IPV6 地址无法在 IP 查询功能中搜索到有关记录 [BUG] 某些 IPV6 地址无法在 IP 查询 功能中搜索到有关记录,仅有基本信息 #849 @Ghost-chu
  • 修复某些情况下,可翻译组件在序列化/反序列化过程中被破坏的问题 @Ghost-chu @paulzzh
    • 由于序列化方式更改,本次升级后,PeerBanHelper 的未读消息通知会被清除
  • 修复 qBittorrent 下载器登录出错时,向用户错误地显示应静默处理的堆栈跟踪的问题 @Ghost-chu
  • 修复 IP 封禁排行搜索功能不起作用的问题 @Ghost-chu

Docker

DockerHub: ghostchu/peerbanhelper:v7.3.2
阿里云国内镜像加速: registry.cn-hangzhou.aliyuncs.com/ghostchu/peerbanhelper:v7.3.2

renovate bot and others added 25 commits January 13, 2025 11:03
修复 hash 气泡被覆盖的问题
Bumps org.apache.james:apache-mime4j-storage from 0.8.11 to 0.8.12.

---
updated-dependencies:
- dependency-name: org.apache.james:apache-mime4j-storage
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps org.apache.james:apache-mime4j-dom from 0.8.11 to 0.8.12.

---
updated-dependencies:
- dependency-name: org.apache.james:apache-mime4j-dom
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps org.apache.james:apache-mime4j-core from 0.8.11 to 0.8.12.

---
updated-dependencies:
- dependency-name: org.apache.james:apache-mime4j-core
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [org.bspfsystems:yamlconfiguration](https://github.com/bspfsystems/YamlConfiguration) from 3.0.1 to 3.0.2.
- [Release notes](https://github.com/bspfsystems/YamlConfiguration/releases)
- [Commits](bspfsystems/YamlConfiguration@v3.0.1...v3.0.2)

---
updated-dependencies:
- dependency-name: org.bspfsystems:yamlconfiguration
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
…s-apache-mime4j-storage-0.8.12

Bump org.apache.james:apache-mime4j-storage from 0.8.11 to 0.8.12
…-yamlconfiguration-3.0.2

Bump org.bspfsystems:yamlconfiguration from 3.0.1 to 3.0.2
…s-apache-mime4j-core-0.8.12

Bump org.apache.james:apache-mime4j-core from 0.8.11 to 0.8.12
…s-apache-mime4j-dom-0.8.12

Bump org.apache.james:apache-mime4j-dom from 0.8.11 to 0.8.12
@Ghost-chu Ghost-chu requested review from a team as code owners January 13, 2025 14:38
Copy link
Contributor

coderabbitai bot commented Jan 13, 2025

"""

变更概述

工作流程

这个拉取请求主要包含对 GitHub Actions 工作流程文件、项目依赖、数据库处理和前端组件的多个更新。主要变更包括更新 Docker 构建操作版本、项目版本和依赖版本,以及对数据库实体和 JSON 序列化处理的修改。

变更

文件路径 变更摘要
.github/workflows/jvm-ci.yml 更新 Docker 构建操作版本从 v6.10.0v6.11.0
.github/workflows/jvm-release.yml 更新 Docker 构建操作版本从 v6.10.0v6.11.0
.gitignore 添加 install4j/project.install4j~ 忽略项
pom.xml 项目版本升级至 7.3.2,更新多个依赖版本
src/main/java/com/ghostchu/peerbanhelper/database/DatabaseHelper.java 添加数据库版本 7 的升级逻辑
src/main/java/com/ghostchu/peerbanhelper/database/table/AlertEntity.java 修改数据库字段注解,使用自定义持久化类
src/main/java/com/ghostchu/peerbanhelper/downloader/impl/qbittorrent/AbstractQbittorrent.java 移除登录状态检查失败时的错误日志记录
src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHPeerController.java 修改 IP 地址处理逻辑,使用 toNormalizedString()
src/main/java/com/ghostchu/peerbanhelper/util/json/JsonUtil.java 注册 TranslationComponent 的类型适配器
src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java 更新序列化和反序列化方法,扩展适配器功能
webui/src/stores/endpoint.ts 添加对 401 状态码的错误处理
webui/src/views/banlist/components/banListItem.vue 修改工具提示位置属性

可能相关的拉取请求

  • v7.3.0 #880: 此 PR 也涉及更新 .github/workflows/jvm-ci.yml 文件中的 docker/build-push-action 版本,类似于主拉取请求。
  • v7.3.1 #895: 此 PR 包含对 webui/src/views/banlist/components/banListItem.vue 文件的修改,也涉及工具提示组件的更改,尽管与主 PR 中的操作版本更新无关。
  • 修复 hash 气泡被覆盖的问题 #898: 此 PR 修改了 webui/src/views/banlist/components/banListItem.vue 文件,通过添加位置属性来直接更改相同的组件,但与主 PR 的变更无关。

建议的审阅者

  • Gaojianli
  • paulzzh

备注

这次变更涉及多个系统层面的小更新,包括工作流程、依赖管理、数据库处理和前端错误处理。主要目的似乎是升级依赖版本、改进错误处理和优化数据持久化机制。
"""

Finishing Touches

  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java (1)

34-34: 建议将注释翻译为英文

为了保持代码的一致性和国际化,建议将注释翻译为英文。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d1e411f and c457fad.

📒 Files selected for processing (12)
  • .github/workflows/jvm-ci.yml (2 hunks)
  • .github/workflows/jvm-release.yml (2 hunks)
  • .gitignore (1 hunks)
  • pom.xml (5 hunks)
  • src/main/java/com/ghostchu/peerbanhelper/database/DatabaseHelper.java (1 hunks)
  • src/main/java/com/ghostchu/peerbanhelper/database/table/AlertEntity.java (2 hunks)
  • src/main/java/com/ghostchu/peerbanhelper/downloader/impl/qbittorrent/AbstractQbittorrent.java (0 hunks)
  • src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHPeerController.java (2 hunks)
  • src/main/java/com/ghostchu/peerbanhelper/util/json/JsonUtil.java (2 hunks)
  • src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java (1 hunks)
  • webui/src/stores/endpoint.ts (1 hunks)
  • webui/src/views/banlist/components/banListItem.vue (1 hunks)
💤 Files with no reviewable changes (1)
  • src/main/java/com/ghostchu/peerbanhelper/downloader/impl/qbittorrent/AbstractQbittorrent.java
✅ Files skipped from review due to trivial changes (3)
  • .gitignore
  • .github/workflows/jvm-ci.yml
  • .github/workflows/jvm-release.yml
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Build_SPK / pkgcreate
  • GitHub Check: Build_Installers / install4jc
  • GitHub Check: Build_Docker
🔇 Additional comments (9)
pom.xml (3)

9-9: 版本号更新符合预期!

版本号从 7.3.1 升级到 7.3.2 的更新符合语义化版本规范,与此 PR 修复错误的目标相符。


261-261: 建议验证 yamlconfiguration 依赖更新的兼容性

yamlconfiguration 依赖从 3.0.1 升级到 3.0.2,这是一个次要版本更新。

请运行以下脚本验证新版本的变更内容和兼容性:


401-401: Apache MIME4J 组件更新合理

apache-mime4j-dom、apache-mime4j-core 和 apache-mime4j-storage 从 0.8.11 升级到 0.8.12 是补丁版本更新,风险较低。

运行以下脚本检查更新内容:

Also applies to: 412-412, 423-423

src/main/java/com/ghostchu/peerbanhelper/util/json/JsonUtil.java (1)

3-3: 成功注册 TranslationComponent 的 TypeAdapter

此更改正确地在 GsonBuilder 中注册了 TranslationComponentTypeAdapter,有助于序列化和反序列化操作。

Also applies to: 17-17

src/main/java/com/ghostchu/peerbanhelper/database/DatabaseHelper.java (1)

78-82: 数据库升级逻辑看起来没有问题

这个升级逻辑遵循了已建立的模式,通过删除和重建 AlertEntity 表来确保数据结构的一致性。

建议运行以下脚本来验证是否有其他地方引用了 AlertEntity 表的旧结构:

✅ Verification successful

数据库升级操作验证完成,确认安全

经过详细检查,AlertEntity 表的删除和重建操作是安全的:

  • 所有相关代码都使用标准字段访问
  • 没有发现复杂的表关系或外键依赖
  • DAO 层的操作都是基础的 CRUD,不涉及特殊查询
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 搜索可能引用 AlertEntity 表结构的代码
rg -l "AlertEntity" | grep -v "DatabaseHelper.java"

Length of output: 344


Script:

#!/bin/bash
# Check AlertEntity class structure and its usage
echo "=== AlertEntity.java ==="
cat src/main/java/com/ghostchu/peerbanhelper/database/table/AlertEntity.java

echo -e "\n=== AlertDao.java ==="
cat src/main/java/com/ghostchu/peerbanhelper/database/dao/impl/AlertDao.java

echo -e "\n=== Usage in AlertManager ==="
rg -A 5 "AlertEntity" src/main/java/com/ghostchu/peerbanhelper/alert/AlertManager.java

echo -e "\n=== Usage in Controller ==="
rg -A 5 "AlertEntity" src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHAlertController.java

Length of output: 5996

webui/src/stores/endpoint.ts (1)

213-214: 登录错误处理得到了改进

添加了对 HTTP 401 状态码的处理,使未授权访问的错误处理更加完整和一致。

webui/src/views/banlist/components/banListItem.vue (1)

139-139: UI 改进:优化了工具提示的位置

通过添加 position="bottom" 属性,使工具提示的显示位置更加合理和一致。

src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHPeerController.java (2)

156-156: 改进了 IP 地址的标准化处理

使用 toNormalizedString() 来确保 IP 地址格式的一致性,这对于 IPv6 地址的处理尤其重要。


171-171: 保持了一致的 IP 地址标准化处理

在 handleAccessHistory 方法中同样使用了 toNormalizedString(),保持了代码的一致性。

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java (1)

17-35: 建议增加空值检查和异常处理

当前实现逻辑清晰,但建议做以下改进:

  1. 在方法开始时增加对 value 的空值检查
  2. param.toString() 之前增加对 param 的空值检查
  3. 考虑捕获并处理可能的异常,确保序列化过程更加稳健

建议的代码修改:

 public void write(JsonWriter out, TranslationComponent value) throws IOException {
+    if (value == null) {
+        out.nullValue();
+        return;
+    }
     out.beginObject();
     out.name("key").value(value.getKey());
     out.name("params");
     out.beginArray();
     for (Object param : value.getParams()) {
+        if (param == null) {
+            out.nullValue();
+            continue;
+        }
         if (param instanceof TranslationComponent) {
             TranslationComponentTypeAdapter.INSTANCE.write(out, (TranslationComponent) param);
         } else {
             out.value(param.toString());
         }
     }
     out.endArray();
     out.endObject();
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c457fad and 4d9347f.

📒 Files selected for processing (1)
  • src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java (1 hunks)
🔇 Additional comments (1)
src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java (1)

4-13: 类型适配器的改进实现!

JsonSerializer 改为 TypeAdapter 是一个很好的改进,现在可以同时处理序列化和反序列化操作。导入的类也都是必要且合适的。

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/main/java/com/ghostchu/peerbanhelper/database/dao/impl/HistoryDao.java (2)

52-54: 建议提取分页参数为常量

当前实现正确且清晰,建议将分页相关的计算提取为可重用的工具方法,以提高代码的可维护性。

+    private static final String ORDER_BY_COUNT_DESC = "count DESC";
+    
     public Page<PeerBanCount> getBannedIps(Pageable pageable, String filter) throws Exception {
         var builder = queryBuilder()
                 .selectRaw("ip, COUNT(*) AS count")
                 .groupBy("ip")
-                .orderByRaw("count DESC");
+                .orderByRaw(ORDER_BY_COUNT_DESC);

55-56: 建议增加结果集的空值处理

当前的实现在处理查询结果时可能需要增加额外的防御性编程。建议添加对空值的处理,以提高代码的健壮性。

     List<PeerBanCount> mapped;
     try (GenericRawResults<String[]> banLogs = queryRaw(queryBuilder.prepareStatementString(), args)) {
         var results = banLogs.getResults();
-        mapped = results.stream().map(arr -> new PeerBanCount(arr[0], Long.parseLong(arr[1]))).toList();
+        mapped = results.stream()
+            .filter(arr -> arr != null && arr.length >= 2 && arr[0] != null)
+            .map(arr -> new PeerBanCount(arr[0], Long.parseLong(arr[1])))
+            .toList();
     }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d9347f and 2512963.

📒 Files selected for processing (2)
  • src/main/java/com/ghostchu/peerbanhelper/PeerBanHelperServer.java (1 hunks)
  • src/main/java/com/ghostchu/peerbanhelper/database/dao/impl/HistoryDao.java (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/main/java/com/ghostchu/peerbanhelper/PeerBanHelperServer.java
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Build_PKG / pkg (14.1)
  • GitHub Check: Build_Installers / install4jc
  • GitHub Check: Build_PKG / pkg (13.4)
  • GitHub Check: Build_SPK / pkgcreate
  • GitHub Check: Build_DEB / dpkg
  • GitHub Check: Build_Docker
  • GitHub Check: Analyze (java-kotlin)
  • GitHub Check: Build_Docker_Standalone
🔇 Additional comments (2)
src/main/java/com/ghostchu/peerbanhelper/database/dao/impl/HistoryDao.java (2)

47-50: 改进了参数化查询的处理!

通过将过滤条件作为参数传递而不是直接拼接到SQL中,提高了代码的安全性,同时也解决了IPv6地址中特殊字符的处理问题。


47-56: 整体实现符合预期且安全性得到提升

代码变更很好地解决了IPv6地址搜索的问题,同时通过使用参数化查询提高了安全性。建议考虑添加单元测试以验证IPv6地址的各种场景。

建议执行以下测试脚本来验证IPv6相关的改动:

Copy link
Collaborator

@paulzzh paulzzh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

记得修改install4j的版本号

@Ghost-chu Ghost-chu merged commit acda442 into release Jan 13, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants