forked from I2P_Developers/i2p.i2p
Router: Parameterize bandwidth classes, fix display on /tunnels
This commit is contained in:
@ -150,21 +150,26 @@ class TunnelRenderer {
|
||||
out.write("<h3 class=\"tabletitle\">" + _t("Bandwidth Tiers") + "</h3>\n");
|
||||
out.write("<table id=\"tunnel_defs\"><tbody>");
|
||||
out.write("<tr><td> </td>"
|
||||
+ "<td><span class=\"tunnel_cap\"><b>L</b></span></td><td>" + _t("{0} shared bandwidth", "12 - 32KBps") + "</td>"
|
||||
+ "<td><span class=\"tunnel_cap\"><b>M</b></span></td><td>" + _t("{0} shared bandwidth", "32 - 64KBps") + "</td>"
|
||||
+ "<td><span class=\"tunnel_cap\"><b>L</b></span></td><td>" + _t("{0} shared bandwidth", range(Router.MIN_BW_L, Router.MIN_BW_M)) + "</td>"
|
||||
+ "<td><span class=\"tunnel_cap\"><b>M</b></span></td><td>" + _t("{0} shared bandwidth", range(Router.MIN_BW_M, Router.MIN_BW_N)) + "</td>"
|
||||
+ "<td> </td></tr>");
|
||||
out.write("<tr><td> </td>"
|
||||
+ "<td><span class=\"tunnel_cap\"><b>N</b></span></td><td>" + _t("{0} shared bandwidth", "64 - 128KBps") + "</td>"
|
||||
+ "<td><span class=\"tunnel_cap\"><b>O</b></span></td><td>" + _t("{0} shared bandwidth", "128 - 256KBps") + "</td>"
|
||||
+ "<td><span class=\"tunnel_cap\"><b>N</b></span></td><td>" + _t("{0} shared bandwidth", range(Router.MIN_BW_N, Router.MIN_BW_O)) + "</td>"
|
||||
+ "<td><span class=\"tunnel_cap\"><b>O</b></span></td><td>" + _t("{0} shared bandwidth", range(Router.MIN_BW_O, Router.MIN_BW_P)) + "</td>"
|
||||
+ "<td> </td></tr>");
|
||||
out.write("<tr><td> </td>"
|
||||
+ "<td><span class=\"tunnel_cap\"><b>P</b></span></td><td>" + _t("{0} shared bandwidth", "256 - 2000KBps") + "</td>"
|
||||
+ "<td><span class=\"tunnel_cap\"><b>X</b></span></td><td>" + _t("Over {0} shared bandwidth", "2000KBps") + "</td>"
|
||||
+ "<td><span class=\"tunnel_cap\"><b>P</b></span></td><td>" + _t("{0} shared bandwidth", range(Router.MIN_BW_P, Router.MIN_BW_X)) + "</td>"
|
||||
+ "<td><span class=\"tunnel_cap\"><b>X</b></span></td><td>" + _t("Over {0} shared bandwidth", Router.MIN_BW_X + " KBps") + "</td>"
|
||||
+ "<td> </td></tr>");
|
||||
out.write("</tbody></table>");
|
||||
|
||||
}
|
||||
|
||||
/** @since 0.9.33 */
|
||||
private static String range(int f, int t) {
|
||||
return f + " - " + t + " KBps";
|
||||
}
|
||||
|
||||
private static class TunnelComparator implements Comparator<HopConfig>, Serializable {
|
||||
public int compare(HopConfig l, HopConfig r) {
|
||||
return (r.getProcessedMessagesCount() - l.getProcessedMessagesCount());
|
||||
|
@ -952,6 +952,21 @@ public class Router implements RouterClock.ClockShiftListener {
|
||||
@Deprecated
|
||||
public static final char CAPABILITY_NEW_TUNNEL = 'T';
|
||||
|
||||
/** @since 0.9.33 */
|
||||
public static final int MIN_BW_K = 0;
|
||||
/** @since 0.9.33 */
|
||||
public static final int MIN_BW_L = 12;
|
||||
/** @since 0.9.33 */
|
||||
public static final int MIN_BW_M = 48;
|
||||
/** @since 0.9.33 */
|
||||
public static final int MIN_BW_N = 64;
|
||||
/** @since 0.9.33 */
|
||||
public static final int MIN_BW_O = 128;
|
||||
/** @since 0.9.33 */
|
||||
public static final int MIN_BW_P = 256;
|
||||
/** @since 0.9.33 */
|
||||
public static final int MIN_BW_X = 2000;
|
||||
|
||||
/**
|
||||
* The current bandwidth class.
|
||||
* For building our RI. Not for external use.
|
||||
@ -967,17 +982,17 @@ public class Router implements RouterClock.ClockShiftListener {
|
||||
String force = _context.getProperty(PROP_FORCE_BWCLASS);
|
||||
if (force != null && force.length() > 0) {
|
||||
return force.charAt(0);
|
||||
} else if (bwLim < 12) {
|
||||
} else if (bwLim < MIN_BW_L) {
|
||||
return CAPABILITY_BW12;
|
||||
} else if (bwLim <= 48) {
|
||||
} else if (bwLim <= MIN_BW_M) {
|
||||
return CAPABILITY_BW32;
|
||||
} else if (bwLim <= 64) {
|
||||
} else if (bwLim <= MIN_BW_N) {
|
||||
return CAPABILITY_BW64;
|
||||
} else if (bwLim <= 128) {
|
||||
} else if (bwLim <= MIN_BW_O) {
|
||||
return CAPABILITY_BW128;
|
||||
} else if (bwLim <= 256) {
|
||||
} else if (bwLim <= MIN_BW_P) {
|
||||
return CAPABILITY_BW256;
|
||||
} else if (bwLim <= 2000) { // TODO adjust threshold
|
||||
} else if (bwLim <= MIN_BW_X) { // TODO adjust threshold
|
||||
// 512 supported as of 0.9.18;
|
||||
return CAPABILITY_BW512;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user