- Start to rework inbound configuration

This commit is contained in:
zzz
2009-04-28 22:45:26 +00:00
parent accf3dbf3f
commit fc10031ff0
3 changed files with 71 additions and 51 deletions

View File

@ -29,6 +29,7 @@ public class ConfigNetHandler extends FormHandler {
private String _udpPort;
private boolean _ntcpAutoIP;
private boolean _ntcpAutoPort;
private boolean _ntcpInboundDisabled;
private boolean _upnp;
private String _inboundRate;
private String _inboundBurstRate;
@ -58,8 +59,16 @@ public class ConfigNetHandler extends FormHandler {
public void setHiddenMode(String moo) { _hiddenMode = true; }
public void setDynamicKeys(String moo) { _dynamicKeys = true; }
public void setEnableloadtesting(String moo) { _enableLoadTesting = true; }
public void setNtcpAutoIP(String moo) { _ntcpAutoIP = true; }
public void setNtcpAutoPort(String moo) { _ntcpAutoPort = true; }
public void setNtcpAutoIP(String mode) {
_ntcpAutoIP = mode.equals("2");
if (mode.equals("0"))
_ntcpInboundDisabled = true;
}
public void setNtcpAutoPort(String mode) {
_ntcpAutoPort = mode.equals("2");
if (mode.equals("0"))
_ntcpInboundDisabled = true;
}
public void setUpnp(String moo) { _upnp = true; }
public void setHostname(String hostname) {
@ -122,8 +131,12 @@ public class ConfigNetHandler extends FormHandler {
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 (_ntcpHostname == null || _ntcpInboundDisabled) _ntcpHostname = "";
if (_ntcpPort == null || _ntcpInboundDisabled) _ntcpPort = "";
if (_ntcpInboundDisabled) {
_ntcpAutoIP = false;
_ntcpAutoPort = false;
}
if (oldAutoHost != _ntcpAutoIP || ! oldNHost.equalsIgnoreCase(_ntcpHostname)) {
if (_ntcpAutoIP) {
@ -162,6 +175,7 @@ public class ConfigNetHandler extends FormHandler {
String oldPort = "" + _context.getProperty(UDPTransport.PROP_INTERNAL_PORT, UDPTransport.DEFAULT_INTERNAL_PORT);
if (!oldPort.equals(_udpPort)) {
_context.router().setConfigSetting(UDPTransport.PROP_INTERNAL_PORT, _udpPort);
_context.router().setConfigSetting(UDPTransport.PROP_EXTERNAL_PORT, _udpPort);
addFormNotice("Updating UDP port from " + oldPort + " to " + _udpPort);
restartRequired = true;
}

View File

@ -18,6 +18,8 @@ public class ConfigNetHelper extends HelperBase {
public final static String PROP_I2NP_NTCP_PORT = "i2np.ntcp.port";
public final static String PROP_I2NP_NTCP_AUTO_PORT = "i2np.ntcp.autoport";
public final static String PROP_I2NP_NTCP_AUTO_IP = "i2np.ntcp.autoip";
private final static String CHECKED = " checked=\"true\" ";
private final static String DISABLED = " disabled=\"true\" ";
public String getNtcphostname() {
if (!TransportManager.enableNTCP(_context))
return "\" disabled=\"true";
@ -70,68 +72,64 @@ public class ConfigNetHelper extends HelperBase {
if ( (disabled != null) && ("true".equalsIgnoreCase(disabled)) )
return "";
else
return " checked ";
return CHECKED;
}
/** @param prop must default to false */
public String getChecked(String prop) {
if (Boolean.valueOf(_context.getProperty(prop)).booleanValue())
return CHECKED;
return "";
}
public String getHiddenModeChecked() {
String enabled = _context.getProperty(Router.PROP_HIDDEN, "false");
if ( (enabled != null) && ("true".equalsIgnoreCase(enabled)) )
return " checked ";
else
return "";
return getChecked(Router.PROP_HIDDEN);
}
public String getDynamicKeysChecked() {
String enabled = _context.getProperty(Router.PROP_DYNAMIC_KEYS, "false");
if ( (enabled != null) && ("true".equalsIgnoreCase(enabled)) )
return " checked ";
else
return "";
return getChecked(Router.PROP_DYNAMIC_KEYS);
}
public String getTcpAutoPortChecked() {
public String getTcpAutoPortChecked(int mode) {
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 ";
else
return "";
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))
return CHECKED;
return "";
}
public String getTcpAutoIPChecked() {
public String getTcpAutoIPChecked(int mode) {
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 ";
else
return "";
return DISABLED;
String hostname = _context.getProperty(PROP_I2NP_NTCP_HOSTNAME);
boolean specified = hostname != null && hostname.length() > 0;
boolean auto = Boolean.valueOf(_context.getProperty(PROP_I2NP_NTCP_AUTO_IP)).booleanValue();
if ((mode == 0 && (!specified) && !auto) ||
(mode == 1 && specified && !auto) ||
(mode == 2 && auto))
return CHECKED;
return "";
}
public String getUpnpChecked() {
if (Boolean.valueOf(_context.getProperty(TransportManager.PROP_ENABLE_UPNP)).booleanValue())
return " checked ";
else
return "";
return getChecked(TransportManager.PROP_ENABLE_UPNP);
}
public String getRequireIntroductionsChecked() {
short status = _context.commSystem().getReachabilityStatus();
switch (status) {
case CommSystemFacade.STATUS_OK:
if ("true".equalsIgnoreCase(_context.getProperty(UDPTransport.PROP_FORCE_INTRODUCERS, "false")))
return "checked=\"true\"";
return "";
case CommSystemFacade.STATUS_UNKNOWN:
return getChecked(UDPTransport.PROP_FORCE_INTRODUCERS);
case CommSystemFacade.STATUS_DIFFERENT:
case CommSystemFacade.STATUS_REJECT_UNSOLICITED:
return "checked=\"true\"";
case CommSystemFacade.STATUS_UNKNOWN:
if ("true".equalsIgnoreCase(_context.getProperty(UDPTransport.PROP_FORCE_INTRODUCERS, "false")))
return "checked=\"true\"";
return "";
default:
return "checked=\"true\"";
return CHECKED;
}
}
@ -191,7 +189,7 @@ public class ConfigNetHelper extends HelperBase {
public String getEnableLoadTesting() {
if (LoadTestManager.isEnabled(_context))
return " checked ";
return CHECKED;
else
return "";
}

View File

@ -83,18 +83,26 @@
<input type="submit" name="recheckReachability" value="Check network reachability..." />
<p>
<b>Inbound TCP connection configuration:</b><br />
Externally reachable hostname or IP address:
Externally reachable hostname or IP address:<br />
<input type="radio" name="ntcpAutoIP" value="0" <%=nethelper.getTcpAutoIPChecked(0) %> />
Disable<br />
<input type="radio" name="ntcpAutoIP" value="2" <%=nethelper.getTcpAutoIPChecked(2) %> />
Use IP address detected by SSU
(currently <jsp:getProperty name="nethelper" property="udpIP" />)<br />
<input type="radio" name="ntcpAutoIP" value="1" <%=nethelper.getTcpAutoIPChecked(1) %> />
Specify hostname or IP:
<input name ="ntcphost" type="text" size="16" value="<jsp:getProperty name="nethelper" property="ntcphostname" />" />
(dyndns and the like are fine)<br />
OR use IP address detected by SSU
(currently <jsp:getProperty name="nethelper" property="udpIP" />)?
<input type="checkbox" name="ntcpAutoIP" value="true" <jsp:getProperty name="nethelper" property="tcpAutoIPChecked" /> /><br />
<p>
Externally reachable TCP port:
Externally reachable TCP port:<br />
<input type="radio" name="ntcpAutoPort" value="0" <%=nethelper.getTcpAutoPortChecked(0) %> />
Disable<br />
<input type="radio" name="ntcpAutoPort" value="2" <%=nethelper.getTcpAutoPortChecked(2) %> />
Use the same port configured for SSU
(currently <jsp:getProperty name="nethelper" property="udpPort" />)?<br />
<input type="radio" name="ntcpAutoPort" value="1" <%=nethelper.getTcpAutoPortChecked(1) %> />
Specify Port:
<input name ="ntcpport" type="text" size="6" value="<jsp:getProperty name="nethelper" property="ntcpport" />" /><br />
OR use the same port configured for SSU
(currently <jsp:getProperty name="nethelper" property="udpPort" />)?
<input type="checkbox" name="ntcpAutoPort" value="true" <jsp:getProperty name="nethelper" property="tcpAutoPortChecked" /> /><br />
<p>A hostname entered here will be published in the network database.
It is <b>not private</b>.
Also, <b>do not enter a private IP address</b> like 127.0.0.1 or 192.168.1.1.