forked from I2P_Developers/i2p.i2p
@ -684,10 +684,10 @@ public class KRPC implements I2PSessionMuxedListener, DHT {
|
|||||||
StringBuilder buf = new StringBuilder(256);
|
StringBuilder buf = new StringBuilder(256);
|
||||||
buf.append("<br><hr class=\"debug\"><b>DHT DEBUG</b><br><hr class=\"debug\"><hr><b>TX:</b> ").append(_txPkts.get()).append(" pkts / ")
|
buf.append("<br><hr class=\"debug\"><b>DHT DEBUG</b><br><hr class=\"debug\"><hr><b>TX:</b> ").append(_txPkts.get()).append(" pkts / ")
|
||||||
.append(DataHelper.formatSize2(_txBytes.get())).append("B / ")
|
.append(DataHelper.formatSize2(_txBytes.get())).append("B / ")
|
||||||
.append(DataHelper.formatSize2(_txBytes.get() * 1000 / uptime)).append("Bps<br>" +
|
.append(DataHelper.formatSize2Decimal(_txBytes.get() * 1000 / uptime)).append("Bps<br>" +
|
||||||
"<b>RX:</b> ").append(_rxPkts.get()).append(" pkts / ")
|
"<b>RX:</b> ").append(_rxPkts.get()).append(" pkts / ")
|
||||||
.append(DataHelper.formatSize2(_rxBytes.get())).append("B / ")
|
.append(DataHelper.formatSize2(_rxBytes.get())).append("B / ")
|
||||||
.append(DataHelper.formatSize2(_rxBytes.get() * 1000 / uptime)).append("Bps<br>" +
|
.append(DataHelper.formatSize2Decimal(_rxBytes.get() * 1000 / uptime)).append("Bps<br>" +
|
||||||
"<b>DHT Peers:</b> ").append( _knownNodes.size()).append("<br>" +
|
"<b>DHT Peers:</b> ").append( _knownNodes.size()).append("<br>" +
|
||||||
"<b>Blacklisted:</b> ").append(_blacklist.size()).append("<br>" +
|
"<b>Blacklisted:</b> ").append(_blacklist.size()).append("<br>" +
|
||||||
"<b>Sent tokens:</b> ").append(_outgoingTokens.size()).append("<br>" +
|
"<b>Sent tokens:</b> ").append(_outgoingTokens.size()).append("<br>" +
|
||||||
|
@ -1754,7 +1754,7 @@ public class I2PSnarkServlet extends BasicServlet {
|
|||||||
out.write("<div class=\"percentBarOuter\">");
|
out.write("<div class=\"percentBarOuter\">");
|
||||||
out.write("<div class=\"percentBarInner\" style=\"width: " + percent + "%;\">");
|
out.write("<div class=\"percentBarInner\" style=\"width: " + percent + "%;\">");
|
||||||
out.write("<div class=\"percentBarText\" tabindex=\"0\" title=\"");
|
out.write("<div class=\"percentBarText\" tabindex=\"0\" title=\"");
|
||||||
out.write(percent + "% " + _t("complete") + " - " + DataHelper.formatSize2(remaining) + "B " + _t("remaining"));
|
out.write(percent + "% " + _t("complete") + "; " + DataHelper.formatSize2(remaining) + "B " + _t("remaining"));
|
||||||
out.write("\">");
|
out.write("\">");
|
||||||
out.write(formatSize(total-remaining) + thinsp(noThinsp) + formatSize(total));
|
out.write(formatSize(total-remaining) + thinsp(noThinsp) + formatSize(total));
|
||||||
out.write("</div></div></div>");
|
out.write("</div></div></div>");
|
||||||
@ -2752,18 +2752,8 @@ public class I2PSnarkServlet extends BasicServlet {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// rounding makes us look faster :)
|
|
||||||
private static String formatSize(long bytes) {
|
private static String formatSize(long bytes) {
|
||||||
if (bytes < 5000)
|
return DataHelper.formatSize2(bytes) + 'B';
|
||||||
|
|
||||||
// replace with narrow non-breaking space ( )
|
|
||||||
return bytes + " B";
|
|
||||||
else if (bytes < 5*1024*1024)
|
|
||||||
return ((bytes + 512)/1024) + " KB";
|
|
||||||
else if (bytes < 10*1024*1024*1024l)
|
|
||||||
return ((bytes + 512*1024)/(1024*1024)) + " MB";
|
|
||||||
else
|
|
||||||
return ((bytes + 512*1024*1024)/(1024*1024*1024)) + " GB";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -171,7 +171,8 @@ class SummaryRenderer {
|
|||||||
def.setMinValue(0d);
|
def.setMinValue(0d);
|
||||||
String name = _listener.getRate().getRateStat().getName();
|
String name = _listener.getRate().getRateStat().getName();
|
||||||
// heuristic to set K=1024
|
// heuristic to set K=1024
|
||||||
if ((name.startsWith("bw.") || name.indexOf("Size") >= 0 || name.indexOf("Bps") >= 0 || name.indexOf("memory") >= 0)
|
//if ((name.startsWith("bw.") || name.indexOf("Size") >= 0 || name.indexOf("Bps") >= 0 || name.indexOf("memory") >= 0)
|
||||||
|
if ((name.indexOf("Size") >= 0 || name.indexOf("memory") >= 0)
|
||||||
&& !showEvents)
|
&& !showEvents)
|
||||||
def.setBase(1024);
|
def.setBase(1024);
|
||||||
if (titleOverride != null) {
|
if (titleOverride != null) {
|
||||||
@ -192,8 +193,8 @@ class SummaryRenderer {
|
|||||||
}
|
}
|
||||||
String path = _listener.getData().getPath();
|
String path = _listener.getData().getPath();
|
||||||
String dsNames[] = _listener.getData().getDsNames();
|
String dsNames[] = _listener.getData().getDsNames();
|
||||||
String plotName = null;
|
String plotName;
|
||||||
String descr = null;
|
String descr;
|
||||||
if (showEvents) {
|
if (showEvents) {
|
||||||
// include the average event count on the plot
|
// include the average event count on the plot
|
||||||
plotName = dsNames[1];
|
plotName = dsNames[1];
|
||||||
|
@ -24,7 +24,7 @@ public class ConfigLoggingHelper extends HelperBase {
|
|||||||
}
|
}
|
||||||
public String getMaxFileSize() {
|
public String getMaxFileSize() {
|
||||||
int bytes = _context.logManager().getFileSize();
|
int bytes = _context.logManager().getFileSize();
|
||||||
if (bytes <= 0) return "1.00 MB";
|
if (bytes <= 0) return "1.00 MiB";
|
||||||
return DataHelper.formatSize2(bytes, false) + 'B';
|
return DataHelper.formatSize2(bytes, false) + 'B';
|
||||||
}
|
}
|
||||||
public String getLogLevelTable() {
|
public String getLogLevelTable() {
|
||||||
|
@ -502,12 +502,12 @@ public class ConfigNetHandler extends FormHandler {
|
|||||||
!_inboundRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH,
|
!_inboundRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH,
|
||||||
Integer.toString(FIFOBandwidthRefiller.DEFAULT_INBOUND_BURST_BANDWIDTH)))) {
|
Integer.toString(FIFOBandwidthRefiller.DEFAULT_INBOUND_BURST_BANDWIDTH)))) {
|
||||||
try {
|
try {
|
||||||
int rate = Integer.parseInt(_inboundRate);
|
float rate = Integer.parseInt(_inboundRate) / 1.024f;
|
||||||
int kb = DEF_BURST_TIME * rate;
|
float kb = DEF_BURST_TIME * rate;
|
||||||
changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH, Integer.toString(rate));
|
changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH, Integer.toString(Math.round(rate)));
|
||||||
changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH_PEAK, Integer.toString(kb));
|
changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH_PEAK, Integer.toString(Math.round(kb)));
|
||||||
rate -= Math.min(rate * DEF_BURST_PCT / 100, 50);
|
rate -= Math.min(rate * DEF_BURST_PCT / 100, 50);
|
||||||
changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH, Integer.toString(rate));
|
changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH, Integer.toString(Math.round(rate)));
|
||||||
bwUpdated = true;
|
bwUpdated = true;
|
||||||
} catch (NumberFormatException nfe) {
|
} catch (NumberFormatException nfe) {
|
||||||
addFormError(_t("Invalid bandwidth"));
|
addFormError(_t("Invalid bandwidth"));
|
||||||
@ -517,12 +517,12 @@ public class ConfigNetHandler extends FormHandler {
|
|||||||
!_outboundRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH,
|
!_outboundRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH,
|
||||||
Integer.toString(FIFOBandwidthRefiller.DEFAULT_OUTBOUND_BURST_BANDWIDTH)))) {
|
Integer.toString(FIFOBandwidthRefiller.DEFAULT_OUTBOUND_BURST_BANDWIDTH)))) {
|
||||||
try {
|
try {
|
||||||
int rate = Integer.parseInt(_outboundRate);
|
float rate = Integer.parseInt(_outboundRate) / 1.024f;
|
||||||
int kb = DEF_BURST_TIME * rate;
|
float kb = DEF_BURST_TIME * rate;
|
||||||
changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH, Integer.toString(rate));
|
changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH, Integer.toString(Math.round(rate)));
|
||||||
changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH_PEAK, Integer.toString(kb));
|
changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH_PEAK, Integer.toString(Math.round(kb)));
|
||||||
rate -= Math.min(rate * DEF_BURST_PCT / 100, 50);
|
rate -= Math.min(rate * DEF_BURST_PCT / 100, 50);
|
||||||
changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH, Integer.toString(rate));
|
changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH, Integer.toString(Math.round(rate)));
|
||||||
bwUpdated = true;
|
bwUpdated = true;
|
||||||
} catch (NumberFormatException nfe) {
|
} catch (NumberFormatException nfe) {
|
||||||
addFormError(_t("Invalid bandwidth"));
|
addFormError(_t("Invalid bandwidth"));
|
||||||
|
@ -243,36 +243,46 @@ public class ConfigNetHelper extends HelperBase {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return decimal */
|
||||||
public String getInboundRate() {
|
public String getInboundRate() {
|
||||||
return Integer.toString(_context.bandwidthLimiter().getInboundKBytesPerSecond());
|
return Integer.toString(Math.round(_context.bandwidthLimiter().getInboundKBytesPerSecond() * 1.024f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return decimal */
|
||||||
public String getOutboundRate() {
|
public String getOutboundRate() {
|
||||||
return Integer.toString(_context.bandwidthLimiter().getOutboundKBytesPerSecond());
|
return Integer.toString(Math.round(_context.bandwidthLimiter().getOutboundKBytesPerSecond() * 1.024f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return decimal */
|
||||||
public String getInboundBurstRateBits() {
|
public String getInboundBurstRateBits() {
|
||||||
return kbytesToBits(_context.bandwidthLimiter().getInboundBurstKBytesPerSecond());
|
return kbytesToBits(_context.bandwidthLimiter().getInboundBurstKBytesPerSecond());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return decimal */
|
||||||
public String getOutboundBurstRateBits() {
|
public String getOutboundBurstRateBits() {
|
||||||
return kbytesToBits(_context.bandwidthLimiter().getOutboundBurstKBytesPerSecond());
|
return kbytesToBits(_context.bandwidthLimiter().getOutboundBurstKBytesPerSecond());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return decimal */
|
||||||
public String getShareRateBits() {
|
public String getShareRateBits() {
|
||||||
return kbytesToBits(getShareBandwidth());
|
return kbytesToBits(getShareBandwidth());
|
||||||
}
|
}
|
||||||
private String kbytesToBits(int kbytes) {
|
|
||||||
return DataHelper.formatSize(kbytes * (8 * 1024L)) + ' ' + _t("bits per second") +
|
/** @param kbytes binary K */
|
||||||
' ' + _t("or {0} bytes per month maximum", DataHelper.formatSize(kbytes * (1024L * 60 * 60 * 24 * 31)));
|
private String kbytesToBits(float kbytes) {
|
||||||
|
return DataHelper.formatSize2Decimal((long) (kbytes * (8 * 1024))) + _t("bits per second") +
|
||||||
|
"; " +
|
||||||
|
_t("{0}Bytes per month maximum", DataHelper.formatSize2Decimal((long) (kbytes * (1024L * 60 * 60 * 24 * 31))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return decimal */
|
||||||
public String getInboundBurstRate() {
|
public String getInboundBurstRate() {
|
||||||
return Integer.toString(_context.bandwidthLimiter().getInboundBurstKBytesPerSecond());
|
return Integer.toString(Math.round(_context.bandwidthLimiter().getInboundBurstKBytesPerSecond() * 1.024f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return decimal */
|
||||||
public String getOutboundBurstRate() {
|
public String getOutboundBurstRate() {
|
||||||
return Integer.toString(_context.bandwidthLimiter().getOutboundBurstKBytesPerSecond());
|
return Integer.toString(Math.round(_context.bandwidthLimiter().getOutboundBurstKBytesPerSecond() * 1.024f));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -350,7 +360,7 @@ public class ConfigNetHelper extends HelperBase {
|
|||||||
public static final int DEFAULT_SHARE_KBPS = 12;
|
public static final int DEFAULT_SHARE_KBPS = 12;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return in KBytes per second
|
* @return in binary KBytes per second
|
||||||
*/
|
*/
|
||||||
public int getShareBandwidth() {
|
public int getShareBandwidth() {
|
||||||
int irateKBps = _context.bandwidthLimiter().getInboundKBytesPerSecond();
|
int irateKBps = _context.bandwidthLimiter().getInboundKBytesPerSecond();
|
||||||
|
@ -224,7 +224,7 @@ public class PeerHelper extends HelperBase {
|
|||||||
buf.append("</span></td><td class=\"cells\" align=\"center\"><span class=\"right\">");
|
buf.append("</span></td><td class=\"cells\" align=\"center\"><span class=\"right\">");
|
||||||
if (con.getTimeSinceReceive() < 2*60*1000) {
|
if (con.getTimeSinceReceive() < 2*60*1000) {
|
||||||
float r = con.getRecvRate();
|
float r = con.getRecvRate();
|
||||||
buf.append(formatRate(r / 1024));
|
buf.append(formatRate(r / 1000));
|
||||||
bpsRecv += r;
|
bpsRecv += r;
|
||||||
} else {
|
} else {
|
||||||
buf.append(formatRate(0));
|
buf.append(formatRate(0));
|
||||||
@ -232,7 +232,7 @@ public class PeerHelper extends HelperBase {
|
|||||||
buf.append("</span>").append(THINSP).append("<span class=\"left\">");
|
buf.append("</span>").append(THINSP).append("<span class=\"left\">");
|
||||||
if (con.getTimeSinceSend() < 2*60*1000) {
|
if (con.getTimeSinceSend() < 2*60*1000) {
|
||||||
float r = con.getSendRate();
|
float r = con.getSendRate();
|
||||||
buf.append(formatRate(r / 1024));
|
buf.append(formatRate(r / 1000));
|
||||||
bpsSend += r;
|
bpsSend += r;
|
||||||
} else {
|
} else {
|
||||||
buf.append(formatRate(0));
|
buf.append(formatRate(0));
|
||||||
@ -268,8 +268,8 @@ public class PeerHelper extends HelperBase {
|
|||||||
// buf.append("<tr> <td colspan=\"11\"><hr></td></tr>\n");
|
// buf.append("<tr> <td colspan=\"11\"><hr></td></tr>\n");
|
||||||
buf.append("<tr class=\"tablefooter\"><td colspan=\"4\" align=\"left\"><b>")
|
buf.append("<tr class=\"tablefooter\"><td colspan=\"4\" align=\"left\"><b>")
|
||||||
.append(ngettext("{0} peer", "{0} peers", peers.size()));
|
.append(ngettext("{0} peer", "{0} peers", peers.size()));
|
||||||
buf.append("</b></td><td align=\"center\" nowrap><span class=\"right\"><b>").append(formatRate(bpsRecv/1024)).append("</b></span>");
|
buf.append("</b></td><td align=\"center\" nowrap><span class=\"right\"><b>").append(formatRate(bpsRecv/1000)).append("</b></span>");
|
||||||
buf.append(THINSP).append("<span class=\"left\"><b>").append(formatRate(bpsSend/1024)).append("</b></span>");
|
buf.append(THINSP).append("<span class=\"left\"><b>").append(formatRate(bpsSend/1000)).append("</b></span>");
|
||||||
buf.append("</td><td align=\"right\"><b>").append(DataHelper.formatDuration2(totalUptime/peers.size()));
|
buf.append("</td><td align=\"right\"><b>").append(DataHelper.formatDuration2(totalUptime/peers.size()));
|
||||||
buf.append("</b></td><td align=\"right\"><b>").append(DataHelper.formatDuration2(offsetTotal*1000/peers.size()));
|
buf.append("</b></td><td align=\"right\"><b>").append(DataHelper.formatDuration2(offsetTotal*1000/peers.size()));
|
||||||
buf.append("</b></td><td align=\"right\"><b>").append(totalSend).append("</b></td><td align=\"right\"><b>").append(totalRecv);
|
buf.append("</b></td><td align=\"right\"><b>").append(totalSend).append("</b></td><td align=\"right\"><b>").append(totalRecv);
|
||||||
@ -634,7 +634,7 @@ public class PeerHelper extends HelperBase {
|
|||||||
|
|
||||||
private static final String formatKBps(int bps) {
|
private static final String formatKBps(int bps) {
|
||||||
synchronized (_fmt) {
|
synchronized (_fmt) {
|
||||||
return _fmt.format((float)bps/1024);
|
return _fmt.format((float)bps/1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ class ProfileOrganizerRenderer {
|
|||||||
.append("<td><b>U</b></td><td>").append(_t("Unreachable")).append("</td>")
|
.append("<td><b>U</b></td><td>").append(_t("Unreachable")).append("</td>")
|
||||||
.append("<td> </td></tr>");
|
.append("<td> </td></tr>");
|
||||||
buf.append("<tr><td> </td>")
|
buf.append("<tr><td> </td>")
|
||||||
.append("<td><b>X</b></td><td>").append(_t("Over {0} shared bandwidth", Router.MIN_BW_X + " KBps")).append("</td>")
|
.append("<td><b>X</b></td><td>").append(_t("Over {0} shared bandwidth", Math.round(Router.MIN_BW_X * 1.024f) + " KBps")).append("</td>")
|
||||||
.append("<td> </td><td> </td><td> </td></tr>");
|
.append("<td> </td><td> </td><td> </td></tr>");
|
||||||
buf.append("<tr><td> </td><td colspan=\"5\">").append(_t("Note: For P and X bandwidth tiers, O is included for the purpose of backward compatibility in the NetDB."))
|
buf.append("<tr><td> </td><td colspan=\"5\">").append(_t("Note: For P and X bandwidth tiers, O is included for the purpose of backward compatibility in the NetDB."))
|
||||||
.append("</tr>");
|
.append("</tr>");
|
||||||
|
@ -320,7 +320,7 @@ public class SummaryHelper extends HelperBase {
|
|||||||
// long free = Runtime.getRuntime().freeMemory()/1024/1024;
|
// long free = Runtime.getRuntime().freeMemory()/1024/1024;
|
||||||
// return integerFormatter.format(used) + "MB (" + usedPc + "%)";
|
// return integerFormatter.format(used) + "MB (" + usedPc + "%)";
|
||||||
// return integerFormatter.format(used) + "MB / " + free + " MB";
|
// return integerFormatter.format(used) + "MB / " + free + " MB";
|
||||||
return integerFormatter.format(used) + " / " + total + " MB";
|
return integerFormatter.format(used) + " / " + total + " MiB";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @since 0.9.32 */
|
/** @since 0.9.32 */
|
||||||
@ -349,7 +349,7 @@ public class SummaryHelper extends HelperBase {
|
|||||||
// return integerFormatter.format(used) + "MB (" + usedPc + "%)";
|
// return integerFormatter.format(used) + "MB (" + usedPc + "%)";
|
||||||
// return integerFormatter.format(used) + "MB / " + free + " MB";
|
// return integerFormatter.format(used) + "MB / " + free + " MB";
|
||||||
return "<div class=\"percentBarOuter\" id=\"sb_memoryBar\"><div class=\"percentBarText\">RAM: " +
|
return "<div class=\"percentBarOuter\" id=\"sb_memoryBar\"><div class=\"percentBarText\">RAM: " +
|
||||||
integerFormatter.format(used) + " / " + total + " MB" +
|
integerFormatter.format(used) + " / " + total + " MiB" +
|
||||||
"</div><div class=\"percentBarInner\" style=\"width: " + integerFormatter.format(usedPc) +
|
"</div><div class=\"percentBarInner\" style=\"width: " + integerFormatter.format(usedPc) +
|
||||||
"%;\"></div></div>";
|
"%;\"></div></div>";
|
||||||
}
|
}
|
||||||
@ -498,17 +498,18 @@ public class SummaryHelper extends HelperBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return "x.xx / y.yy {K|M}"
|
* Output is decimal, not binary
|
||||||
|
* @return "x.xx / y.yy {K|M}"
|
||||||
*/
|
*/
|
||||||
private static String formatPair(double in, double out) {
|
private static String formatPair(double in, double out) {
|
||||||
boolean mega = in >= 1024*1024 || out >= 1024*1024;
|
boolean mega = in >= 1000*1000 || out >= 1000*1000;
|
||||||
// scale both the same
|
// scale both the same
|
||||||
if (mega) {
|
if (mega) {
|
||||||
in /= 1024*1024;
|
in /= 1000*1000;
|
||||||
out /= 1024*1024;
|
out /= 1000*1000;
|
||||||
} else {
|
} else {
|
||||||
in /= 1024;
|
in /= 1000;
|
||||||
out /= 1024;
|
out /= 1000;
|
||||||
}
|
}
|
||||||
// control total width
|
// control total width
|
||||||
DecimalFormat fmt;
|
DecimalFormat fmt;
|
||||||
@ -530,9 +531,7 @@ public class SummaryHelper extends HelperBase {
|
|||||||
public String getInboundTransferred() {
|
public String getInboundTransferred() {
|
||||||
if (_context == null)
|
if (_context == null)
|
||||||
return "0";
|
return "0";
|
||||||
|
|
||||||
long received = _context.bandwidthLimiter().getTotalAllocatedInboundBytes();
|
long received = _context.bandwidthLimiter().getTotalAllocatedInboundBytes();
|
||||||
|
|
||||||
return DataHelper.formatSize2(received) + 'B';
|
return DataHelper.formatSize2(received) + 'B';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -544,7 +543,6 @@ public class SummaryHelper extends HelperBase {
|
|||||||
public String getOutboundTransferred() {
|
public String getOutboundTransferred() {
|
||||||
if (_context == null)
|
if (_context == null)
|
||||||
return "0";
|
return "0";
|
||||||
|
|
||||||
long sent = _context.bandwidthLimiter().getTotalAllocatedOutboundBytes();
|
long sent = _context.bandwidthLimiter().getTotalAllocatedOutboundBytes();
|
||||||
return DataHelper.formatSize2(sent) + 'B';
|
return DataHelper.formatSize2(sent) + 'B';
|
||||||
}
|
}
|
||||||
@ -957,7 +955,7 @@ public class SummaryHelper extends HelperBase {
|
|||||||
String status = checker.getStatus();
|
String status = checker.getStatus();
|
||||||
if (status.length() > 0) {
|
if (status.length() > 0) {
|
||||||
// Show status message even if not running, timer in ReseedChecker should remove after 20 minutes
|
// Show status message even if not running, timer in ReseedChecker should remove after 20 minutes
|
||||||
buf.append("<div class=\"sb_notice\"><i>").append(checker.getStatus()).append("</i></div>");
|
buf.append("<div class=\"sb_notice\"><i>").append(status).append("</i></div>");
|
||||||
}
|
}
|
||||||
if (!checker.inProgress()) {
|
if (!checker.inProgress()) {
|
||||||
// If a new reseed isn't running, and the last reseed had errors, show error message
|
// If a new reseed isn't running, and the last reseed had errors, show error message
|
||||||
|
@ -185,7 +185,7 @@ class TunnelRenderer {
|
|||||||
+ "<td> </td></tr>");
|
+ "<td> </td></tr>");
|
||||||
out.write("<tr><td> </td>"
|
out.write("<tr><td> </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>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><span class=\"tunnel_cap\"><b>X</b></span></td><td>" + _t("Over {0} shared bandwidth", Math.round(Router.MIN_BW_X * 1.024f) + " KBps") + "</td>"
|
||||||
+ "<td> </td></tr>");
|
+ "<td> </td></tr>");
|
||||||
out.write("</tbody></table>");
|
out.write("</tbody></table>");
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ class TunnelRenderer {
|
|||||||
|
|
||||||
/** @since 0.9.33 */
|
/** @since 0.9.33 */
|
||||||
static String range(int f, int t) {
|
static String range(int f, int t) {
|
||||||
return f + " - " + t + " KBps";
|
return Math.round(f * 1.024f) + " - " + (Math.round(t * 1.024f) - 1) + " KBps";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TunnelComparator implements Comparator<HopConfig>, Serializable {
|
private static class TunnelComparator implements Comparator<HopConfig>, Serializable {
|
||||||
@ -248,7 +248,7 @@ class TunnelRenderer {
|
|||||||
_t("Outbound") + "\"></td>");
|
_t("Outbound") + "\"></td>");
|
||||||
out.write("<td class=\"cells\" align=\"center\">" + DataHelper.formatDuration2(timeLeft) + "</td>\n");
|
out.write("<td class=\"cells\" align=\"center\">" + DataHelper.formatDuration2(timeLeft) + "</td>\n");
|
||||||
int count = info.getProcessedMessagesCount();
|
int count = info.getProcessedMessagesCount();
|
||||||
out.write("<td class=\"cells\" align=\"center\">" + count + " KB</td>\n");
|
out.write("<td class=\"cells\" align=\"center\">" + count + " KiB</td>\n");
|
||||||
for (int j = 0; j < info.getLength(); j++) {
|
for (int j = 0; j < info.getLength(); j++) {
|
||||||
Hash peer = info.getPeer(j);
|
Hash peer = info.getPeer(j);
|
||||||
TunnelId id = (info.isInbound() ? info.getReceiveTunnelId(j) : info.getSendTunnelId(j));
|
TunnelId id = (info.isInbound() ? info.getReceiveTunnelId(j) : info.getSendTunnelId(j));
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
<td>(<jsp:getProperty name="nethelper" property="shareRateBits" />)
|
<td>(<jsp:getProperty name="nethelper" property="shareRateBits" />)
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td class="infohelp" colspan="2">
|
<tr><td class="infohelp" colspan="2">
|
||||||
<% int share = nethelper.getShareBandwidth();
|
<% int share = Math.round(nethelper.getShareBandwidth() * 1.024f);
|
||||||
if (share < 12) {
|
if (share < 12) {
|
||||||
out.print("<b>");
|
out.print("<b>");
|
||||||
out.print(intl._t("NOTE"));
|
out.print(intl._t("NOTE"));
|
||||||
|
@ -1525,8 +1525,15 @@ public class DataHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Caller should append 'B' or 'b' as appropriate
|
* This is binary, i.e. multiples of 1024.
|
||||||
|
* For decimal, see formatSize2Decimal().
|
||||||
|
*
|
||||||
|
* Caller should append 'B' or 'b' as appropriate.
|
||||||
|
*
|
||||||
|
* No space between the number and the letter.
|
||||||
* NOTE: formatSize2() recommended in most cases for readability
|
* NOTE: formatSize2() recommended in most cases for readability
|
||||||
|
*
|
||||||
|
* @return e.g. "123.05Ki"
|
||||||
*/
|
*/
|
||||||
public static String formatSize(long bytes) {
|
public static String formatSize(long bytes) {
|
||||||
float val = bytes;
|
float val = bytes;
|
||||||
@ -1540,23 +1547,29 @@ public class DataHelper {
|
|||||||
|
|
||||||
String str = fmt.format(val);
|
String str = fmt.format(val);
|
||||||
switch (scale) {
|
switch (scale) {
|
||||||
case 1: return str + "K";
|
case 1: return str + "Ki";
|
||||||
case 2: return str + "M";
|
case 2: return str + "Mi";
|
||||||
case 3: return str + "G";
|
case 3: return str + "Gi";
|
||||||
case 4: return str + "T";
|
case 4: return str + "Ti";
|
||||||
case 5: return str + "P";
|
case 5: return str + "Pi";
|
||||||
case 6: return str + "E";
|
case 6: return str + "Ei";
|
||||||
case 7: return str + "Z";
|
case 7: return str + "Zi";
|
||||||
case 8: return str + "Y";
|
case 8: return str + "Yi";
|
||||||
default: return bytes + "";
|
default: return bytes + "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* This is binary, i.e. multiples of 1024.
|
||||||
|
* For decimal, see formatSize2Decimal().
|
||||||
|
*
|
||||||
|
* Caller should append 'B' or 'b' as appropriate.
|
||||||
* Like formatSize but with a non-breaking space after the number
|
* Like formatSize but with a non-breaking space after the number
|
||||||
* This seems consistent with most style guides out there.
|
* This seems consistent with most style guides out there.
|
||||||
* Use only in HTML, and not inside form values (use
|
* Use only in HTML, and not inside form values (use
|
||||||
* formatSize2(bytes, false) there instead).
|
* formatSize2(bytes, false) there instead).
|
||||||
|
*
|
||||||
|
* @return e.g. "123.05&#8239;Ki"
|
||||||
* @since 0.7.14, uses thin non-breaking space since 0.9.31
|
* @since 0.7.14, uses thin non-breaking space since 0.9.31
|
||||||
*/
|
*/
|
||||||
public static String formatSize2(long bytes) {
|
public static String formatSize2(long bytes) {
|
||||||
@ -1564,9 +1577,15 @@ public class DataHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* This is binary, i.e. multiples of 1024.
|
||||||
|
* For decimal, see formatSize2Decimal().
|
||||||
|
*
|
||||||
|
* Caller should append 'B' or 'b' as appropriate,
|
||||||
* Like formatSize but with a space after the number
|
* Like formatSize but with a space after the number
|
||||||
* This seems consistent with most style guides out there.
|
* This seems consistent with most style guides out there.
|
||||||
|
*
|
||||||
* @param nonBreaking use an HTML thin non-breaking space (&#8239;)
|
* @param nonBreaking use an HTML thin non-breaking space (&#8239;)
|
||||||
|
* @return e.g. "123.05&#8239;Ki" or "123.05 Ki"
|
||||||
* @since 0.9.31
|
* @since 0.9.31
|
||||||
*/
|
*/
|
||||||
public static String formatSize2(long bytes, boolean nonBreaking) {
|
public static String formatSize2(long bytes, boolean nonBreaking) {
|
||||||
@ -1581,6 +1600,56 @@ public class DataHelper {
|
|||||||
|
|
||||||
// Replace with thin non-breaking space   (more consistent/predictable width between fonts & point sizes)
|
// Replace with thin non-breaking space   (more consistent/predictable width between fonts & point sizes)
|
||||||
|
|
||||||
|
String space = nonBreaking ? " " : " ";
|
||||||
|
String str = fmt.format(val) + space;
|
||||||
|
switch (scale) {
|
||||||
|
case 1: return str + "Ki";
|
||||||
|
case 2: return str + "Mi";
|
||||||
|
case 3: return str + "Gi";
|
||||||
|
case 4: return str + "Ti";
|
||||||
|
case 5: return str + "Pi";
|
||||||
|
case 6: return str + "Ei";
|
||||||
|
case 7: return str + "Zi";
|
||||||
|
case 8: return str + "Yi";
|
||||||
|
default: return bytes + space;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is decimal, i.e. multiples of 1000.
|
||||||
|
* For binary, see formatSize2().
|
||||||
|
*
|
||||||
|
* Caller should append 'B' or 'b' as appropriate.
|
||||||
|
* Like formatSize but with a space after the number
|
||||||
|
* This seems consistent with most style guides out there.
|
||||||
|
*
|
||||||
|
* @return e.g. "123.05&#8239;K"
|
||||||
|
* @since 0.9.34
|
||||||
|
*/
|
||||||
|
public static String formatSize2Decimal(long bytes) {
|
||||||
|
return formatSize2Decimal(bytes, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is decimal, i.e. multiples of 1000.
|
||||||
|
* For binary, see formatSize2().
|
||||||
|
*
|
||||||
|
* Caller should append 'B' or 'b' as appropriate.
|
||||||
|
* Like formatSize but with a space after the number
|
||||||
|
* This seems consistent with most style guides out there.
|
||||||
|
*
|
||||||
|
* @param nonBreaking use an HTML thin non-breaking space (&#8239;)
|
||||||
|
* @return e.g. "123.05&#8239;K" or "123.05 K"
|
||||||
|
* @since 0.9.34
|
||||||
|
*/
|
||||||
|
public static String formatSize2Decimal(long bytes, boolean nonBreaking) {
|
||||||
|
double val = bytes;
|
||||||
|
int scale = 0;
|
||||||
|
while (val >= 1000) {
|
||||||
|
scale++;
|
||||||
|
val /= 1000;
|
||||||
|
}
|
||||||
|
DecimalFormat fmt = new DecimalFormat("##0.00");
|
||||||
String space = nonBreaking ? " " : " ";
|
String space = nonBreaking ? " " : " ";
|
||||||
String str = fmt.format(val) + space;
|
String str = fmt.format(val) + space;
|
||||||
switch (scale) {
|
switch (scale) {
|
||||||
|
@ -552,7 +552,9 @@ public class LogManager implements Flushable {
|
|||||||
String v = size.trim().toUpperCase(Locale.US);
|
String v = size.trim().toUpperCase(Locale.US);
|
||||||
if (v.length() < 2)
|
if (v.length() < 2)
|
||||||
return -1;
|
return -1;
|
||||||
if (v.endsWith("B"))
|
if (v.endsWith("IB"))
|
||||||
|
v = v.substring(0, v.length() - 2);
|
||||||
|
else if (v.endsWith("B"))
|
||||||
v = v.substring(0, v.length() - 1);
|
v = v.substring(0, v.length() - 1);
|
||||||
char mod = v.charAt(v.length() - 1);
|
char mod = v.charAt(v.length() - 1);
|
||||||
if (!Character.isDigit(mod)) v = v.substring(0, v.length() - 1);
|
if (!Character.isDigit(mod)) v = v.substring(0, v.length() - 1);
|
||||||
|
@ -973,19 +973,26 @@ public class Router implements RouterClock.ClockShiftListener {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public static final char CAPABILITY_NEW_TUNNEL = 'T';
|
public static final char CAPABILITY_NEW_TUNNEL = 'T';
|
||||||
|
|
||||||
/** @since 0.9.33 */
|
/** In binary (1024) Kbytes
|
||||||
|
* @since 0.9.33 */
|
||||||
public static final int MIN_BW_K = 0;
|
public static final int MIN_BW_K = 0;
|
||||||
/** @since 0.9.33 */
|
/** In binary (1024) Kbytes
|
||||||
|
* @since 0.9.33 */
|
||||||
public static final int MIN_BW_L = 12;
|
public static final int MIN_BW_L = 12;
|
||||||
/** @since 0.9.33 */
|
/** In binary (1024) Kbytes
|
||||||
|
* @since 0.9.33 */
|
||||||
public static final int MIN_BW_M = 48;
|
public static final int MIN_BW_M = 48;
|
||||||
/** @since 0.9.33 */
|
/** In binary (1024) Kbytes
|
||||||
|
* @since 0.9.33 */
|
||||||
public static final int MIN_BW_N = 64;
|
public static final int MIN_BW_N = 64;
|
||||||
/** @since 0.9.33 */
|
/** In binary (1024) Kbytes
|
||||||
|
* @since 0.9.33 */
|
||||||
public static final int MIN_BW_O = 128;
|
public static final int MIN_BW_O = 128;
|
||||||
/** @since 0.9.33 */
|
/** In binary (1024) Kbytes
|
||||||
|
* @since 0.9.33 */
|
||||||
public static final int MIN_BW_P = 256;
|
public static final int MIN_BW_P = 256;
|
||||||
/** @since 0.9.33 */
|
/** In binary (1024) Kbytes
|
||||||
|
* @since 0.9.33 */
|
||||||
public static final int MIN_BW_X = 2000;
|
public static final int MIN_BW_X = 2000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,16 +133,28 @@ public class FIFOBandwidthLimiter {
|
|||||||
/** @return smoothed 15 second rate */
|
/** @return smoothed 15 second rate */
|
||||||
public float getReceiveBps15s() { return _recvBps15s; }
|
public float getReceiveBps15s() { return _recvBps15s; }
|
||||||
|
|
||||||
/** The configured maximum, not the current rate */
|
/**
|
||||||
|
* The configured maximum, not the current rate.
|
||||||
|
* In binary K, i.e. rate / 1024.
|
||||||
|
*/
|
||||||
public int getOutboundKBytesPerSecond() { return _refiller.getOutboundKBytesPerSecond(); }
|
public int getOutboundKBytesPerSecond() { return _refiller.getOutboundKBytesPerSecond(); }
|
||||||
|
|
||||||
/** The configured maximum, not the current rate */
|
/**
|
||||||
|
* The configured maximum, not the current rate.
|
||||||
|
* In binary K, i.e. rate / 1024.
|
||||||
|
*/
|
||||||
public int getInboundKBytesPerSecond() { return _refiller.getInboundKBytesPerSecond(); }
|
public int getInboundKBytesPerSecond() { return _refiller.getInboundKBytesPerSecond(); }
|
||||||
|
|
||||||
/** The configured maximum, not the current rate */
|
/**
|
||||||
|
* The configured maximum, not the current rate.
|
||||||
|
* In binary K, i.e. rate / 1024.
|
||||||
|
*/
|
||||||
public int getOutboundBurstKBytesPerSecond() { return _refiller.getOutboundBurstKBytesPerSecond(); }
|
public int getOutboundBurstKBytesPerSecond() { return _refiller.getOutboundBurstKBytesPerSecond(); }
|
||||||
|
|
||||||
/** The configured maximum, not the current rate */
|
/**
|
||||||
|
* The configured maximum, not the current rate.
|
||||||
|
* In binary K, i.e. rate / 1024.
|
||||||
|
*/
|
||||||
public int getInboundBurstKBytesPerSecond() { return _refiller.getInboundBurstKBytesPerSecond(); }
|
public int getInboundBurstKBytesPerSecond() { return _refiller.getInboundBurstKBytesPerSecond(); }
|
||||||
|
|
||||||
public synchronized void reinitialize() {
|
public synchronized void reinitialize() {
|
||||||
|
Reference in New Issue
Block a user