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 bc50d65a42..51cd532928 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHandler.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHandler.java
@@ -41,6 +41,8 @@ public class ConfigNetHandler extends FormHandler {
private String _ntcpPort;
private String _tcpPort;
private String _udpPort;
+ private boolean _ntcpAutoIP;
+ private boolean _ntcpAutoPort;
private String _inboundRate;
private String _inboundBurstRate;
private String _inboundBurst;
@@ -70,6 +72,8 @@ public class ConfigNetHandler extends FormHandler {
public void setDynamicKeys(String moo) { _dynamicKeys = true; }
public void setUpdateratesonly(String moo) { _ratesOnly = true; }
public void setEnableloadtesting(String moo) { _enableLoadTesting = true; }
+ public void setNtcpAutoIP(String moo) { _ntcpAutoIP = true; }
+ public void setNtcpAutoPort(String moo) { _ntcpAutoPort = true; }
public void setHostname(String hostname) {
_hostname = (hostname != null ? hostname.trim() : null);
@@ -142,27 +146,49 @@ public class ConfigNetHandler extends FormHandler {
}
}
- if ( (_ntcpHostname != null) && (_ntcpHostname.length() > 0) && (_ntcpPort != null) && (_ntcpPort.length() > 0) ) {
- String oldHost = _context.router().getConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME);
- String oldPort = _context.router().getConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_PORT);
- if ( (oldHost == null) || (!oldHost.equalsIgnoreCase(_ntcpHostname)) ||
- (oldPort == null) || (!oldPort.equalsIgnoreCase(_ntcpPort)) ) {
- _context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME, _ntcpHostname);
- _context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_PORT, _ntcpPort);
- addFormNotice("Updating inbound TCP settings from " + oldHost + ":" + oldPort
- + " to " + _ntcpHostname + ":" + _ntcpPort);
- restartRequired = true;
- }
- } else {
- String oldHost = _context.router().getConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME);
- String oldPort = _context.router().getConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_PORT);
- if ( (oldHost != null) || (oldPort != null) ) {
+ // 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 = "";
+ String oldNPort = _context.router().getConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_PORT);
+ if (oldNPort == null) oldNPort = "";
+ String sAutoHost = _context.router().getConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_AUTO_IP);
+ String sAutoPort = _context.router().getConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_AUTO_PORT);
+ boolean oldAutoHost = "true".equalsIgnoreCase(sAutoHost);
+ boolean oldAutoPort = "true".equalsIgnoreCase(sAutoPort);
+ if (_ntcpHostname == null) _ntcpHostname = "";
+ if (_ntcpPort == null) _ntcpPort = "";
+
+ if (oldAutoHost != _ntcpAutoIP || ! oldNHost.equalsIgnoreCase(_ntcpHostname)) {
+ if (_ntcpAutoIP) {
+ _context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_AUTO_IP, "true");
_context.router().removeConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME);
- _context.router().removeConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_PORT);
- addFormNotice("Updating inbound TCP settings from " + oldHost + ":" + oldPort
- + " so that we no longer receive inbound TCP connections");
- restartRequired = true;
+ addFormNotice("Updating inbound TCP address to auto");
+ } else if (_ntcpHostname.length() > 0) {
+ _context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME, _ntcpHostname);
+ _context.router().removeConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_AUTO_IP);
+ addFormNotice("Updating inbound TCP address to " + _ntcpHostname);
+ } else {
+ _context.router().removeConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME);
+ _context.router().removeConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_AUTO_IP);
+ addFormNotice("Disabling inbound TCP");
}
+ 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) {
+ _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");
+ }
+ restartRequired = true;
}
if ( (_udpPort != null) && (_udpPort.length() > 0) ) {
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 3058b973b7..c0c918314a 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java
@@ -50,6 +50,8 @@ public class ConfigNetHelper {
}
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() {
String hostname = _context.getProperty(PROP_I2NP_NTCP_HOSTNAME);
if (hostname == null) return "";
@@ -69,6 +71,26 @@ public class ConfigNetHelper {
return ua.toString();
}
+ public String getUdpIP() {
+ RouterAddress addr = _context.router().getRouterInfo().getTargetAddress("SSU");
+ if (addr == null)
+ return "unknown";
+ UDPAddress ua = new UDPAddress(addr);
+ if (ua.getHost() == null)
+ return "unknown";
+ return ua.getHost();
+ }
+
+ public String getUdpPort() {
+ RouterAddress addr = _context.router().getRouterInfo().getTargetAddress("SSU");
+ if (addr == null)
+ return "unknown";
+ UDPAddress ua = new UDPAddress(addr);
+ if (ua.getPort() <= 0)
+ return "unknown";
+ return "" + ua.getPort();
+ }
+
public String getEnableTimeSyncChecked() {
String disabled = _context.getProperty(Timestamper.PROP_DISABLED, "false");
if ( (disabled != null) && ("true".equalsIgnoreCase(disabled)) )
@@ -93,6 +115,22 @@ public class ConfigNetHelper {
return "";
}
+ public String getTcpAutoPortChecked() {
+ String enabled = _context.getProperty(PROP_I2NP_NTCP_AUTO_PORT, "false");
+ if ( (enabled != null) && ("true".equalsIgnoreCase(enabled)) )
+ return " checked ";
+ else
+ return "";
+ }
+
+ public String getTcpAutoIPChecked() {
+ String enabled = _context.getProperty(PROP_I2NP_NTCP_AUTO_IP, "false");
+ if ( (enabled != null) && ("true".equalsIgnoreCase(enabled)) )
+ return " checked ";
+ else
+ return "";
+ }
+
public String getRequireIntroductionsChecked() {
short status = _context.commSystem().getReachabilityStatus();
switch (status) {
diff --git a/apps/routerconsole/jsp/config.jsp b/apps/routerconsole/jsp/config.jsp
index dc18a101bf..20726de147 100644
--- a/apps/routerconsole/jsp/config.jsp
+++ b/apps/routerconsole/jsp/config.jsp
@@ -82,14 +82,21 @@
Externally reachable hostname or IP address:
" />
(dyndns and the like are fine)
+ OR use IP address detected by SSU
+ (currently
+
Externally reachable TCP port:
" />
+ OR use the same port configured for SSU
+ (currently
You do not need to allow inbound TCP connections - outbound connections work with no configuration. However, if you want to receive inbound TCP connections, you must poke a hole in your NAT or firewall for unsolicited TCP connections. If you specify the wrong IP address or hostname, or do not properly configure your NAT or firewall, your network performance will degrade substantially. When in doubt, leave the hostname and port number blank.
-Note: changing this setting will terminate all of your connections and effectively +
Note: changing any of these settings will terminate all of your connections and effectively restart your router.