diff --git a/pom.xml b/pom.xml index 56c74d2940..ab8abe32af 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.ghostchu.peerbanhelper peerbanhelper - 7.1.1 + 7.1.2 jar PeerBanHelper diff --git a/src/main/java/com/ghostchu/peerbanhelper/Main.java b/src/main/java/com/ghostchu/peerbanhelper/Main.java index 58788a6521..bba39f93ba 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/Main.java +++ b/src/main/java/com/ghostchu/peerbanhelper/Main.java @@ -151,14 +151,15 @@ public static void setupLogback() { appender.start(); // 启动 appender } - try{ + try { var targetLevel = System.getProperty("pbh.log.level"); - if(targetLevel != null) { + if (targetLevel != null) { var rootLogger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); ch.qos.logback.classic.Logger logbackLogger = (ch.qos.logback.classic.Logger) rootLogger; logbackLogger.setLevel(Level.toLevel(targetLevel)); } - }catch (Throwable ignored){} + } catch (Throwable ignored) { + } } public static ReloadResult reloadModule() { @@ -221,8 +222,14 @@ private static void setupConfDirectory(String[] args) { logsDirectory = new File(dataDirectory, "logs"); configDirectory = new File(dataDirectory, "config"); pluginDirectory = new File(dataDirectory, "plugins"); - libraryDirectory = new File(dataDirectory, "libraries"); debugDirectory = new File(dataDirectory, "debug"); + if (System.getProperty("pbh.configdir") != null) { + configDirectory = new File(System.getProperty("pbh.configdir")); + } + if (System.getProperty("pbh.logsdir") != null) { + logsDirectory = new File(System.getProperty("pbh.logsdir")); + } + // other directories aren't allowed to change by user to keep necessary structure } private static YamlConfiguration loadConfiguration(File file) { diff --git a/src/main/java/com/ghostchu/peerbanhelper/downloader/impl/qbittorrent/impl/QBittorrentTorrent.java b/src/main/java/com/ghostchu/peerbanhelper/downloader/impl/qbittorrent/impl/QBittorrentTorrent.java index 97f0a51661..aa889d7699 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/downloader/impl/qbittorrent/impl/QBittorrentTorrent.java +++ b/src/main/java/com/ghostchu/peerbanhelper/downloader/impl/qbittorrent/impl/QBittorrentTorrent.java @@ -187,7 +187,7 @@ public double getProgress() { @Override public long getSize() { - return size; + return totalSize; } @Override 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 0fdda5014f..3e7538fc6c 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 @@ -100,7 +100,8 @@ private void handleLogs(Context ctx) throws SQLException { private void handleBans(Context ctx) { long limit = Long.parseLong(Objects.requireNonNullElse(ctx.queryParam("limit"), "-1")); long lastBanTime = Long.parseLong(Objects.requireNonNullElse(ctx.queryParam("lastBanTime"), "-1")); - var banResponseList = getBanResponseStream(locale(ctx), lastBanTime, limit); + boolean ignoreBanForDisconnect = Boolean.parseBoolean(Objects.requireNonNullElse(ctx.queryParam("ignoreBanForDisconnect"), "true")); + var banResponseList = getBanResponseStream(locale(ctx), lastBanTime, limit, ignoreBanForDisconnect); ctx.json(new StdResp(true, null, banResponseList.toList())); } @@ -110,10 +111,14 @@ public void onDisable() { } - private @NotNull Stream getBanResponseStream(String locale, long lastBanTime, long limit) { + private @NotNull Stream getBanResponseStream(String locale, long lastBanTime, long limit, boolean ignoreBanForDisconnect) { var banResponseList = getServer().getBannedPeers() .entrySet() .stream() + .filter(b -> { + if(!ignoreBanForDisconnect) return true; + return !b.getValue().isBanForDisconnect(); + }) .map(entry -> new BanResponse(entry.getKey().getAddress().toString(), new BakedBanMetadata(locale, entry.getValue()))) .sorted((o1, o2) -> Long.compare(o2.getBanMetadata().getBanAt(), o1.getBanMetadata().getBanAt())); if (lastBanTime > 0) { diff --git a/webui/src/components/autoUpdateBtn.vue b/webui/src/components/autoUpdateBtn.vue index 30855948a1..e1a7421990 100644 --- a/webui/src/components/autoUpdateBtn.vue +++ b/webui/src/components/autoUpdateBtn.vue @@ -1,17 +1,19 @@