diff --git a/router/java/src/net/i2p/router/transport/TransportManager.java b/router/java/src/net/i2p/router/transport/TransportManager.java index 243c76237b..cf21af11d9 100644 --- a/router/java/src/net/i2p/router/transport/TransportManager.java +++ b/router/java/src/net/i2p/router/transport/TransportManager.java @@ -492,7 +492,7 @@ public class TransportManager implements TransportEventListener { t.renderStatusHTML(out, urlBase, sortFlags); } - if (_transports.size() > 0) { + if (!_transports.isEmpty()) { out.write(getTransportsLegend()); } @@ -516,6 +516,11 @@ public class TransportManager implements TransportEventListener { private final String getTransportsLegend() { StringBuilder buf = new StringBuilder(1024); + buf.append("

").append(_("Help")).append("

") + .append(_("Your transport connection limits are automatically set based on your configured bandwidth.")) + .append('\n') + .append(_("To override these limits, add the settings i2np.ntcp.maxConnections=nnn and i2np.udp.maxConnections=nnn on the advanced configuration page.")) + .append("

\n"); buf.append("

").append(_("Definitions")).append("

" + "

").append(_("Peer")).append(": ").append(_("The remote peer, identified by router hash")).append("
\n" + "").append(_("Dir")).append(": " + diff --git a/router/java/src/net/i2p/router/transport/udp/UDPTransport.java b/router/java/src/net/i2p/router/transport/udp/UDPTransport.java index f0e9c9e2e9..dc0790ac48 100644 --- a/router/java/src/net/i2p/router/transport/udp/UDPTransport.java +++ b/router/java/src/net/i2p/router/transport/udp/UDPTransport.java @@ -1978,15 +1978,13 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority // buf.append(' ').append(_context.blocklist().toStr(ip)); buf.append(""); - long idleIn = (now-peer.getLastReceiveTime())/1000; - long idleOut = (now-peer.getLastSendTime())/1000; - if (idleIn < 0) idleIn = 0; - if (idleOut < 0) idleOut = 0; + long idleIn = Math.max(now-peer.getLastReceiveTime(), 0); + long idleOut = Math.max(now-peer.getLastSendTime(), 0); buf.append(""); - buf.append(DataHelper.formatDuration2(1000 * idleIn)); + buf.append(DataHelper.formatDuration2(idleIn)); buf.append("&thinsp/ "); - buf.append(DataHelper.formatDuration2(1000 * idleOut)); + buf.append(DataHelper.formatDuration2(idleOut)); buf.append(""); int recvBps = (idleIn > 2 ? 0 : peer.getReceiveBps()); @@ -2010,7 +2008,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority buf.append(""); buf.append(""); - buf.append(DataHelper.formatDuration2(peer.getClockSkew())); + long skew = peer.getClockSkew(); + buf.append(formatDuration3(peer.getClockSkew())); buf.append(""); offsetTotal = offsetTotal + peer.getClockSkew(); @@ -2032,15 +2031,15 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority int rto = peer.getRTO(); buf.append(""); - buf.append(rtt); + buf.append(DataHelper.formatDuration2(rtt)); buf.append(""); buf.append(""); - buf.append(peer.getRTTDeviation()); + buf.append(DataHelper.formatDuration2(peer.getRTTDeviation())); buf.append(""); buf.append(""); - buf.append(rto); + buf.append(DataHelper.formatDuration2(rto)); buf.append(""); buf.append(""); @@ -2104,19 +2103,19 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority // buf.append("


\n"); buf.append(" ").append(_("SUMMARY")).append("" + ""); - buf.append(formatKBps(bpsIn)).append("thinsp;/ ").append(formatKBps(bpsOut)); + buf.append(formatKBps(bpsIn)).append(" / ").append(formatKBps(bpsOut)); long x = numPeers > 0 ? uptimeMsTotal/numPeers : 0; buf.append("" + "").append(DataHelper.formatDuration2(x)); x = numPeers > 0 ? offsetTotal/numPeers : 0; - buf.append("").append(DataHelper.formatDuration2(x)).append("\n" + + buf.append("").append(formatDuration3(x)).append("\n" + ""); buf.append(numPeers > 0 ? cwinTotal/(numPeers*1024) + "K" : "0K"); buf.append(" \n" + ""); - buf.append(numPeers > 0 ? rttTotal/numPeers : 0); + buf.append(numPeers > 0 ? DataHelper.formatDuration2(rttTotal/numPeers) : '0'); buf.append("  "); - buf.append(numPeers > 0 ? rtoTotal/numPeers : 0); + buf.append(numPeers > 0 ? DataHelper.formatDuration2(rtoTotal/numPeers) : '0'); buf.append("  "); buf.append(sendTotal).append(" ").append(recvTotal).append("\n" + "").append(resentTotal); @@ -2139,6 +2138,17 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority buf.setLength(0); } + /** + * @return e.g. 3 sec or -3 sec + * formatDuration2() always prints negative numbers in ms + * @since 0.8.2 + */ + private static String formatDuration3(long x) { + if (x >= 0) + return DataHelper.formatDuration2(x); + return "-" + DataHelper.formatDuration2(0 - x); + } + private static final DecimalFormat _fmt = new DecimalFormat("#,##0.00"); private static final String formatKBps(int bps) { synchronized (_fmt) {