forked from I2P_Developers/i2p.i2p
* I2PTunnel: Add advanced quantity options
This commit is contained in:
@ -378,4 +378,42 @@ public class EditBean extends IndexBean {
|
|||||||
if (controller == null) return null;
|
if (controller == null) return null;
|
||||||
return controller.getClientOptionProps();
|
return controller.getClientOptionProps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String PROP_ADVANCED = "routerconsole.advanced";
|
||||||
|
private static final int DFLT_QUANTITY = 2;
|
||||||
|
private static final int MAX_CLIENT_QUANTITY = 3;
|
||||||
|
private static final int MAX_SERVER_QUANTITY = 6;
|
||||||
|
private static final int MAX_ADVANCED_QUANTITY = 16;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 0.9.7
|
||||||
|
*/
|
||||||
|
public String getQuantityOptions(int tunnel) {
|
||||||
|
int tunnelQuantity = getTunnelQuantity(tunnel, DFLT_QUANTITY);
|
||||||
|
boolean advanced = _context.getBooleanProperty(PROP_ADVANCED);
|
||||||
|
int maxQuantity = advanced ? MAX_ADVANCED_QUANTITY :
|
||||||
|
(isClient(tunnel) ? MAX_CLIENT_QUANTITY : MAX_SERVER_QUANTITY);
|
||||||
|
if (tunnelQuantity > maxQuantity)
|
||||||
|
maxQuantity = tunnelQuantity;
|
||||||
|
StringBuilder buf = new StringBuilder(256);
|
||||||
|
for (int i = 1; i <= maxQuantity; i++) {
|
||||||
|
buf.append("<option value=\"").append(i).append('"');
|
||||||
|
if (i == tunnelQuantity)
|
||||||
|
buf.append(" selected=\"selected\"");
|
||||||
|
buf.append('>');
|
||||||
|
buf.append(ngettext("{0} inbound, {0} outbound tunnel", "{0} inbound, {0} outbound tunnels", i));
|
||||||
|
if (i <= 3) {
|
||||||
|
buf.append(" (");
|
||||||
|
if (i == 1)
|
||||||
|
buf.append(_("lower bandwidth and reliability"));
|
||||||
|
else if (i == 2)
|
||||||
|
buf.append(_("standard bandwidth and reliability"));
|
||||||
|
else if (i == 3)
|
||||||
|
buf.append(_("higher bandwidth and reliability"));
|
||||||
|
buf.append(')');
|
||||||
|
}
|
||||||
|
buf.append("</option>\n");
|
||||||
|
}
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1293,4 +1293,11 @@ public class IndexBean {
|
|||||||
protected String _(String key) {
|
protected String _(String key) {
|
||||||
return Messages._(key, _context);
|
return Messages._(key, _context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** translate (ngettext)
|
||||||
|
* @since 0.9.7
|
||||||
|
*/
|
||||||
|
protected String ngettext(String s, String p, int n) {
|
||||||
|
return Messages.ngettext(s, p, n, _context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,4 +39,11 @@ public class Messages {
|
|||||||
public String _(String s, Object o) {
|
public String _(String s, Object o) {
|
||||||
return Translate.getString(s, o, _context, BUNDLE_NAME);
|
return Translate.getString(s, o, _context, BUNDLE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** translate (ngettext)
|
||||||
|
* @since 0.9.7
|
||||||
|
*/
|
||||||
|
public static String ngettext(String s, String p, int n, I2PAppContext ctx) {
|
||||||
|
return Translate.getString(n, s, p, ctx, BUNDLE_NAME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,14 +247,8 @@ input.default { width: 1px; height: 1px; visibility: hidden; }
|
|||||||
<%=intl._("Count")%>(<span class="accessKey">C</span>):
|
<%=intl._("Count")%>(<span class="accessKey">C</span>):
|
||||||
</label>
|
</label>
|
||||||
<select id="tunnelQuantity" name="tunnelQuantity" title="Number of Tunnels in Group" class="selectbox">
|
<select id="tunnelQuantity" name="tunnelQuantity" title="Number of Tunnels in Group" class="selectbox">
|
||||||
<% int tunnelQuantity = editBean.getTunnelQuantity(curTunnel, 2);
|
<%=editBean.getQuantityOptions(curTunnel)%>
|
||||||
%><option value="1"<%=(tunnelQuantity == 1 ? " selected=\"selected\"" : "") %>><%=intl._("1 inbound, 1 outbound tunnel (low bandwidth usage, less reliability)")%></option>
|
</select>
|
||||||
<option value="2"<%=(tunnelQuantity == 2 ? " selected=\"selected\"" : "") %>><%=intl._("2 inbound, 2 outbound tunnels (standard bandwidth usage, standard reliability)")%></option>
|
|
||||||
<option value="3"<%=(tunnelQuantity == 3 ? " selected=\"selected\"" : "") %>><%=intl._("3 inbound, 3 outbound tunnels (higher bandwidth usage, higher reliability)")%></option>
|
|
||||||
<% if (tunnelQuantity > 3) {
|
|
||||||
%> <option value="<%=tunnelQuantity%>" selected="selected"><%=tunnelQuantity%> <%=intl._("tunnels")%></option>
|
|
||||||
<% }
|
|
||||||
%></select>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="backupField" class="rowItem">
|
<div id="backupField" class="rowItem">
|
||||||
<label for="tunnelBackupQuantity" accesskey="b">
|
<label for="tunnelBackupQuantity" accesskey="b">
|
||||||
|
@ -264,17 +264,8 @@ input.default { width: 1px; height: 1px; visibility: hidden; }
|
|||||||
<%=intl._("Count")%>(<span class="accessKey">C</span>):
|
<%=intl._("Count")%>(<span class="accessKey">C</span>):
|
||||||
</label>
|
</label>
|
||||||
<select id="tunnelQuantity" name="tunnelQuantity" title="Number of Tunnels in Group" class="selectbox">
|
<select id="tunnelQuantity" name="tunnelQuantity" title="Number of Tunnels in Group" class="selectbox">
|
||||||
<% int tunnelQuantity = editBean.getTunnelQuantity(curTunnel, 2);
|
<%=editBean.getQuantityOptions(curTunnel)%>
|
||||||
%><option value="1"<%=(tunnelQuantity == 1 ? " selected=\"selected\"" : "") %>><%=intl._("1 inbound, 1 outbound tunnel (low bandwidth usage, less reliability)")%></option>
|
</select>
|
||||||
<option value="2"<%=(tunnelQuantity == 2 ? " selected=\"selected\"" : "") %>><%=intl._("2 inbound, 2 outbound tunnels (standard bandwidth usage, standard reliability)")%></option>
|
|
||||||
<option value="3"<%=(tunnelQuantity == 3 ? " selected=\"selected\"" : "") %>><%=intl._("3 inbound, 3 outbound tunnels (higher bandwidth usage, higher reliability)")%></option>
|
|
||||||
<option value="4"<%=(tunnelQuantity == 4 ? " selected=\"selected\"" : "") %>><%=intl._("4 in, 4 out (high traffic server)")%></option>
|
|
||||||
<option value="5"<%=(tunnelQuantity == 5 ? " selected=\"selected\"" : "") %>><%=intl._("5 in, 5 out (high traffic server)")%></option>
|
|
||||||
<option value="6"<%=(tunnelQuantity == 6 ? " selected=\"selected\"" : "") %>><%=intl._("6 in, 6 out (high traffic server)")%></option>
|
|
||||||
<% if (tunnelQuantity > 6) {
|
|
||||||
%> <option value="<%=tunnelQuantity%>" selected="selected"><%=tunnelQuantity%> <%=intl._("tunnels")%></option>
|
|
||||||
<% }
|
|
||||||
%></select>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="backupField" class="rowItem">
|
<div id="backupField" class="rowItem">
|
||||||
<label for="tunnelBackupQuantity" accesskey="b">
|
<label for="tunnelBackupQuantity" accesskey="b">
|
||||||
|
Reference in New Issue
Block a user