Refactor / fix boolean showfooter config

Add full scrape config, default false
This commit is contained in:
zzz
2022-01-15 11:38:07 -05:00
parent 8fd17dd938
commit 9ed1a1ce0c
5 changed files with 29 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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 <a href=\"http://git.idk.i2p/i2p-hackers/i2p.plugins.zzzot\" target=\"_blank\">ZZZOT</a> " + 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;

View File

@ -29,8 +29,8 @@
}
%>
<%
String showfooter = ZzzOTController.shouldShowFooter();
if (showfooter == "true") {
boolean showfooter = ZzzOTController.shouldShowFooter();
if (showfooter) {
%>
<span id="footer" class="version"><%=ZzzOTController.footerText()%></span>
<%

View File

@ -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";