From 9ed1a1ce0c5df4119ff1dabbb6ab7d53c99d3626 Mon Sep 17 00:00:00 2001 From: zzz Date: Sat, 15 Jan 2022 11:38:07 -0500 Subject: [PATCH] Refactor / fix boolean showfooter config Add full scrape config, default false --- CHANGES.txt | 1 + scripts/zzzot.config | 9 +++++++++ src/java/net/i2p/zzzot/ZzzOTController.java | 15 ++++++++++++--- src/jsp/index.jsp | 4 ++-- src/jsp/scrape.jsp | 6 +++++- 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 88025f8..5344957 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,7 @@ 2022-xx-xx [0.19.0] - UDP announce support (proposal 160) (requires I2P 1.7.0/API 0.9.53 or higher) + - Disable full scrape by default 2020-08-30 [0.18.0] - Enable both encryption types diff --git a/scripts/zzzot.config b/scripts/zzzot.config index af8e7a4..526dc3c 100644 --- a/scripts/zzzot.config +++ b/scripts/zzzot.config @@ -1,3 +1,12 @@ +# +# All changes require plugin restart +# # announce interval in seconds # minimum 900 (15 minutes), maximum 21600 (6 hours) interval=1620 +# +showfoooter=true +#footerText=your html text here +# +# default false as of 0.0.19 +#allowFullScrape=false diff --git a/src/java/net/i2p/zzzot/ZzzOTController.java b/src/java/net/i2p/zzzot/ZzzOTController.java index 0dc1087..88898e7 100644 --- a/src/java/net/i2p/zzzot/ZzzOTController.java +++ b/src/java/net/i2p/zzzot/ZzzOTController.java @@ -67,8 +67,9 @@ public class ZzzOTController implements ClientApp { private static volatile ZzzOTController _controller; // you wouldn't run two instances in the same JVM, would you? private static String _sitename; - private static String _showfooter; + private static boolean _showfooter; private static String _footertext; + private static boolean _fullScrape; private ClientAppState _state = UNINITIALIZED; @@ -80,6 +81,8 @@ public class ZzzOTController implements ClientApp { private static final String PROP_SHOWFOOTER = "showfooter"; private static final String DEFAULT_FOOTERTEXT = "Running ZZZOT " + VERSION; private static final String PROP_FOOTERTEXT = "footertext"; + private static final String PROP_FULLSCRAPE = "allowFullScrape"; + private static final String DEFAULT_FULLSCRAPE = "false"; private static final String CONFIG_FILE = "zzzot.config"; private static final String BACKUP_SUFFIX = ".jetty8"; private static final String[] xmlFiles = { @@ -108,8 +111,9 @@ public class ZzzOTController implements ClientApp { } _zzzot = new ZzzOT(ctx, props); _sitename = props.getProperty(PROP_SITENAME, DEFAULT_SITENAME); - _showfooter = props.getProperty(PROP_SHOWFOOTER, DEFAULT_SHOWFOOTER); + _showfooter = Boolean.parseBoolean(props.getProperty(PROP_SHOWFOOTER, DEFAULT_SHOWFOOTER)); _footertext = props.getProperty(PROP_FOOTERTEXT, DEFAULT_FOOTERTEXT); + _fullScrape = Boolean.parseBoolean(props.getProperty(PROP_FULLSCRAPE, DEFAULT_FULLSCRAPE)); _state = INITIALIZED; } @@ -492,7 +496,7 @@ public class ZzzOTController implements ClientApp { } /** @since 0.17.0 */ - public static String shouldShowFooter() { + public static boolean shouldShowFooter() { return _showfooter; } @@ -501,6 +505,11 @@ public class ZzzOTController implements ClientApp { return _footertext; } + /** @since 0.19.0 */ + public static boolean allowFullScrape() { + return _fullScrape; + } + /** @since 0.12.0 */ private synchronized void changeState(ClientAppState state) { _state = state; diff --git a/src/jsp/index.jsp b/src/jsp/index.jsp index d7aa6a6..9be13f6 100644 --- a/src/jsp/index.jsp +++ b/src/jsp/index.jsp @@ -29,8 +29,8 @@ } %> <% - String showfooter = ZzzOTController.shouldShowFooter(); - if (showfooter == "true") { + boolean showfooter = ZzzOTController.shouldShowFooter(); + if (showfooter) { %> <%=ZzzOTController.footerText()%> <% diff --git a/src/jsp/scrape.jsp b/src/jsp/scrape.jsp index 14b89f8..b8022b0 100644 --- a/src/jsp/scrape.jsp +++ b/src/jsp/scrape.jsp @@ -50,8 +50,12 @@ } boolean all = info_hash == null; + if (all && !ZzzOTController.allowFullScrape()) { + fail = true; + msg = "unsupported"; + } - Torrents torrents = ZzzOTController.getTorrents(); + Torrents torrents = fail ? null : ZzzOTController.getTorrents(); if (torrents == null && !fail) { fail = true; msg = "tracker is down";