diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHandler.java
index 38d9b2074..0ddcd58a9 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHandler.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHandler.java
@@ -3,6 +3,7 @@ package net.i2p.router.web;
import net.i2p.data.RouterInfo;
import net.i2p.router.LoadTestManager;
import net.i2p.router.Router;
+import net.i2p.router.transport.FIFOBandwidthRefiller;
import net.i2p.router.transport.udp.UDPTransport;
import net.i2p.router.web.ConfigServiceHandler.UpdateWrapperManagerAndRekeyTask;
import net.i2p.time.Timestamper;
@@ -110,26 +111,6 @@ public class ConfigNetHandler extends FormHandler {
boolean restartRequired = false;
if (!_ratesOnly) {
- if ( (_hostname != null) && (_hostname.length() > 0) ) {
- String oldHost = _context.router().getConfigSetting(ConfigNetHelper.PROP_I2NP_TCP_HOSTNAME);
- if ( (oldHost == null) || (!oldHost.equalsIgnoreCase(_hostname)) ) {
- _context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_TCP_HOSTNAME, _hostname);
- addFormNotice("Updating hostname from " + oldHost + " to " + _hostname);
- restartRequired = true;
- }
- }
- if ( (_tcpPort != null) && (_tcpPort.length() > 0) ) {
- String oldPort = _context.router().getConfigSetting(ConfigNetHelper.PROP_I2NP_TCP_PORT);
- if ( (oldPort == null) && (_tcpPort.equals("8887")) ) {
- // still on default.. noop
- } else if ( (oldPort == null) || (!oldPort.equalsIgnoreCase(_tcpPort)) ) {
- // its not the default OR it has changed
- _context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_TCP_PORT, _tcpPort);
- addFormNotice("Updating TCP port from " + oldPort + " to " + _tcpPort);
- restartRequired = true;
- }
- }
-
// Normalize some things to make the following code a little easier...
String oldNHost = _context.router().getConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME);
if (oldNHost == null) oldNHost = "";
@@ -181,7 +162,7 @@ public class ConfigNetHandler extends FormHandler {
// still on default.. noop
} else if ( (oldPort == null) || (!oldPort.equalsIgnoreCase(_udpPort)) ) {
// its not the default OR it has changed
- _context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_TCP_PORT, _udpPort);
+ _context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_UDP_PORT, _udpPort);
addFormNotice("Updating UDP port from " + oldPort + " to " + _udpPort);
restartRequired = true;
}
@@ -193,9 +174,9 @@ public class ConfigNetHandler extends FormHandler {
if (!_ratesOnly) {
if (_sharePct != null) {
- String old = _context.router().getConfigSetting(ConfigNetHelper.PROP_SHARE_PERCENTAGE);
+ String old = _context.router().getConfigSetting(Router.PROP_BANDWIDTH_SHARE_PERCENTAGE);
if ( (old == null) || (!old.equalsIgnoreCase(_sharePct)) ) {
- _context.router().setConfigSetting(ConfigNetHelper.PROP_SHARE_PERCENTAGE, _sharePct);
+ _context.router().setConfigSetting(Router.PROP_BANDWIDTH_SHARE_PERCENTAGE, _sharePct);
addFormNotice("Updating bandwidth share percentage");
}
}
@@ -263,23 +244,23 @@ public class ConfigNetHandler extends FormHandler {
private void updateRates() {
boolean updated = false;
if ( (_inboundRate != null) && (_inboundRate.length() > 0) ) {
- _context.router().setConfigSetting(ConfigNetHelper.PROP_INBOUND_KBPS, _inboundRate);
+ _context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH, _inboundRate);
updated = true;
}
if ( (_outboundRate != null) && (_outboundRate.length() > 0) ) {
- _context.router().setConfigSetting(ConfigNetHelper.PROP_OUTBOUND_KBPS, _outboundRate);
+ _context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH, _outboundRate);
updated = true;
}
if ( (_inboundBurstRate != null) && (_inboundBurstRate.length() > 0) ) {
- _context.router().setConfigSetting(ConfigNetHelper.PROP_INBOUND_BURST_KBPS, _inboundBurstRate);
+ _context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH, _inboundBurstRate);
updated = true;
}
if ( (_outboundBurstRate != null) && (_outboundBurstRate.length() > 0) ) {
- _context.router().setConfigSetting(ConfigNetHelper.PROP_OUTBOUND_BURST_KBPS, _outboundBurstRate);
+ _context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH, _outboundBurstRate);
updated = true;
}
- String inBurstRate = _context.router().getConfigSetting(ConfigNetHelper.PROP_INBOUND_BURST_KBPS);
+ String inBurstRate = _context.router().getConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH);
if (_inboundBurst != null) {
int rateKBps = 0;
@@ -292,12 +273,12 @@ public class ConfigNetHandler extends FormHandler {
}
if ( (rateKBps > 0) && (burstSeconds > 0) ) {
int kb = rateKBps * burstSeconds;
- _context.router().setConfigSetting(ConfigNetHelper.PROP_INBOUND_BURST, "" + kb);
+ _context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH_PEAK, "" + kb);
updated = true;
}
}
- String outBurstRate = _context.router().getConfigSetting(ConfigNetHelper.PROP_OUTBOUND_BURST_KBPS);
+ String outBurstRate = _context.router().getConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH);
if (_outboundBurst != null) {
int rateKBps = 0;
@@ -310,12 +291,13 @@ public class ConfigNetHandler extends FormHandler {
}
if ( (rateKBps > 0) && (burstSeconds > 0) ) {
int kb = rateKBps * burstSeconds;
- _context.router().setConfigSetting(ConfigNetHelper.PROP_OUTBOUND_BURST, "" + kb);
+ _context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH_PEAK, "" + kb);
updated = true;
}
}
if (updated && !_ratesOnly)
+ _context.bandwidthLimiter().reinitialize();
addFormNotice("Updated bandwidth limits");
}
}
diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java
index 0b6a7b65d..b648d9607 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java
@@ -5,6 +5,7 @@ import net.i2p.router.CommSystemFacade;
import net.i2p.router.LoadTestManager;
import net.i2p.router.Router;
import net.i2p.router.RouterContext;
+import net.i2p.router.transport.TransportManager;
import net.i2p.router.transport.udp.UDPAddress;
import net.i2p.router.transport.udp.UDPTransport;
import net.i2p.time.Timestamper;
@@ -27,37 +28,23 @@ public class ConfigNetHelper {
public ConfigNetHelper() {}
- /** copied from various private TCP components */
- public final static String PROP_I2NP_TCP_HOSTNAME = "i2np.tcp.hostname";
- public final static String PROP_I2NP_TCP_PORT = "i2np.tcp.port";
+ /** copied from various private components */
public final static String PROP_I2NP_UDP_PORT = "i2np.udp.port";
public final static String PROP_I2NP_INTERNAL_UDP_PORT = "i2np.udp.internalPort";
-
- public String getHostname() {
- return _context.getProperty(PROP_I2NP_TCP_HOSTNAME);
- }
- public String getTcpPort() {
- int port = 8887;
- String val = _context.getProperty(PROP_I2NP_TCP_PORT);
- if (val != null) {
- try {
- port = Integer.parseInt(val);
- } catch (NumberFormatException nfe) {
- // ignore, use default from above
- }
- }
- return "" + port;
- }
public final static String PROP_I2NP_NTCP_HOSTNAME = "i2np.ntcp.hostname";
public final static String PROP_I2NP_NTCP_PORT = "i2np.ntcp.port";
public final static String PROP_I2NP_NTCP_AUTO_PORT = "i2np.ntcp.autoip";
public final static String PROP_I2NP_NTCP_AUTO_IP = "i2np.ntcp.autoport";
public String getNtcphostname() {
+ if (!TransportManager.enableNTCP(_context))
+ return "\" disabled=\"true";
String hostname = _context.getProperty(PROP_I2NP_NTCP_HOSTNAME);
if (hostname == null) return "";
return hostname;
}
public String getNtcpport() {
+ if (!TransportManager.enableNTCP(_context))
+ return "\" disabled=\"true";
String port = _context.getProperty(PROP_I2NP_NTCP_PORT);
if (port == null) return "";
return port;
@@ -116,6 +103,8 @@ public class ConfigNetHelper {
}
public String getTcpAutoPortChecked() {
+ if (!TransportManager.enableNTCP(_context))
+ return " disabled=\"true\" ";
String enabled = _context.getProperty(PROP_I2NP_NTCP_AUTO_PORT, "false");
if ( (enabled != null) && ("true".equalsIgnoreCase(enabled)) )
return " checked ";
@@ -124,6 +113,8 @@ public class ConfigNetHelper {
}
public String getTcpAutoIPChecked() {
+ if (!TransportManager.enableNTCP(_context))
+ return " disabled=\"true\" ";
String enabled = _context.getProperty(PROP_I2NP_NTCP_AUTO_IP, "false");
if ( (enabled != null) && ("true".equalsIgnoreCase(enabled)) )
return " checked ";
@@ -150,80 +141,33 @@ public class ConfigNetHelper {
}
}
- public static final String PROP_INBOUND_KBPS = "i2np.bandwidth.inboundKBytesPerSecond";
- public static final String PROP_OUTBOUND_KBPS = "i2np.bandwidth.outboundKBytesPerSecond";
- public static final String PROP_INBOUND_BURST_KBPS = "i2np.bandwidth.inboundBurstKBytesPerSecond";
- public static final String PROP_OUTBOUND_BURST_KBPS = "i2np.bandwidth.outboundBurstKBytesPerSecond";
- public static final String PROP_INBOUND_BURST = "i2np.bandwidth.inboundBurstKBytes";
- public static final String PROP_OUTBOUND_BURST = "i2np.bandwidth.outboundBurstKBytes";
- public static final String PROP_SHARE_PERCENTAGE = "router.sharePercentage";
- public static final int DEFAULT_SHARE_PERCENTAGE = 80;
-
public String getInboundRate() {
- String rate = _context.getProperty(PROP_INBOUND_KBPS);
- if (rate != null)
- return rate;
- else
- return "32";
+ return "" + _context.bandwidthLimiter().getInboundKBytesPerSecond();
}
public String getOutboundRate() {
- String rate = _context.getProperty(PROP_OUTBOUND_KBPS);
- if (rate != null)
- return rate;
- else
- return "16";
+ return "" + _context.bandwidthLimiter().getOutboundKBytesPerSecond();
}
public String getInboundBurstRate() {
- String rate = _context.getProperty(PROP_INBOUND_BURST_KBPS);
- if (rate != null)
- return rate;
- else
- return "48";
+ return "" + _context.bandwidthLimiter().getInboundBurstKBytesPerSecond();
}
public String getOutboundBurstRate() {
- String rate = _context.getProperty(PROP_OUTBOUND_BURST_KBPS);
- if (rate != null)
- return rate;
- else
- return "32";
+ return "" + _context.bandwidthLimiter().getOutboundBurstKBytesPerSecond();
}
public String getInboundBurstFactorBox() {
- String rate = _context.getProperty(PROP_INBOUND_BURST_KBPS);
- String burst = _context.getProperty(PROP_INBOUND_BURST);
int numSeconds = 1;
- if ( (burst != null) && (rate != null) ) {
- int rateKBps = 0;
- int burstKB = 0;
- try {
- rateKBps = Integer.parseInt(rate);
- burstKB = Integer.parseInt(burst);
- } catch (NumberFormatException nfe) {
- // ignore
- }
- if ( (rateKBps > 0) && (burstKB > 0) ) {
- numSeconds = burstKB / rateKBps;
- }
- }
+ int rateKBps = _context.bandwidthLimiter().getInboundBurstKBytesPerSecond();
+ int burstKB = _context.bandwidthLimiter().getInboundBurstBytes() * 1024;
+ if ( (rateKBps > 0) && (burstKB > 0) )
+ numSeconds = burstKB / rateKBps;
return getBurstFactor(numSeconds, "inboundburstfactor");
}
public String getOutboundBurstFactorBox() {
- String rate = _context.getProperty(PROP_OUTBOUND_BURST_KBPS);
- String burst = _context.getProperty(PROP_OUTBOUND_BURST);
int numSeconds = 1;
- if ( (burst != null) && (rate != null) ) {
- int rateKBps = 0;
- int burstKB = 0;
- try {
- rateKBps = Integer.parseInt(rate);
- burstKB = Integer.parseInt(burst);
- } catch (NumberFormatException nfe) {
- // ignore
- }
- if ( (rateKBps > 0) && (burstKB > 0) ) {
- numSeconds = burstKB / rateKBps;
- }
- }
+ int rateKBps = _context.bandwidthLimiter().getOutboundBurstKBytesPerSecond();
+ int burstKB = _context.bandwidthLimiter().getOutboundBurstBytes() * 1024;
+ if ( (rateKBps > 0) && (burstKB > 0) )
+ numSeconds = burstKB / rateKBps;
return getBurstFactor(numSeconds, "outboundburstfactor");
}
@@ -254,43 +198,36 @@ public class ConfigNetHelper {
}
public String getSharePercentageBox() {
- String pctStr = _context.getProperty(PROP_SHARE_PERCENTAGE);
- int pct = DEFAULT_SHARE_PERCENTAGE;
- if (pctStr != null)
- try { pct = Integer.parseInt(pctStr); } catch (NumberFormatException nfe) {}
+ int pct = (int) (100 * _context.router().getSharePercentage());
StringBuffer buf = new StringBuffer(256);
buf.append("\n");
return buf.toString();
}
+ public static final int DEFAULT_SHARE_KBPS = 12;
public int getShareBandwidth() {
- String irate = _context.getProperty(PROP_INBOUND_KBPS, "32");
- String orate = _context.getProperty(PROP_OUTBOUND_KBPS, "16");
- String pctStr = _context.getProperty(PROP_SHARE_PERCENTAGE, "" + DEFAULT_SHARE_PERCENTAGE);
- if ( (irate != null) && (orate != null) && (pctStr != null)) {
- try {
- int irateKBps = Integer.parseInt(irate);
- int orateKBps = Integer.parseInt(orate);
- if (irateKBps < 0 || orateKBps < 0)
- return 12;
- int pct = Integer.parseInt(pctStr);
- return (int) (((float) pct) * Math.min(irateKBps, orateKBps) / 100);
- } catch (NumberFormatException nfe) {
- // ignore
- }
- }
- return 12;
+ int irateKBps = _context.bandwidthLimiter().getInboundKBytesPerSecond();
+ int orateKBps = _context.bandwidthLimiter().getOutboundKBytesPerSecond();
+ double pct = _context.router().getSharePercentage();
+ if (irateKBps < 0 || orateKBps < 0)
+ return DEFAULT_SHARE_KBPS;
+ return (int) (pct * Math.min(irateKBps, orateKBps));
}
}
diff --git a/apps/routerconsole/java/src/net/i2p/router/web/SummaryHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/SummaryHelper.java
index e728086be..279650ebb 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/SummaryHelper.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/SummaryHelper.java
@@ -143,6 +143,14 @@ public class SummaryHelper {
return "ERR-UDP Port In Use - Set i2np.udp.internalPort=xxxx in advanced config and restart";
case CommSystemFacade.STATUS_UNKNOWN: // fallthrough
default:
+ ra = _context.router().getRouterInfo().getTargetAddress("UDP");
+ if (ra == null) {
+ if (_context.getProperty(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME) == null ||
+ _context.getProperty(ConfigNetHelper.PROP_I2NP_NTCP_PORT) == null)
+ return "ERR-UDP Disabled and Inbound TCP host/port not set";
+ else
+ return "WARN-Firewalled with UDP Disabled";
+ }
return "Testing";
}
}
diff --git a/apps/routerconsole/jsp/config.jsp b/apps/routerconsole/jsp/config.jsp
index 058229b2a..0d9573fe6 100644
--- a/apps/routerconsole/jsp/config.jsp
+++ b/apps/routerconsole/jsp/config.jsp
@@ -40,8 +40,7 @@
" /> KBps for
KBps = kilobytes per second = 1024 bytes per second = 8192 bits per second.
- A negative inbound rate means a default limit of 32KBytes per second.
- A negative outbound rate means a default limit of 16KBytes per second.
+ A negative rate sets the default.
Bandwidth share percentage:
<% int share = nethelper.getShareBandwidth();
@@ -130,6 +129,11 @@
your UDP port is firewalled, and therefore it is likely that your TCP port is firewalled as well.
If your TCP port is firewalled with inbound TCP enabled, routers will not be able to contact
you via TCP, which will hurt the network. Please open your firewall or disable inbound TCP above.
+