forked from I2P_Developers/i2p.i2p
Console: Add floodfill configuration form to /configadvanced
This commit is contained in:
@ -17,14 +17,18 @@ public class ConfigAdvancedHandler extends FormHandler {
|
|||||||
//private boolean _forceRestart;
|
//private boolean _forceRestart;
|
||||||
private boolean _shouldSave;
|
private boolean _shouldSave;
|
||||||
private String _config;
|
private String _config;
|
||||||
|
private String _ff;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void processForm() {
|
protected void processForm() {
|
||||||
if (_shouldSave) {
|
if (_shouldSave) {
|
||||||
if (isAdvanced())
|
if ("ff".equals(_action) && _ff != null) {
|
||||||
|
saveFF();
|
||||||
|
} else if (isAdvanced()) {
|
||||||
saveChanges();
|
saveChanges();
|
||||||
else
|
} else {
|
||||||
addFormError("Save disabled, edit the router.config file to make changes") ;
|
addFormError("Save disabled, edit the router.config file to make changes") ;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// noop
|
// noop
|
||||||
}
|
}
|
||||||
@ -33,6 +37,9 @@ public class ConfigAdvancedHandler extends FormHandler {
|
|||||||
public void setShouldsave(String moo) { _shouldSave = true; }
|
public void setShouldsave(String moo) { _shouldSave = true; }
|
||||||
//public void setRestart(String moo) { _forceRestart = 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) {
|
public void setNofilter_config(String val) {
|
||||||
_config = 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;
|
import net.i2p.data.DataHelper;
|
||||||
|
|
||||||
public class ConfigAdvancedHelper extends HelperBase {
|
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() {
|
public String getSettings() {
|
||||||
StringBuilder buf = new StringBuilder(4*1024);
|
StringBuilder buf = new StringBuilder(4*1024);
|
||||||
TreeMap<String, String> sorted = new TreeMap<String, String>();
|
TreeMap<String, String> sorted = new TreeMap<String, String>();
|
||||||
@ -24,4 +25,14 @@ public class ConfigAdvancedHelper extends HelperBase {
|
|||||||
public String getConfigFileName() {
|
public String getConfigFileName() {
|
||||||
return _context.router().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" %>
|
<%@include file="formhandler.jsi" %>
|
||||||
<div class="configure">
|
<div class="configure">
|
||||||
<div class="wideload">
|
<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()) { %>
|
<% if (advancedhelper.isAdvanced()) { %>
|
||||||
<form action="" method="POST">
|
<form action="" method="POST">
|
||||||
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
|
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
|
||||||
<input type="hidden" name="action" value="blah" >
|
<input type="hidden" name="action" value="blah" >
|
||||||
<% } // isAdvanced %>
|
<% } // 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>
|
<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()) { %>
|
<% if (advancedhelper.isAdvanced()) { %>
|
||||||
<div class="formaction">
|
<div class="formaction">
|
||||||
|
Reference in New Issue
Block a user