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 26e03feff..d3c52a53f 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHandler.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHandler.java
@@ -66,8 +66,6 @@ public class ConfigNetHandler extends FormHandler {
}
public void setNtcpAutoPort(String mode) {
_ntcpAutoPort = mode.equals("2");
- if (mode.equals("0"))
- _ntcpInboundDisabled = true;
}
public void setUpnp(String moo) { _upnp = true; }
@@ -155,19 +153,14 @@ public class ConfigNetHandler extends FormHandler {
restartRequired = true;
}
if (oldAutoPort != _ntcpAutoPort || ! oldNPort.equals(_ntcpPort)) {
- if ( _ntcpAutoPort ) {
- _context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_AUTO_PORT, "true");
- _context.router().removeConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_PORT);
- addFormNotice("Updating inbound TCP port to auto");
- } else if (_ntcpPort.length() > 0) {
+ if (_ntcpPort.length() > 0 && !_ntcpAutoPort) {
_context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_PORT, _ntcpPort);
- _context.router().removeConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_AUTO_PORT);
addFormNotice("Updating inbound TCP port to " + _ntcpPort);
} else {
_context.router().removeConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_PORT);
- _context.router().removeConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_AUTO_PORT);
- addFormNotice("Disabling inbound TCP");
+ addFormNotice("Updating inbound TCP port to auto");
}
+ _context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_AUTO_PORT, "" + _ntcpAutoPort);
restartRequired = true;
}
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 2c90b805c..95a370efc 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java
@@ -103,10 +103,8 @@ public class ConfigNetHelper extends HelperBase {
return DISABLED;
String port = _context.getProperty(PROP_I2NP_NTCP_PORT);
boolean specified = port != null && port.length() > 0;
- boolean auto = Boolean.valueOf(_context.getProperty(PROP_I2NP_NTCP_AUTO_PORT)).booleanValue();
- if ((mode == 0 && (!specified) && !auto) ||
- (mode == 1 && specified && !auto) ||
- (mode == 2 && auto))
+ if ((mode == 1 && specified) ||
+ (mode == 2 && !specified))
return CHECKED;
return "";
}
diff --git a/apps/routerconsole/jsp/config.jsp b/apps/routerconsole/jsp/config.jsp
index 5eb809ed5..298414e22 100644
--- a/apps/routerconsole/jsp/config.jsp
+++ b/apps/routerconsole/jsp/config.jsp
@@ -125,8 +125,6 @@
(dyndns and the like are fine)
Externally reachable TCP port:
- />
- Disable
/>
Use the same port configured for SSU
(currently
diff --git a/router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java b/router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java
index 9060ede84..fa62fdc31 100644
--- a/router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java
+++ b/router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java
@@ -193,6 +193,9 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
public final static String PROP_I2NP_NTCP_AUTO_PORT = "i2np.ntcp.autoport";
public final static String PROP_I2NP_NTCP_AUTO_IP = "i2np.ntcp.autoip";
+ /**
+ * This should really be moved to ntcp/NTCPTransport.java, why is it here?
+ */
public static RouterAddress createNTCPAddress(RouterContext ctx) {
if (!TransportManager.enableNTCP(ctx)) return null;
RouterAddress addr = new RouterAddress();
@@ -236,6 +239,7 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
/**
* UDP changed addresses, tell NTCP and restart
+ * This should really be moved to ntcp/NTCPTransport.java, why is it here?
*/
@Override
public void notifyReplaceAddress(RouterAddress UDPAddr) {
@@ -249,7 +253,8 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
return;
Properties newProps;
RouterAddress oldAddr = t.getCurrentAddress();
- //_log.warn("Changing NTCP Address? was " + oldAddr);
+ if (_log.shouldLog(Log.INFO))
+ _log.info("Changing NTCP Address? was " + oldAddr);
RouterAddress newAddr = oldAddr;
if (newAddr == null) {
newAddr = new RouterAddress();
@@ -264,23 +269,27 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
}
boolean changed = false;
+ // old behavior (<= 0.7.3): auto-port defaults to false, and true trumps explicit setting
+ // new behavior (>= 0.7.4): auto-port defaults to true, but explicit setting trumps auto
String oport = newProps.getProperty(NTCPAddress.PROP_PORT);
- String enabled = _context.getProperty(PROP_I2NP_NTCP_AUTO_PORT, "false");
- if ( (enabled != null) && ("true".equalsIgnoreCase(enabled)) ) {
- String nport = UDPProps.getProperty(UDPAddress.PROP_PORT);
- if (nport == null || nport.length() <= 0)
- return;
- if (oport == null || ! oport.equals(nport)) {
- newProps.setProperty(NTCPAddress.PROP_PORT, nport);
- changed = true;
- }
- } else if (oport == null || oport.length() <= 0) {
+ String nport = null;
+ String cport = _context.getProperty(PROP_I2NP_NTCP_PORT);
+ if (cport != null && cport.length() > 0) {
+ nport = cport;
+ } else if (Boolean.valueOf(_context.getProperty(PROP_I2NP_NTCP_AUTO_PORT, "true")).booleanValue()) {
+ nport = UDPProps.getProperty(UDPAddress.PROP_PORT);
+ }
+ if (_log.shouldLog(Log.INFO))
+ _log.info("old: " + oport + " config: " + cport + " new: " + nport);
+ if (nport == null || nport.length() <= 0)
return;
+ if (oport == null || ! oport.equals(nport)) {
+ newProps.setProperty(NTCPAddress.PROP_PORT, nport);
+ changed = true;
}
String ohost = newProps.getProperty(NTCPAddress.PROP_HOST);
- enabled = _context.getProperty(PROP_I2NP_NTCP_AUTO_IP, "false");
- if ( (enabled != null) && ("true".equalsIgnoreCase(enabled)) ) {
+ if (Boolean.valueOf(_context.getProperty(PROP_I2NP_NTCP_AUTO_IP)).booleanValue()) {
String nhost = UDPProps.getProperty(UDPAddress.PROP_HOST);
if (nhost == null || nhost.length() <= 0)
return;
@@ -293,12 +302,16 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
}
if (!changed) {
- //_log.warn("No change to NTCP Address");
+ _log.warn("No change to NTCP Address");
return;
}
// stopListening stops the pumper, readers, and writers, so required even if
// oldAddr == null since startListening starts them all again
+ //
+ // really need to fix this so that we can change or create an inbound address
+ // without tearing down everything
+ //
_log.warn("Halting NTCP to change address");
t.stopListening();
newAddr.setOptions(newProps);