Console: Add floodfill configuration form to /configadvanced

This commit is contained in:
zzz
2015-05-03 18:49:34 +00:00
parent b5f75a4bb9
commit 2fafa3337f
3 changed files with 46 additions and 5 deletions

View File

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

View File

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