From 0861089907e6de69fb13012d8837af2e9a8a4896 Mon Sep 17 00:00:00 2001 From: Ghost_chu Date: Sat, 17 Aug 2024 21:00:17 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=BB=E6=AD=A2=E6=A8=A1=E5=9D=97=E8=A2=AB?= =?UTF-8?q?=20SpringContext=20=E6=89=AB=E6=8F=8F=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=EF=BC=8C=E6=88=91=E4=BB=AC=E6=89=8B=E5=8A=A8=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E4=BB=96=E4=BB=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ghostchu/peerbanhelper/AppConfig.java | 3 +- .../config/MainConfigUpdateScript.java | 5 ++ .../impl/ProgressCheatBlockerPersistDao.java | 58 +++++++++---------- .../impl/rule/ActiveMonitoringModule.java | 6 +- .../module/impl/rule/AutoRangeBan.java | 2 + .../module/impl/rule/BtnNetworkOnline.java | 2 + .../module/impl/rule/ClientNameBlacklist.java | 2 + .../module/impl/rule/ExpressionRule.java | 5 +- .../module/impl/rule/IPBlackList.java | 2 + .../module/impl/rule/IPBlackRuleList.java | 2 + .../module/impl/rule/MultiDialingBlocker.java | 2 + .../module/impl/rule/PeerIdBlacklist.java | 2 + .../impl/rule/ProgressCheatBlocker.java | 2 + .../impl/webapi/BlockListController.java | 2 + .../impl/webapi/PBHAlertController.java | 2 + .../webapi/PBHAuthenticateController.java | 2 + .../module/impl/webapi/PBHBanController.java | 2 + .../impl/webapi/PBHChartController.java | 2 + .../impl/webapi/PBHDownloaderController.java | 2 + .../impl/webapi/PBHGeneralController.java | 2 + .../module/impl/webapi/PBHLogsController.java | 2 + .../impl/webapi/PBHMetadataController.java | 2 + .../impl/webapi/PBHMetricsController.java | 2 + .../module/impl/webapi/PBHOOBEController.java | 2 + .../module/impl/webapi/PBHPeerController.java | 2 + .../module/impl/webapi/PBHPlusController.java | 12 ++-- .../impl/webapi/PBHTorrentController.java | 2 + .../module/impl/webapi/RuleSubController.java | 2 + .../pbhplus/ActivationManager.java | 2 +- .../util/context/IgnoreScan.java | 4 ++ 30 files changed, 98 insertions(+), 41 deletions(-) create mode 100644 src/main/java/com/ghostchu/peerbanhelper/util/context/IgnoreScan.java diff --git a/src/main/java/com/ghostchu/peerbanhelper/AppConfig.java b/src/main/java/com/ghostchu/peerbanhelper/AppConfig.java index ff7f4b471..97780f2fa 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/AppConfig.java +++ b/src/main/java/com/ghostchu/peerbanhelper/AppConfig.java @@ -1,5 +1,6 @@ package com.ghostchu.peerbanhelper; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.simplereloadlib.ReloadManager; import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Bean; @@ -9,7 +10,7 @@ import java.io.File; @Configuration -@ComponentScan("com.ghostchu.peerbanhelper") +@ComponentScan(value = "com.ghostchu.peerbanhelper", excludeFilters = @ComponentScan.Filter(IgnoreScan.class)) @Slf4j public class AppConfig { @Bean diff --git a/src/main/java/com/ghostchu/peerbanhelper/config/MainConfigUpdateScript.java b/src/main/java/com/ghostchu/peerbanhelper/config/MainConfigUpdateScript.java index d0083935c..dfa9a6497 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/config/MainConfigUpdateScript.java +++ b/src/main/java/com/ghostchu/peerbanhelper/config/MainConfigUpdateScript.java @@ -25,6 +25,11 @@ private void validate() { // } } + @UpdateScript(version = 17) + public void windowsEcoQoSApi() { + conf.set("performance.windows-ecoqos-api", true); + } + @UpdateScript(version = 16) public void fixNonProxyHosts() { if (!conf.isSet("proxy.non-proxy-hosts")) { diff --git a/src/main/java/com/ghostchu/peerbanhelper/database/dao/impl/ProgressCheatBlockerPersistDao.java b/src/main/java/com/ghostchu/peerbanhelper/database/dao/impl/ProgressCheatBlockerPersistDao.java index c96044f32..c3c2c6df7 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/database/dao/impl/ProgressCheatBlockerPersistDao.java +++ b/src/main/java/com/ghostchu/peerbanhelper/database/dao/impl/ProgressCheatBlockerPersistDao.java @@ -50,36 +50,36 @@ public List fetchFromDatabase(ProgressCheatBloc public void flushDatabase(List records) throws SQLException { callBatchTasks(() -> { records.forEach(record -> { - String torrentId = record.client().getTorrentId(); - record.task().forEach(task -> { - try { - var entity = findExists(task.getPeerIp(), torrentId); - if (entity == null) { - entity = new ProgressCheatBlockerPersistEntity(null, - task.getPeerIp(), - torrentId, - task.getLastReportProgress(), - task.getLastReportUploaded(), - task.getTrackingUploadedIncreaseTotal(), - task.getRewindCounter(), - task.getProgressDifferenceCounter(), - new Timestamp(System.currentTimeMillis()), - new Timestamp(System.currentTimeMillis()) - ); - create(entity); - } else { - entity.setLastReportProgress(task.getLastReportProgress()); - entity.setLastReportUploaded(task.getLastReportUploaded()); - entity.setProgressDifferenceCounter(task.getProgressDifferenceCounter()); - entity.setRewindCounter(task.getRewindCounter()); - entity.setTrackingUploadedIncreaseTotal(task.getTrackingUploadedIncreaseTotal()); - entity.setLastTimeSeen(new Timestamp(System.currentTimeMillis())); - update(entity); - } - } catch (SQLException e) { - log.error("Unable write PCB persist data into database", e); + String torrentId = record.client().getTorrentId(); + record.task().forEach(task -> { + try { + var entity = findExists(task.getPeerIp(), torrentId); + if (entity == null) { + entity = new ProgressCheatBlockerPersistEntity(null, + task.getPeerIp(), + torrentId, + task.getLastReportProgress(), + task.getLastReportUploaded(), + task.getTrackingUploadedIncreaseTotal(), + task.getRewindCounter(), + task.getProgressDifferenceCounter(), + new Timestamp(System.currentTimeMillis()), + new Timestamp(System.currentTimeMillis()) + ); + create(entity); + } else { + entity.setLastReportProgress(task.getLastReportProgress()); + entity.setLastReportUploaded(task.getLastReportUploaded()); + entity.setProgressDifferenceCounter(task.getProgressDifferenceCounter()); + entity.setRewindCounter(task.getRewindCounter()); + entity.setTrackingUploadedIncreaseTotal(task.getTrackingUploadedIncreaseTotal()); + entity.setLastTimeSeen(new Timestamp(System.currentTimeMillis())); + update(entity); } - }); + } catch (SQLException e) { + log.error("Unable write PCB persist data into database", e); + } + }); }); return null; }); diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ActiveMonitoringModule.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ActiveMonitoringModule.java index 30e3fa56c..0e5277999 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ActiveMonitoringModule.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ActiveMonitoringModule.java @@ -8,6 +8,7 @@ import com.ghostchu.peerbanhelper.module.AbstractFeatureModule; import com.ghostchu.peerbanhelper.text.Lang; import com.ghostchu.peerbanhelper.util.MiscUtil; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.simplereloadlib.ReloadResult; import com.ghostchu.simplereloadlib.Reloadable; import com.google.common.cache.Cache; @@ -28,6 +29,7 @@ @Slf4j @Component +@IgnoreScan public class ActiveMonitoringModule extends AbstractFeatureModule implements Reloadable { private final PeerRecordDao peerRecordDao; private final Deque dataBuffer = new ConcurrentLinkedDeque<>(); @@ -127,10 +129,10 @@ private void writeJournal() { long uploaded = 0; long downloaded = 0; if (data != null) { - if(data[0]!=null && !data[0].isBlank()){ + if (data[0] != null && !data[0].isBlank()) { uploaded = Long.parseLong(data[0]); } - if(data[1]!=null && !data[1].isBlank()){ + if (data[1] != null && !data[1].isBlank()) { downloaded = Long.parseLong(data[1]); } } diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/AutoRangeBan.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/AutoRangeBan.java index dd281e06f..3da0d4a9f 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/AutoRangeBan.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/AutoRangeBan.java @@ -9,6 +9,7 @@ import com.ghostchu.peerbanhelper.text.Lang; import com.ghostchu.peerbanhelper.text.TranslationComponent; import com.ghostchu.peerbanhelper.torrent.Torrent; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.web.JavalinWebContainer; import com.ghostchu.peerbanhelper.web.Role; import com.ghostchu.peerbanhelper.web.wrapper.StdResp; @@ -28,6 +29,7 @@ @Slf4j @Component +@IgnoreScan public class AutoRangeBan extends AbstractRuleFeatureModule implements Reloadable { @Autowired private PeerBanHelperServer peerBanHelperServer; diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/BtnNetworkOnline.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/BtnNetworkOnline.java index 06d2ab02d..14971f5ec 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/BtnNetworkOnline.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/BtnNetworkOnline.java @@ -12,6 +12,7 @@ import com.ghostchu.peerbanhelper.text.TranslationComponent; import com.ghostchu.peerbanhelper.torrent.Torrent; import com.ghostchu.peerbanhelper.util.NullUtil; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.util.rule.Rule; import com.ghostchu.peerbanhelper.util.rule.RuleMatchResult; import com.ghostchu.peerbanhelper.util.rule.RuleParser; @@ -29,6 +30,7 @@ @Slf4j @Component +@IgnoreScan public class BtnNetworkOnline extends AbstractRuleFeatureModule implements Reloadable { private final CheckResult BTN_MANAGER_NOT_INITIALIZED = new CheckResult(getClass(), PeerAction.NO_ACTION, 0, new TranslationComponent(Lang.GENERAL_NA), new TranslationComponent("BtnManager not initialized")); @Autowired(required = false) diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ClientNameBlacklist.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ClientNameBlacklist.java index 13404883a..155bf3869 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ClientNameBlacklist.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ClientNameBlacklist.java @@ -8,6 +8,7 @@ import com.ghostchu.peerbanhelper.text.Lang; import com.ghostchu.peerbanhelper.text.TranslationComponent; import com.ghostchu.peerbanhelper.torrent.Torrent; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.util.rule.Rule; import com.ghostchu.peerbanhelper.util.rule.RuleMatchResult; import com.ghostchu.peerbanhelper.util.rule.RuleParser; @@ -28,6 +29,7 @@ @Getter @Component +@IgnoreScan public class ClientNameBlacklist extends AbstractRuleFeatureModule implements Reloadable { private List bannedPeers; @Autowired diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ExpressionRule.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ExpressionRule.java index 7081c3c0b..89b16e731 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ExpressionRule.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ExpressionRule.java @@ -6,17 +6,15 @@ import com.ghostchu.peerbanhelper.module.CheckResult; import com.ghostchu.peerbanhelper.module.PeerAction; import com.ghostchu.peerbanhelper.peer.Peer; -import com.ghostchu.peerbanhelper.peer.PeerImpl; import com.ghostchu.peerbanhelper.text.Lang; import com.ghostchu.peerbanhelper.text.TranslationComponent; import com.ghostchu.peerbanhelper.torrent.Torrent; -import com.ghostchu.peerbanhelper.torrent.TorrentImpl; import com.ghostchu.peerbanhelper.util.HTTPUtil; import com.ghostchu.peerbanhelper.util.IPAddressUtil; import com.ghostchu.peerbanhelper.util.StrUtil; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.util.json.JsonUtil; import com.ghostchu.peerbanhelper.util.time.InfoHashUtil; -import com.ghostchu.peerbanhelper.wrapper.PeerAddress; import com.ghostchu.simplereloadlib.ReloadResult; import com.ghostchu.simplereloadlib.Reloadable; import com.googlecode.aviator.AviatorEvaluator; @@ -54,6 +52,7 @@ @Slf4j @Component +@IgnoreScan public class ExpressionRule extends AbstractRuleFeatureModule implements Reloadable { private final long maxScriptExecuteTime = 1500; private final Map threadLocks = new HashMap<>(); diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/IPBlackList.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/IPBlackList.java index f8345a85f..8ba5d40ae 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/IPBlackList.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/IPBlackList.java @@ -9,6 +9,7 @@ import com.ghostchu.peerbanhelper.text.TranslationComponent; import com.ghostchu.peerbanhelper.torrent.Torrent; import com.ghostchu.peerbanhelper.util.IPAddressUtil; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.web.JavalinWebContainer; import com.ghostchu.peerbanhelper.web.Role; import com.ghostchu.peerbanhelper.web.wrapper.StdResp; @@ -33,6 +34,7 @@ @Slf4j @Component +@IgnoreScan public class IPBlackList extends AbstractRuleFeatureModule implements Reloadable { private Set ips; private Set ports; diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/IPBlackRuleList.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/IPBlackRuleList.java index eaf936060..d79adb5b9 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/IPBlackRuleList.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/IPBlackRuleList.java @@ -14,6 +14,7 @@ import com.ghostchu.peerbanhelper.torrent.Torrent; import com.ghostchu.peerbanhelper.util.HTTPUtil; import com.ghostchu.peerbanhelper.util.IPAddressUtil; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.util.paging.Page; import com.ghostchu.peerbanhelper.util.paging.Pageable; import com.ghostchu.peerbanhelper.util.rule.MatchResult; @@ -58,6 +59,7 @@ @Slf4j @Component @Getter +@IgnoreScan public class IPBlackRuleList extends AbstractRuleFeatureModule implements Reloadable { private final RuleSubLogsDao ruleSubLogsDao; private List ipBanMatchers; diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/MultiDialingBlocker.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/MultiDialingBlocker.java index 019fb4d44..a4ecf59ff 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/MultiDialingBlocker.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/MultiDialingBlocker.java @@ -9,6 +9,7 @@ import com.ghostchu.peerbanhelper.text.TranslationComponent; import com.ghostchu.peerbanhelper.torrent.Torrent; import com.ghostchu.peerbanhelper.util.IPAddressUtil; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.web.JavalinWebContainer; import com.ghostchu.peerbanhelper.web.Role; import com.ghostchu.peerbanhelper.web.wrapper.StdResp; @@ -34,6 +35,7 @@ */ @Slf4j @Component +@IgnoreScan public class MultiDialingBlocker extends AbstractRuleFeatureModule implements Reloadable { // 计算缓存容量 private static final int TORRENT_PEER_MAX_NUM = 1024; diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/PeerIdBlacklist.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/PeerIdBlacklist.java index 5b2c911c4..139b79312 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/PeerIdBlacklist.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/PeerIdBlacklist.java @@ -8,6 +8,7 @@ import com.ghostchu.peerbanhelper.text.Lang; import com.ghostchu.peerbanhelper.text.TranslationComponent; import com.ghostchu.peerbanhelper.torrent.Torrent; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.util.rule.Rule; import com.ghostchu.peerbanhelper.util.rule.RuleMatchResult; import com.ghostchu.peerbanhelper.util.rule.RuleParser; @@ -26,6 +27,7 @@ import java.util.concurrent.ExecutorService; @Component +@IgnoreScan public class PeerIdBlacklist extends AbstractRuleFeatureModule implements Reloadable { private List bannedPeers; @Autowired 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 b99eac680..4b973cef7 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 @@ -11,6 +11,7 @@ import com.ghostchu.peerbanhelper.torrent.Torrent; import com.ghostchu.peerbanhelper.util.IPAddressUtil; import com.ghostchu.peerbanhelper.util.MsgUtil; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.web.JavalinWebContainer; import com.ghostchu.peerbanhelper.web.Role; import com.ghostchu.peerbanhelper.web.wrapper.StdResp; @@ -37,6 +38,7 @@ @Component @Slf4j +@IgnoreScan public class ProgressCheatBlocker extends AbstractRuleFeatureModule implements Reloadable { private final Deque pendingPersistQueue = new ConcurrentLinkedDeque<>(); private final Cache> progressRecorder = CacheBuilder.newBuilder() diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/BlockListController.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/BlockListController.java index d9331e6d9..7b9fdd3ed 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/BlockListController.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/BlockListController.java @@ -2,6 +2,7 @@ import com.ghostchu.peerbanhelper.module.AbstractFeatureModule; import com.ghostchu.peerbanhelper.util.IPAddressUtil; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.web.JavalinWebContainer; import com.ghostchu.peerbanhelper.web.Role; import com.ghostchu.peerbanhelper.wrapper.BanMetadata; @@ -18,6 +19,7 @@ import java.util.UUID; @Component +@IgnoreScan public class BlockListController extends AbstractFeatureModule { @Autowired private JavalinWebContainer webContainer; diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHAlertController.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHAlertController.java index dcce6440c..0a4cd36f3 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHAlertController.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHAlertController.java @@ -2,6 +2,7 @@ import com.ghostchu.peerbanhelper.alert.AlertManager; import com.ghostchu.peerbanhelper.module.AbstractFeatureModule; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.web.JavalinWebContainer; import com.ghostchu.peerbanhelper.web.Role; import com.ghostchu.peerbanhelper.web.wrapper.StdResp; @@ -11,6 +12,7 @@ import org.springframework.stereotype.Component; @Component +@IgnoreScan public class PBHAlertController extends AbstractFeatureModule { @Autowired private AlertManager alertManager; diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHAuthenticateController.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHAuthenticateController.java index 3c1d1ada6..877df877d 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHAuthenticateController.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHAuthenticateController.java @@ -2,6 +2,7 @@ import com.ghostchu.peerbanhelper.module.AbstractFeatureModule; import com.ghostchu.peerbanhelper.text.Lang; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.web.JavalinWebContainer; import com.ghostchu.peerbanhelper.web.Role; import com.ghostchu.peerbanhelper.web.exception.NeedInitException; @@ -20,6 +21,7 @@ @Component @Slf4j +@IgnoreScan public class PBHAuthenticateController extends AbstractFeatureModule { @Autowired private JavalinWebContainer webContainer; diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHBanController.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHBanController.java index f78a0262b..0fdda5014 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHBanController.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHBanController.java @@ -5,6 +5,7 @@ import com.ghostchu.peerbanhelper.database.table.HistoryEntity; import com.ghostchu.peerbanhelper.metric.BasicMetrics; import com.ghostchu.peerbanhelper.module.AbstractFeatureModule; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.util.paging.Page; import com.ghostchu.peerbanhelper.util.paging.Pageable; import com.ghostchu.peerbanhelper.web.JavalinWebContainer; @@ -31,6 +32,7 @@ @Slf4j @Component +@IgnoreScan public class PBHBanController extends AbstractFeatureModule { @Autowired private Database db; diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHChartController.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHChartController.java index 1361d53a2..dcfb02ff3 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHChartController.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHChartController.java @@ -11,6 +11,7 @@ import com.ghostchu.peerbanhelper.text.Lang; import com.ghostchu.peerbanhelper.util.MiscUtil; import com.ghostchu.peerbanhelper.util.WebUtil; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.web.JavalinWebContainer; import com.ghostchu.peerbanhelper.web.Role; import com.ghostchu.peerbanhelper.web.exception.RequirePBHPlusLicenseException; @@ -35,6 +36,7 @@ @Component @Slf4j +@IgnoreScan public class PBHChartController extends AbstractFeatureModule { @Autowired private JavalinWebContainer webContainer; diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHDownloaderController.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHDownloaderController.java index 41ef978ad..738a551a4 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHDownloaderController.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHDownloaderController.java @@ -8,6 +8,7 @@ import com.ghostchu.peerbanhelper.module.impl.webapi.dto.PopulatedPeerDTO; import com.ghostchu.peerbanhelper.text.Lang; import com.ghostchu.peerbanhelper.text.TranslationComponent; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.web.JavalinWebContainer; import com.ghostchu.peerbanhelper.web.Role; import com.ghostchu.peerbanhelper.web.wrapper.StdResp; @@ -31,6 +32,7 @@ @Slf4j @Component +@IgnoreScan public class PBHDownloaderController extends AbstractFeatureModule { @Autowired private JavalinWebContainer webContainer; diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHGeneralController.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHGeneralController.java index 8947bfe77..4c993f763 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHGeneralController.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHGeneralController.java @@ -2,6 +2,7 @@ import com.ghostchu.peerbanhelper.Main; import com.ghostchu.peerbanhelper.module.AbstractFeatureModule; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.web.JavalinWebContainer; import com.ghostchu.peerbanhelper.web.Role; import com.ghostchu.peerbanhelper.web.wrapper.StdResp; @@ -15,6 +16,7 @@ import java.util.List; @Component +@IgnoreScan public class PBHGeneralController extends AbstractFeatureModule { @Autowired private JavalinWebContainer webContainer; diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHLogsController.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHLogsController.java index b420a0593..8c3d309e6 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHLogsController.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHLogsController.java @@ -4,6 +4,7 @@ import com.ghostchu.peerbanhelper.event.LoggerEventRecordCreatedEvent; import com.ghostchu.peerbanhelper.log4j2.MemoryLoggerAppender; import com.ghostchu.peerbanhelper.module.AbstractFeatureModule; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.util.json.JsonUtil; import com.ghostchu.peerbanhelper.web.JavalinWebContainer; import com.ghostchu.peerbanhelper.web.Role; @@ -31,6 +32,7 @@ @Component @Slf4j +@IgnoreScan public class PBHLogsController extends AbstractFeatureModule { @Autowired private JavalinWebContainer webContainer; diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHMetadataController.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHMetadataController.java index e853569ea..372aea570 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHMetadataController.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHMetadataController.java @@ -4,6 +4,7 @@ import com.ghostchu.peerbanhelper.module.AbstractFeatureModule; import com.ghostchu.peerbanhelper.module.FeatureModule; import com.ghostchu.peerbanhelper.module.ModuleManager; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.web.JavalinWebContainer; import com.ghostchu.peerbanhelper.web.Role; import com.ghostchu.peerbanhelper.web.wrapper.StdResp; @@ -16,6 +17,7 @@ import java.util.Map; @Component +@IgnoreScan public class PBHMetadataController extends AbstractFeatureModule { @Autowired private JavalinWebContainer webContainer; diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHMetricsController.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHMetricsController.java index 651ca7e5b..7683ebade 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHMetricsController.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHMetricsController.java @@ -6,6 +6,7 @@ import com.ghostchu.peerbanhelper.metric.HitRateMetricRecorder; import com.ghostchu.peerbanhelper.module.AbstractFeatureModule; import com.ghostchu.peerbanhelper.text.TranslationComponent; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.util.rule.Rule; import com.ghostchu.peerbanhelper.web.JavalinWebContainer; import com.ghostchu.peerbanhelper.web.Role; @@ -28,6 +29,7 @@ import static com.ghostchu.peerbanhelper.text.TextManager.tl; @Component +@IgnoreScan public class PBHMetricsController extends AbstractFeatureModule { @Autowired @Qualifier("persistMetrics") diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHOOBEController.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHOOBEController.java index 785c20f0f..ac76dfeab 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHOOBEController.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHOOBEController.java @@ -4,6 +4,7 @@ import com.ghostchu.peerbanhelper.downloader.Downloader; import com.ghostchu.peerbanhelper.module.AbstractFeatureModule; import com.ghostchu.peerbanhelper.text.Lang; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.web.JavalinWebContainer; import com.ghostchu.peerbanhelper.web.Role; import com.ghostchu.peerbanhelper.web.wrapper.StdResp; @@ -26,6 +27,7 @@ */ @Component @Slf4j +@IgnoreScan public class PBHOOBEController extends AbstractFeatureModule { @Autowired private JavalinWebContainer webContainer; diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHPeerController.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHPeerController.java index 7d62348fa..07226e8b8 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHPeerController.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHPeerController.java @@ -7,6 +7,7 @@ import com.ghostchu.peerbanhelper.module.AbstractFeatureModule; import com.ghostchu.peerbanhelper.text.Lang; import com.ghostchu.peerbanhelper.util.IPAddressUtil; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.util.paging.Page; import com.ghostchu.peerbanhelper.util.paging.Pageable; import com.ghostchu.peerbanhelper.web.JavalinWebContainer; @@ -24,6 +25,7 @@ @Component @Slf4j +@IgnoreScan public class PBHPeerController extends AbstractFeatureModule { private final JavalinWebContainer javalinWebContainer; private final HistoryDao historyDao; diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHPlusController.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHPlusController.java index f670cd404..60ee4905a 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHPlusController.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHPlusController.java @@ -4,6 +4,7 @@ import com.ghostchu.peerbanhelper.module.AbstractFeatureModule; import com.ghostchu.peerbanhelper.pbhplus.ActivationManager; import com.ghostchu.peerbanhelper.text.Lang; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.util.encrypt.ActivationKeyUtil; import com.ghostchu.peerbanhelper.web.JavalinWebContainer; import com.ghostchu.peerbanhelper.web.Role; @@ -18,6 +19,7 @@ import static com.ghostchu.peerbanhelper.text.TextManager.tl; @Component +@IgnoreScan public class PBHPlusController extends AbstractFeatureModule { @Autowired private JavalinWebContainer webContainer; @@ -51,15 +53,15 @@ private void handleLicensePut(Context ctx) throws IOException { Main.getMainConfig().set("pbh-plus-key", licenseReq.key()); Main.getMainConfig().save(Main.getMainConfigFile()); activationManager.load(); - if(activationManager.isActivated()) { + if (activationManager.isActivated()) { ctx.json(new StdResp(true, tl(locale(ctx), Lang.PBH_PLUS_LICENSE_UPDATE), null)); - }else{ + } else { var keyData = activationManager.getKeyData(); - if(keyData == null) { + if (keyData == null) { ctx.json(new StdResp(false, tl(locale(ctx), Lang.PBH_PLUS_LICENSE_INVALID), null)); - }else if(System.currentTimeMillis() >= keyData.getExpireAt()){ + } else if (System.currentTimeMillis() >= keyData.getExpireAt()) { ctx.json(new StdResp(false, tl(locale(ctx), Lang.PBH_PLUS_LICENSE_EXPIRED), null)); - }else{ + } else { ctx.json(new StdResp(false, tl(locale(ctx), Lang.PBH_PLUS_LICENSE_INVALID), null)); } } diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHTorrentController.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHTorrentController.java index 53c362fe2..6dccf7c8c 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHTorrentController.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHTorrentController.java @@ -6,6 +6,7 @@ import com.ghostchu.peerbanhelper.database.table.PeerRecordEntity; import com.ghostchu.peerbanhelper.module.AbstractFeatureModule; import com.ghostchu.peerbanhelper.text.Lang; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.util.paging.Page; import com.ghostchu.peerbanhelper.util.paging.Pageable; import com.ghostchu.peerbanhelper.web.JavalinWebContainer; @@ -20,6 +21,7 @@ import static com.ghostchu.peerbanhelper.text.TextManager.tl; @Component +@IgnoreScan public class PBHTorrentController extends AbstractFeatureModule { private final JavalinWebContainer javalinWebContainer; private final TorrentDao torrentDao; diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/RuleSubController.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/RuleSubController.java index f3e2f8c89..1effb06a7 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/RuleSubController.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/RuleSubController.java @@ -6,6 +6,7 @@ import com.ghostchu.peerbanhelper.module.ModuleManager; import com.ghostchu.peerbanhelper.module.impl.rule.IPBlackRuleList; import com.ghostchu.peerbanhelper.text.Lang; +import com.ghostchu.peerbanhelper.util.context.IgnoreScan; import com.ghostchu.peerbanhelper.util.json.JsonUtil; import com.ghostchu.peerbanhelper.util.paging.Pageable; import com.ghostchu.peerbanhelper.web.JavalinWebContainer; @@ -30,6 +31,7 @@ @Slf4j @Component +@IgnoreScan public class RuleSubController extends AbstractFeatureModule { @Autowired private JavalinWebContainer webContainer; diff --git a/src/main/java/com/ghostchu/peerbanhelper/pbhplus/ActivationManager.java b/src/main/java/com/ghostchu/peerbanhelper/pbhplus/ActivationManager.java index cf9f48b03..74d99e0e3 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/pbhplus/ActivationManager.java +++ b/src/main/java/com/ghostchu/peerbanhelper/pbhplus/ActivationManager.java @@ -37,7 +37,7 @@ public void load() { return; } this.keyData = ActivationKeyUtil.fromKey(this.keyText); - if(keyData != null) { + if (keyData != null) { if (this.isActivated()) { log.info(tlUI(Lang.DONATION_KEY_VERIFICATION_SUCCESSFUL, keyData.getLicenseTo(), keyData.getSource(), MsgUtil.getDateFormatter().format(new Date(keyData.getExpireAt())))); } diff --git a/src/main/java/com/ghostchu/peerbanhelper/util/context/IgnoreScan.java b/src/main/java/com/ghostchu/peerbanhelper/util/context/IgnoreScan.java new file mode 100644 index 000000000..fe360af48 --- /dev/null +++ b/src/main/java/com/ghostchu/peerbanhelper/util/context/IgnoreScan.java @@ -0,0 +1,4 @@ +package com.ghostchu.peerbanhelper.util.context; + +public @interface IgnoreScan { +} \ No newline at end of file