I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 2fafa333 authored by zzz's avatar zzz
Browse files

Console: Add floodfill configuration form to /configadvanced

parent b5f75a4b
No related branches found
No related tags found
No related merge requests found
......@@ -17,14 +17,18 @@ public class ConfigAdvancedHandler extends FormHandler {
//private boolean _forceRestart;
private boolean _shouldSave;
private String _config;
private String _ff;
@Override
protected void processForm() {
if (_shouldSave) {
if (isAdvanced())
if ("ff".equals(_action) && _ff != null) {
saveFF();
} else if (isAdvanced()) {
saveChanges();
else
} else {
addFormError("Save disabled, edit the router.config file to make changes") ;
}
} else {
// noop
}
......@@ -33,6 +37,9 @@ public class ConfigAdvancedHandler extends FormHandler {
public void setShouldsave(String moo) { _shouldSave = true; }
//public void setRestart(String moo) { _forceRestart = true; }
/** @since 0.9.20 */
public void setFf(String ff) { _ff = ff; }
public void setNofilter_config(String val) {
_config = val;
}
......@@ -72,4 +79,13 @@ public class ConfigAdvancedHandler extends FormHandler {
//}
}
}
/** @since 0.9.20 */
private void saveFF() {
boolean saved = _context.router().saveConfig(ConfigAdvancedHelper.PROP_FLOODFILL_PARTICIPANT, _ff);
if (saved)
addFormNotice(_("Configuration saved successfully"));
else
addFormError(_("Error saving the configuration (applied but not saved) - please see the error logs"));
}
}
......@@ -6,8 +6,9 @@ import java.util.TreeMap;
import net.i2p.data.DataHelper;
public class ConfigAdvancedHelper extends HelperBase {
public ConfigAdvancedHelper() {}
private final static String CHECKED = " checked=\"checked\" ";
static final String PROP_FLOODFILL_PARTICIPANT = "router.floodfillParticipant";
public String getSettings() {
StringBuilder buf = new StringBuilder(4*1024);
TreeMap<String, String> sorted = new TreeMap<String, String>();
......@@ -24,4 +25,14 @@ public class ConfigAdvancedHelper extends HelperBase {
public String getConfigFileName() {
return _context.router().getConfigFilename();
}
/** @since 0.9.20 */
public String getFFChecked(int mode) {
String ff = _context.getProperty(PROP_FLOODFILL_PARTICIPANT, "auto");
if ((mode == 0 && ff.equals("false")) ||
(mode == 1 && ff.equals("true")) ||
(mode == 2 && ff.equals("auto")))
return CHECKED;
return "";
}
}
......@@ -24,12 +24,26 @@
<%@include file="formhandler.jsi" %>
<div class="configure">
<div class="wideload">
<h3><%=intl._("Floodfill Configuration")%></h3>
<p><%=intl._("Floodill participation helps the network, but may use more of your computer's resources.")%></p>
<form action="" method="POST">
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
<input type="hidden" name="action" value="ff" >
<input type="radio" class="optbox" name="ff" value="auto" <%=advancedhelper.getFFChecked(2) %> >
<%=intl._("Automatic")%><br>
<input type="radio" class="optbox" name="ff" value="true" <%=advancedhelper.getFFChecked(1) %> >
<%=intl._("Force On")%><br>
<input type="radio" class="optbox" name="ff" value="false" <%=advancedhelper.getFFChecked(0) %> >
<%=intl._("Disable")%><br>
<div class="formaction">
<input type="submit" name="shouldsave" class="accept" value="<%=intl._("Save changes")%>" >
</div></form>
<h3><%=intl._("Advanced I2P Configuration")%></h3>
<% if (advancedhelper.isAdvanced()) { %>
<form action="" method="POST">
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
<input type="hidden" name="action" value="blah" >
<% } // isAdvanced %>
<h3><%=intl._("Advanced I2P Configuration")%></h3>
<textarea rows="32" cols="60" name="nofilter_config" wrap="off" spellcheck="false" <% if (!advancedhelper.isAdvanced()) { %>readonly="readonly"<% } %>><jsp:getProperty name="advancedhelper" property="settings" /></textarea><br><hr>
<% if (advancedhelper.isAdvanced()) { %>
<div class="formaction">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment