- Add UDP Port configuration to config.jsp
- Don't restart router when configs change on config.jsp; simply rebuild router info. - Clean up some port config code in UDP
This commit is contained in:
@ -157,12 +157,9 @@ public class ConfigNetHandler extends FormHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( (_udpPort != null) && (_udpPort.length() > 0) ) {
|
if ( (_udpPort != null) && (_udpPort.length() > 0) ) {
|
||||||
String oldPort = _context.router().getConfigSetting(ConfigNetHelper.PROP_I2NP_UDP_PORT);
|
String oldPort = "" + _context.getProperty(UDPTransport.PROP_INTERNAL_PORT, UDPTransport.DEFAULT_INTERNAL_PORT);
|
||||||
if ( (oldPort == null) && (_udpPort.equals("8887")) ) {
|
if (!oldPort.equals(_udpPort)) {
|
||||||
// still on default.. noop
|
_context.router().setConfigSetting(UDPTransport.PROP_INTERNAL_PORT, _udpPort);
|
||||||
} else if ( (oldPort == null) || (!oldPort.equalsIgnoreCase(_udpPort)) ) {
|
|
||||||
// its not the default OR it has changed
|
|
||||||
_context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_UDP_PORT, _udpPort);
|
|
||||||
addFormNotice("Updating UDP port from " + oldPort + " to " + _udpPort);
|
addFormNotice("Updating UDP port from " + oldPort + " to " + _udpPort);
|
||||||
restartRequired = true;
|
restartRequired = true;
|
||||||
}
|
}
|
||||||
@ -229,9 +226,14 @@ public class ConfigNetHandler extends FormHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (restartRequired) {
|
if (restartRequired) {
|
||||||
addFormNotice("Performing a soft restart");
|
//addFormNotice("Performing a soft restart");
|
||||||
_context.router().restart();
|
//_context.router().restart();
|
||||||
addFormNotice("Soft restart complete");
|
//addFormNotice("Soft restart complete");
|
||||||
|
// Most of the time we aren't changing addresses, just enabling or disabling
|
||||||
|
// things, so let's try just a new routerInfo and see how that works.
|
||||||
|
// Maybe we should restart if we change addresses though?
|
||||||
|
_context.router().rebuildRouterInfo();
|
||||||
|
addFormNotice("Router Info rebuilt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,8 +14,6 @@ public class ConfigNetHelper extends HelperBase {
|
|||||||
public ConfigNetHelper() {}
|
public ConfigNetHelper() {}
|
||||||
|
|
||||||
/** copied from various private components */
|
/** 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 final static String PROP_I2NP_NTCP_HOSTNAME = "i2np.ntcp.hostname";
|
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_PORT = "i2np.ntcp.port";
|
||||||
public final static String PROP_I2NP_NTCP_AUTO_PORT = "i2np.ntcp.autoport";
|
public final static String PROP_I2NP_NTCP_AUTO_PORT = "i2np.ntcp.autoport";
|
||||||
@ -63,6 +61,10 @@ public class ConfigNetHelper extends HelperBase {
|
|||||||
return "" + ua.getPort();
|
return "" + ua.getPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getConfiguredUdpPort() {
|
||||||
|
return "" + _context.getProperty(UDPTransport.PROP_INTERNAL_PORT, UDPTransport.DEFAULT_INTERNAL_PORT);
|
||||||
|
}
|
||||||
|
|
||||||
public String getEnableTimeSyncChecked() {
|
public String getEnableTimeSyncChecked() {
|
||||||
String disabled = _context.getProperty(Timestamper.PROP_DISABLED, "false");
|
String disabled = _context.getProperty(Timestamper.PROP_DISABLED, "false");
|
||||||
if ( (disabled != null) && ("true".equalsIgnoreCase(disabled)) )
|
if ( (disabled != null) && ("true".equalsIgnoreCase(disabled)) )
|
||||||
|
@ -67,8 +67,11 @@
|
|||||||
<a href="oldstats.jsp#test.rtt">test.rtt</a> and related stats.</p>
|
<a href="oldstats.jsp#test.rtt">test.rtt</a> and related stats.</p>
|
||||||
<hr />
|
<hr />
|
||||||
-->
|
-->
|
||||||
<b>External UDP address:</b> <i><jsp:getProperty name="nethelper" property="udpAddress" /></i><br />
|
<b>UDP Configuration:</b><br />
|
||||||
<b>Require SSU introductions? </b>
|
Internal UDP port:
|
||||||
|
<input name ="udpPort" type="text" size="6" value="<jsp:getProperty name="nethelper" property="configuredUdpPort" />" /><br />
|
||||||
|
External UDP address: <i><jsp:getProperty name="nethelper" property="udpAddress" /></i><br />
|
||||||
|
Require SSU introductions?
|
||||||
<input type="checkbox" name="requireIntroductions" value="true" <jsp:getProperty name="nethelper" property="requireIntroductionsChecked" /> /><br />
|
<input type="checkbox" name="requireIntroductions" value="true" <jsp:getProperty name="nethelper" property="requireIntroductionsChecked" /> /><br />
|
||||||
<p>If you can, please poke a hole in your NAT or firewall to allow unsolicited UDP packets to reach
|
<p>If you can, please poke a hole in your NAT or firewall to allow unsolicited UDP packets to reach
|
||||||
you on your external UDP address. If you can't, I2P now includes supports UDP hole punching
|
you on your external UDP address. If you can't, I2P now includes supports UDP hole punching
|
||||||
|
@ -20,7 +20,7 @@ public class RouterVersion {
|
|||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 5;
|
public final static long BUILD = 5;
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "-upnp";
|
||||||
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;
|
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
System.out.println("I2P Router version: " + FULL_VERSION);
|
System.out.println("I2P Router version: " + FULL_VERSION);
|
||||||
|
@ -99,6 +99,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
|
|
||||||
public static final String STYLE = "SSU";
|
public static final String STYLE = "SSU";
|
||||||
public static final String PROP_INTERNAL_PORT = "i2np.udp.internalPort";
|
public static final String PROP_INTERNAL_PORT = "i2np.udp.internalPort";
|
||||||
|
public static final int DEFAULT_INTERNAL_PORT = 8887;
|
||||||
|
|
||||||
/** define this to explicitly set an external IP address */
|
/** define this to explicitly set an external IP address */
|
||||||
public static final String PROP_EXTERNAL_HOST = "i2np.udp.host";
|
public static final String PROP_EXTERNAL_HOST = "i2np.udp.host";
|
||||||
@ -215,20 +216,12 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
int port = -1;
|
int port = -1;
|
||||||
if (_externalListenPort <= 0) {
|
if (_externalListenPort <= 0) {
|
||||||
// no explicit external port, so lets try an internal one
|
// no explicit external port, so lets try an internal one
|
||||||
String portStr = _context.getProperty(PROP_INTERNAL_PORT);
|
port = _context.getProperty(PROP_INTERNAL_PORT, DEFAULT_INTERNAL_PORT);
|
||||||
if (portStr != null) {
|
|
||||||
try {
|
|
||||||
port = Integer.parseInt(portStr);
|
|
||||||
} catch (NumberFormatException nfe) {
|
|
||||||
if (_log.shouldLog(Log.ERROR))
|
|
||||||
_log.error("Invalid port specified [" + portStr + "]");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (port <= 0) {
|
if (port <= 0) {
|
||||||
port = 8887;
|
port = DEFAULT_INTERNAL_PORT;
|
||||||
//port = 1024 + _context.random().nextInt(31*1024);
|
//port = 1024 + _context.random().nextInt(31*1024);
|
||||||
if (_log.shouldLog(Log.INFO))
|
//if (_log.shouldLog(Log.INFO))
|
||||||
_log.info("Selecting an arbitrary port to bind to: " + port);
|
// _log.info("Selecting an arbitrary port to bind to: " + port);
|
||||||
_context.router().setConfigSetting(PROP_INTERNAL_PORT, port+"");
|
_context.router().setConfigSetting(PROP_INTERNAL_PORT, port+"");
|
||||||
}
|
}
|
||||||
// attempt to use it as our external port - this will be overridden by
|
// attempt to use it as our external port - this will be overridden by
|
||||||
@ -1013,14 +1006,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
void rebuildExternalAddress(boolean allowRebuildRouterInfo) {
|
void rebuildExternalAddress(boolean allowRebuildRouterInfo) {
|
||||||
// if the external port is specified, we want to use that to bind to even
|
// if the external port is specified, we want to use that to bind to even
|
||||||
// if we don't know the external host.
|
// if we don't know the external host.
|
||||||
String port = _context.getProperty(PROP_EXTERNAL_PORT);
|
_externalListenPort = _context.getProperty(PROP_EXTERNAL_PORT, -1);
|
||||||
if (port != null) {
|
|
||||||
try {
|
|
||||||
_externalListenPort = Integer.parseInt(port);
|
|
||||||
} catch (NumberFormatException nfe) {
|
|
||||||
_externalListenPort = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (explicitAddressSpecified()) {
|
if (explicitAddressSpecified()) {
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user