forked from I2P_Developers/i2p.i2p
Compare commits
3 Commits
master
...
configadva
Author | SHA1 | Date | |
---|---|---|---|
23b61a32cc | |||
05706131b9 | |||
7250ab558c |
@ -1,6 +1,7 @@
|
||||
package net.i2p.router.web.helpers;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -29,23 +30,66 @@ public class ConfigAdvancedHelper extends HelperBase {
|
||||
_hideKeys = new HashSet<String>(Arrays.asList(keys));
|
||||
}
|
||||
|
||||
private static final Map<String, String> _headers = new HashMap<String, String>(16);
|
||||
static {
|
||||
String[] ss = {
|
||||
"crypto", "Crypto",
|
||||
"desktopgui", "System Tray",
|
||||
"i2cp", "I2CP",
|
||||
"i2np", "I2NP",
|
||||
"i2p", "I2P",
|
||||
"jbigi", "JBigI",
|
||||
"netdb", "NetDB",
|
||||
"prng", "Random",
|
||||
"router", "Router",
|
||||
"routerconsole", "Router Console",
|
||||
"stat", "Statistics",
|
||||
"time", "Time" };
|
||||
for (int i = 0; i < ss.length; i += 2) {
|
||||
_headers.put(ss[i], ss[i+1]);
|
||||
}
|
||||
}
|
||||
|
||||
public String getSettings() {
|
||||
StringBuilder buf = new StringBuilder(4*1024);
|
||||
TreeMap<String, String> sorted = new TreeMap<String, String>();
|
||||
sorted.putAll(_context.router().getConfigMap());
|
||||
boolean adv = isAdvanced();
|
||||
String lastType = null;
|
||||
if (!adv)
|
||||
buf.append("<table id=\"advcfgtable\">\n");
|
||||
for (Map.Entry<String, String> e : sorted.entrySet()) {
|
||||
String key = e.getKey();
|
||||
if (!adv &&
|
||||
( _hideKeys.contains(key) ||
|
||||
if (!adv) {
|
||||
if ( _hideKeys.contains(key) ||
|
||||
key.startsWith("i2cp.auth.") ||
|
||||
key.startsWith(PROP_AUTH_PFX))) {
|
||||
key.startsWith(PROP_AUTH_PFX))
|
||||
continue;
|
||||
String type = key;
|
||||
int dot = key.indexOf('.');
|
||||
if (dot > 0)
|
||||
type = type.substring(0, dot);
|
||||
if (!type.equals(lastType)) {
|
||||
lastType = type;
|
||||
String dtype = _headers.get(type);
|
||||
if (dtype == null)
|
||||
dtype = type;
|
||||
dtype = DataHelper.escapeHTML(dtype);
|
||||
buf.append("<tr><th colspan=\"2\">[").append(_t(dtype)).append("]</th></tr>\n");
|
||||
}
|
||||
}
|
||||
String name = DataHelper.escapeHTML(key);
|
||||
String val = DataHelper.escapeHTML(e.getValue());
|
||||
if (adv) {
|
||||
buf.append(name).append('=').append(val).append('\n');
|
||||
} else {
|
||||
if (name.length() > lastType.length())
|
||||
name = name.substring(lastType.length() + 1);
|
||||
buf.append("<tr><td>").append(name).append("</td><td>").append(val).append("</td></tr>\n");
|
||||
}
|
||||
}
|
||||
if (!adv)
|
||||
buf.append("</table>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,17 @@
|
||||
</td></tr>
|
||||
<% } // isAdvanced %>
|
||||
<tr><td class="tabletextarea">
|
||||
<textarea id="advancedsettings" rows="32" cols="60" name="nofilter_config" wrap="off" spellcheck="false" <% if (!advancedhelper.isAdvanced()) { %>readonly="readonly"<% } %>><%=advConfig%></textarea>
|
||||
<%
|
||||
if (advancedhelper.isAdvanced()) {
|
||||
%>
|
||||
<textarea id="advancedsettings" rows="32" cols="60" name="nofilter_config" wrap="off" spellcheck="false" >
|
||||
<% } // isAdvanced %>
|
||||
<%=advConfig%>
|
||||
<%
|
||||
if (advancedhelper.isAdvanced()) {
|
||||
%>
|
||||
</textarea>
|
||||
<% } // isAdvanced %>
|
||||
</td></tr>
|
||||
<% if (advancedhelper.isAdvanced()) { %>
|
||||
<tr><td class="optionsave" align="right">
|
||||
|
Reference in New Issue
Block a user