From 0e1af18f285db08f692ef88c8ce851a7bf29986e Mon Sep 17 00:00:00 2001 From: Ghost_chu Date: Mon, 6 Jan 2025 22:37:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../githubupdate/GithubUpdateService.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/ghostchu/btn/sparkle/module/githubupdate/GithubUpdateService.java b/src/main/java/com/ghostchu/btn/sparkle/module/githubupdate/GithubUpdateService.java index 5c162c6..c12edce 100644 --- a/src/main/java/com/ghostchu/btn/sparkle/module/githubupdate/GithubUpdateService.java +++ b/src/main/java/com/ghostchu/btn/sparkle/module/githubupdate/GithubUpdateService.java @@ -1,7 +1,6 @@ package com.ghostchu.btn.sparkle.module.githubupdate; import com.ghostchu.btn.sparkle.module.analyse.AnalyseService; -import com.ghostchu.btn.sparkle.module.analyse.impl.AnalysedRule; import com.ghostchu.btn.sparkle.module.banhistory.BanHistoryService; import com.ghostchu.btn.sparkle.module.banhistory.internal.BanHistoryRepository; import com.ghostchu.btn.sparkle.util.IPUtil; @@ -65,13 +64,19 @@ public void githubRuleUpdate() throws IOException, InterruptedException { private String generateTrackerHighRiskIps() { var strJoiner = new StringJoiner("\n"); - analyseService.getTrackerHighRisk().forEach(r -> strJoiner.add(r.getIp())); + analyseService.getTrackerHighRisk().forEach(r -> { + strJoiner.add("# " + r.getComment()); + strJoiner.add(r.getIp()); + }); return strJoiner.toString(); } private String generateUntrustedIps() { var strJoiner = new StringJoiner("\n"); - analyseService.getUntrustedIPAddresses().forEach(r -> strJoiner.add(r.getIp())); + analyseService.getUntrustedIPAddresses().forEach(r -> { + strJoiner.add("# " + r.getComment()); + strJoiner.add(r.getIp()); + }); return strJoiner.toString(); } @@ -91,7 +96,10 @@ private String generateUntrustedIps() { private String generateHighRiskIps() { var strJoiner = new StringJoiner("\n"); - analyseService.getHighRiskIps().forEach(r -> strJoiner.add(r.getIp())); + analyseService.getHighRiskIps().forEach(r -> { + strJoiner.add("# " + r.getComment()); + strJoiner.add(r.getIp()); + }); return strJoiner.toString(); } @@ -207,7 +215,12 @@ private void updateFile(GHRepository repository, String file, Supplier c private String generateOverDownloadIps() { - return String.join("\n", analyseService.getOverDownloadIPAddresses().stream().map(AnalysedRule::getIp).toList()); + var strJoiner = new StringJoiner("\n"); + analyseService.getOverDownloadIPAddresses().forEach(r -> { + strJoiner.add("# " + r.getComment()); + strJoiner.add(r.getIp()); + }); + return strJoiner.toString(); } private OffsetDateTime nowTimestamp() {