diff --git a/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigNetHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigNetHandler.java index bcac4198f..be2ed8a0f 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigNetHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigNetHandler.java @@ -43,11 +43,11 @@ public class ConfigNetHandler extends FormHandler { private boolean _upnp; private boolean _laptop; private String _inboundRate; - private String _inboundBurstRate; - private String _inboundBurst; + //private String _inboundBurstRate; + //private String _inboundBurst; private String _outboundRate; - private String _outboundBurstRate; - private String _outboundBurst; + //private String _outboundBurstRate; + //private String _outboundBurst; private String _sharePct; private boolean _ratesOnly; private boolean _udpDisabled; @@ -114,21 +114,29 @@ public class ConfigNetHandler extends FormHandler { public void setInboundrate(String rate) { _inboundRate = (rate != null ? rate.trim() : null); } + +/* public void setInboundburstrate(String rate) { _inboundBurstRate = (rate != null ? rate.trim() : null); } public void setInboundburstfactor(String factor) { _inboundBurst = (factor != null ? factor.trim() : null); } +****/ + public void setOutboundrate(String rate) { _outboundRate = (rate != null ? rate.trim() : null); } + +/* public void setOutboundburstrate(String rate) { _outboundBurstRate = (rate != null ? rate.trim() : null); } public void setOutboundburstfactor(String factor) { _outboundBurst = (factor != null ? factor.trim() : null); } +****/ + public void setSharePercentage(String pct) { _sharePct = (pct != null ? pct.trim() : null); } @@ -487,28 +495,38 @@ public class ConfigNetHandler extends FormHandler { } } - // Since burst is now hidden in the gui, set burst to +10% for 20 seconds + // Since burst is now hidden in the gui, set burst to +10% for 20 seconds (prior to 0.9.33) + // As of 0.9.33, we set strict bandwidth limits. Specified rate is the burst rate, + // and we set the standard rate to 50KB or 10% lower (whichever is less). if ( (_inboundRate != null) && (_inboundRate.length() > 0) && - !_inboundRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH, "" + FIFOBandwidthRefiller.DEFAULT_INBOUND_BANDWIDTH))) { - changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH, _inboundRate); + !_inboundRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH, + Integer.toString(FIFOBandwidthRefiller.DEFAULT_INBOUND_BURST_BANDWIDTH)))) { try { - int rate = Integer.parseInt(_inboundRate) * (100 + DEF_BURST_PCT) / 100; + int rate = Integer.parseInt(_inboundRate); int kb = DEF_BURST_TIME * rate; - changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH, "" + rate); - changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH_PEAK, "" + kb); - } catch (NumberFormatException nfe) {} - bwUpdated = true; + changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH, Integer.toString(rate)); + changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH_PEAK, Integer.toString(kb)); + rate -= Math.min(rate * DEF_BURST_PCT / 100, 50); + changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH, Integer.toString(rate)); + bwUpdated = true; + } catch (NumberFormatException nfe) { + addFormError(_t("Invalid bandwidth")); + } } if ( (_outboundRate != null) && (_outboundRate.length() > 0) && - !_outboundRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH, "" + FIFOBandwidthRefiller.DEFAULT_OUTBOUND_BANDWIDTH))) { - changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH, _outboundRate); + !_outboundRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH, + Integer.toString(FIFOBandwidthRefiller.DEFAULT_OUTBOUND_BURST_BANDWIDTH)))) { try { - int rate = Integer.parseInt(_outboundRate) * (100 + DEF_BURST_PCT) / 100; + int rate = Integer.parseInt(_outboundRate); int kb = DEF_BURST_TIME * rate; - changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH, "" + rate); - changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH_PEAK, "" + kb); - } catch (NumberFormatException nfe) {} - bwUpdated = true; + changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH, Integer.toString(rate)); + changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH_PEAK, Integer.toString(kb)); + rate -= Math.min(rate * DEF_BURST_PCT / 100, 50); + changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH, Integer.toString(rate)); + bwUpdated = true; + } catch (NumberFormatException nfe) { + addFormError(_t("Invalid bandwidth")); + } } if (bwUpdated) { diff --git a/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigNetHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigNetHelper.java index f1593d488..150311423 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigNetHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigNetHelper.java @@ -235,17 +235,21 @@ public class ConfigNetHelper extends HelperBase { } public String getInboundRate() { - return "" + _context.bandwidthLimiter().getInboundKBytesPerSecond(); + return Integer.toString(_context.bandwidthLimiter().getInboundKBytesPerSecond()); } + public String getOutboundRate() { - return "" + _context.bandwidthLimiter().getOutboundKBytesPerSecond(); + return Integer.toString(_context.bandwidthLimiter().getOutboundKBytesPerSecond()); } - public String getInboundRateBits() { - return kbytesToBits(_context.bandwidthLimiter().getInboundKBytesPerSecond()); + + public String getInboundBurstRateBits() { + return kbytesToBits(_context.bandwidthLimiter().getInboundBurstKBytesPerSecond()); } - public String getOutboundRateBits() { - return kbytesToBits(_context.bandwidthLimiter().getOutboundKBytesPerSecond()); + + public String getOutboundBurstRateBits() { + return kbytesToBits(_context.bandwidthLimiter().getOutboundBurstKBytesPerSecond()); } + public String getShareRateBits() { return kbytesToBits(getShareBandwidth()); } @@ -253,12 +257,16 @@ public class ConfigNetHelper extends HelperBase { return DataHelper.formatSize(kbytes * (8 * 1024L)) + ' ' + _t("bits per second") + ' ' + _t("or {0} bytes per month maximum", DataHelper.formatSize(kbytes * (1024L * 60 * 60 * 24 * 31))); } + public String getInboundBurstRate() { - return "" + _context.bandwidthLimiter().getInboundBurstKBytesPerSecond(); + return Integer.toString(_context.bandwidthLimiter().getInboundBurstKBytesPerSecond()); } + public String getOutboundBurstRate() { - return "" + _context.bandwidthLimiter().getOutboundBurstKBytesPerSecond(); + return Integer.toString(_context.bandwidthLimiter().getOutboundBurstKBytesPerSecond()); } + +/* public String getInboundBurstFactorBox() { int numSeconds = 1; int rateKBps = _context.bandwidthLimiter().getInboundBurstKBytesPerSecond(); @@ -301,10 +309,10 @@ public class ConfigNetHelper extends HelperBase { return buf.toString(); } - /** removed */ public String getEnableLoadTesting() { return ""; } +****/ public String getSharePercentageBox() { int pct = (int) (100 * _context.router().getSharePercentage()); diff --git a/apps/routerconsole/jsp/config.jsp b/apps/routerconsole/jsp/config.jsp index aba7eb471..4e0149e0c 100644 --- a/apps/routerconsole/jsp/config.jsp +++ b/apps/routerconsole/jsp/config.jsp @@ -30,21 +30,23 @@ <%=intl._t("I2P will work best if you configure your rates to match the speed of your internet connection.")%> - " > +<%-- display burst, set standard, handler will fix up --%> + " > <%=intl._t("KBps In")%> - () -<% /******** + () +<%-- -*********/ %> +--%> - " > +<%-- display burst, set standard, handler will fix up --%> + " > <%=intl._t("KBps Out")%> - () -<% /******** + () +<%-- -*********/ %> +--%> <%=intl._t("Share")%> () diff --git a/router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java b/router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java index a936043b3..5ab204560 100644 --- a/router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java +++ b/router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java @@ -233,6 +233,8 @@ public class FIFOBandwidthRefiller implements Runnable { if (_inboundBurstKBytesPerSecond <= 0) _inboundBurstKBytesPerSecond = DEFAULT_INBOUND_BURST_BANDWIDTH; + if (_inboundBurstKBytesPerSecond < _inboundKBytesPerSecond) + _inboundBurstKBytesPerSecond = _inboundKBytesPerSecond; _limiter.setInboundBurstKBps(_inboundBurstKBytesPerSecond); } @@ -250,6 +252,8 @@ public class FIFOBandwidthRefiller implements Runnable { if (_outboundBurstKBytesPerSecond <= 0) _outboundBurstKBytesPerSecond = DEFAULT_OUTBOUND_BURST_BANDWIDTH; + if (_outboundBurstKBytesPerSecond < _outboundKBytesPerSecond) + _outboundBurstKBytesPerSecond = _outboundKBytesPerSecond; _limiter.setOutboundBurstKBps(_outboundBurstKBytesPerSecond); }