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 93f709732..ea4d6b03b 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHandler.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHandler.java
@@ -163,7 +163,9 @@ public class ConfigNetHandler extends FormHandler {
if (_ntcpAutoIP == null) _ntcpAutoIP = "true";
if ((!oldAutoHost.equals(_ntcpAutoIP)) || ! oldNHost.equalsIgnoreCase(_ntcpHostname)) {
- if ("false".equals(_ntcpAutoIP) && _ntcpHostname.length() > 0) {
+ if ("disabled".equals(_ntcpAutoIP)) {
+ addFormNotice("Disabling TCP completely");
+ } else if ("false".equals(_ntcpAutoIP) && _ntcpHostname.length() > 0) {
_context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME, _ntcpHostname);
addFormNotice("Updating inbound TCP address to " + _ntcpHostname);
} else {
@@ -174,6 +176,7 @@ public class ConfigNetHandler extends FormHandler {
addFormNotice("Updating inbound TCP address to auto"); // true or always
}
_context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_AUTO_IP, _ntcpAutoIP);
+ _context.router().setConfigSetting(TransportManager.PROP_ENABLE_NTCP, "" + !"disabled".equals(_ntcpAutoIP));
restartRequired = true;
}
if (oldAutoPort != _ntcpAutoPort || ! oldNPort.equals(_ntcpPort)) {
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 151581848..8c25af8f4 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java
@@ -28,14 +28,10 @@ public class ConfigNetHelper extends HelperBase {
}
public String getNtcphostname() {
- if (!TransportManager.enableNTCP(_context))
- return "\" disabled=\"true";
return _context.getProperty(PROP_I2NP_NTCP_HOSTNAME, "");
}
public String getNtcpport() {
- if (!TransportManager.enableNTCP(_context))
- return "\" disabled=\"true";
return _context.getProperty(PROP_I2NP_NTCP_PORT, "");
}
@@ -91,8 +87,6 @@ public class ConfigNetHelper extends HelperBase {
}
public String getTcpAutoPortChecked(int mode) {
- if (!TransportManager.enableNTCP(_context))
- return DISABLED;
String port = _context.getProperty(PROP_I2NP_NTCP_PORT);
boolean specified = port != null && port.length() > 0;
if ((mode == 1 && specified) ||
@@ -102,17 +96,15 @@ public class ConfigNetHelper extends HelperBase {
}
public String getTcpAutoIPChecked(int mode) {
- if (!TransportManager.enableNTCP(_context))
- return DISABLED;
+ boolean enabled = TransportManager.enableNTCP(_context);
String hostname = _context.getProperty(PROP_I2NP_NTCP_HOSTNAME);
boolean specified = hostname != null && hostname.length() > 0;
- String auto = _context.getProperty(PROP_I2NP_NTCP_AUTO_IP);
- if (auto == null)
- auto = "false";
- if ((mode == 0 && (!specified) && auto.equals("false")) ||
- (mode == 1 && specified && auto.equals("false")) ||
- (mode == 2 && auto.equals("true")) ||
- (mode == 3 && auto.equals("always")))
+ String auto = _context.getProperty(PROP_I2NP_NTCP_AUTO_IP, "false");
+ if ((mode == 0 && (!specified) && auto.equals("false") && enabled) ||
+ (mode == 1 && specified && auto.equals("false") && enabled) ||
+ (mode == 2 && auto.equals("true") && enabled) ||
+ (mode == 3 && auto.equals("always") && enabled) ||
+ (mode == 4 && !enabled))
return CHECKED;
return "";
}
diff --git a/apps/routerconsole/jsp/config.jsp b/apps/routerconsole/jsp/config.jsp
index 51255b214..c5c579f77 100644
--- a/apps/routerconsole/jsp/config.jsp
+++ b/apps/routerconsole/jsp/config.jsp
@@ -111,15 +111,17 @@
Hidden mode - do not publish IP(not recommended; change restarts router)
UDP Configuration:
- Internal UDP port:
+ UDP port:
" />
+
- Inbound TCP Configuration:
+ TCP Configuration:
Externally reachable hostname or IP address:
/>
Use auto-detected IP address
@@ -128,11 +130,12 @@
/>
Always use auto-detected IP address (Not firewalled)
/>
- Disable (Firewalled)
+ Disable inbound (Firewalled)
/>
Specify hostname or IP:
- " />
-
+ " />
+ />
+ Completely disable (select only if behind a firewall that throttles or blocks outbound TCP - restart required)
Externally reachable TCP port:
/>
@@ -152,9 +155,11 @@
with "SSU introductions" - peers who will relay a request from someone you don't know to your
router for your router so that you can make an outbound connection to them. I2P will use these
introductions automatically if it detects that the port is not forwarded (as shown by
- the Reachability: Firewalled line), or you can manually require them here.
+ the Reachability: Firewalled line).
Users behind symmetric NATs, such as OpenBSD's pf, are not currently supported.
Hostnames entered here will be published in the network database. They are not private. Also, do not enter a private IP address like 127.0.0.1 or 192.168.1.1. diff --git a/router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java b/router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java index ce8c6fb29..871c9eb4c 100644 --- a/router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java +++ b/router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java @@ -27,6 +27,7 @@ import net.i2p.router.RouterContext; import net.i2p.router.transport.ntcp.NTCPAddress; import net.i2p.router.transport.ntcp.NTCPTransport; import net.i2p.router.transport.udp.UDPAddress; +import net.i2p.router.transport.udp.UDPTransport; import net.i2p.util.Log; public class CommSystemFacadeImpl extends CommSystemFacade { @@ -151,8 +152,8 @@ public class CommSystemFacadeImpl extends CommSystemFacade { @Override public short getReachabilityStatus() { - if (_manager == null) return CommSystemFacade.STATUS_UNKNOWN; - if (_context.router().isHidden()) return CommSystemFacade.STATUS_OK; + if (_manager == null) return STATUS_UNKNOWN; + if (_context.router().isHidden()) return STATUS_OK; return _manager.getReachabilityStatus(); } @Override @@ -303,10 +304,14 @@ public class CommSystemFacadeImpl extends CommSystemFacade { String name = _context.getProperty(PROP_I2NP_NTCP_HOSTNAME); if (name != null && name.length() > 0) enabled = "false"; + Transport udp = _manager.getTransport(UDPTransport.STYLE); + short status = STATUS_UNKNOWN; + if (udp != null) + status = udp.getReachabilityStatus(); if (_log.shouldLog(Log.INFO)) - _log.info("old: " + ohost + " config: " + name + " auto: " + enabled + " status: " + getReachabilityStatus()); + _log.info("old: " + ohost + " config: " + name + " auto: " + enabled + " status: " + status); if (enabled.equalsIgnoreCase("always") || - (enabled.equalsIgnoreCase("true") && getReachabilityStatus() == CommSystemFacade.STATUS_OK)) { + (enabled.equalsIgnoreCase("true") && status == STATUS_OK)) { String nhost = UDPProps.getProperty(UDPAddress.PROP_HOST); if (_log.shouldLog(Log.INFO)) _log.info("old: " + ohost + " config: " + name + " new: " + nhost); diff --git a/router/java/src/net/i2p/router/transport/TransportManager.java b/router/java/src/net/i2p/router/transport/TransportManager.java index 40b23e062..291e2f6c1 100644 --- a/router/java/src/net/i2p/router/transport/TransportManager.java +++ b/router/java/src/net/i2p/router/transport/TransportManager.java @@ -40,10 +40,10 @@ public class TransportManager implements TransportEventListener { private RouterContext _context; private UPnPManager _upnpManager; - private final static String PROP_ENABLE_UDP = "i2np.udp.enable"; - private final static String PROP_ENABLE_NTCP = "i2np.ntcp.enable"; - private final static String DEFAULT_ENABLE_NTCP = "true"; - private final static String DEFAULT_ENABLE_UDP = "true"; + public final static String PROP_ENABLE_UDP = "i2np.udp.enable"; + public final static String PROP_ENABLE_NTCP = "i2np.ntcp.enable"; + public final static String DEFAULT_ENABLE_NTCP = "true"; + public final static String DEFAULT_ENABLE_UDP = "true"; /** default true */ public final static String PROP_ENABLE_UPNP = "i2np.upnp.enable"; 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 ee9c7d9b7..720eaed46 100644 --- a/router/java/src/net/i2p/router/transport/udp/UDPTransport.java +++ b/router/java/src/net/i2p/router/transport/udp/UDPTransport.java @@ -100,6 +100,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority public static final String STYLE = "SSU"; public static final String PROP_INTERNAL_PORT = "i2np.udp.internalPort"; public static final int DEFAULT_INTERNAL_PORT = 8887; + /** since fixed port defaults to true, this doesnt do anything at the moment. + * We should have an exception if it matches the existing low port. */ private static final int MIN_EXTERNAL_PORT = 1024; /** define this to explicitly set an external IP address */ @@ -386,7 +388,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority * @param ourPort >= 1024 */ void externalAddressReceived(Hash from, byte ourIP[], int ourPort) { - boolean isValid = isValid(ourIP) && ourPort >= MIN_EXTERNAL_PORT; + boolean isValid = isValid(ourIP) && + (ourPort >= MIN_EXTERNAL_PORT || ourPort == _externalListenPort || _externalListenPort <= 0); boolean explicitSpecified = explicitAddressSpecified(); boolean inboundRecent = _lastInboundReceivedOn + ALLOW_IP_CHANGE_INTERVAL > System.currentTimeMillis(); if (_log.shouldLog(Log.INFO)) @@ -422,6 +425,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority * @param ourPort >= 1024 or 0 for no change */ private boolean changeAddress(byte ourIP[], int ourPort) { + /** this defaults to true, which means we never change our external port based on what somebody tells us */ boolean fixedPort = getIsPortFixed(); boolean updated = false; boolean fireTest = false; @@ -437,9 +441,10 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority _log.info("Trying to change our external address..."); try { _externalListenHost = InetAddress.getByAddress(ourIP); + // fixed port defaults to true so we never do this if (ourPort >= MIN_EXTERNAL_PORT && !fixedPort) _externalListenPort = ourPort; - if (_externalListenPort >= MIN_EXTERNAL_PORT) { + if (_externalListenPort > 0) { rebuildExternalAddress(); replaceAddress(_externalAddress); updated = true; @@ -1171,12 +1176,18 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority } public boolean introducersRequired() { + /****************** + * Don't do this anymore, as we are removing the checkbox from the UI, + * and we rarely if ever see the problem of false negatives for firewall detection - + * it's usually false positives. + ****************** String forceIntroducers = _context.getProperty(PROP_FORCE_INTRODUCERS); if ( (forceIntroducers != null) && (Boolean.valueOf(forceIntroducers).booleanValue()) ) { if (_log.shouldLog(Log.INFO)) _log.info("Force introducers specified"); return true; } + *******************/ short status = getReachabilityStatus(); switch (status) { case CommSystemFacade.STATUS_REJECT_UNSOLICITED: @@ -1194,6 +1205,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority } } + /** default true */ private boolean allowDirectUDP() { String allowDirect = _context.getProperty(PROP_ALLOW_DIRECT); return ( (allowDirect == null) || (Boolean.valueOf(allowDirect).booleanValue()) );