- Implement UPnP enable/disable
This commit is contained in:
@ -4,6 +4,7 @@ import net.i2p.data.RouterInfo;
|
|||||||
import net.i2p.router.LoadTestManager;
|
import net.i2p.router.LoadTestManager;
|
||||||
import net.i2p.router.Router;
|
import net.i2p.router.Router;
|
||||||
import net.i2p.router.transport.FIFOBandwidthRefiller;
|
import net.i2p.router.transport.FIFOBandwidthRefiller;
|
||||||
|
import net.i2p.router.transport.TransportManager;
|
||||||
import net.i2p.router.transport.udp.UDPTransport;
|
import net.i2p.router.transport.udp.UDPTransport;
|
||||||
import net.i2p.router.web.ConfigServiceHandler.UpdateWrapperManagerAndRekeyTask;
|
import net.i2p.router.web.ConfigServiceHandler.UpdateWrapperManagerAndRekeyTask;
|
||||||
import net.i2p.time.Timestamper;
|
import net.i2p.time.Timestamper;
|
||||||
@ -28,6 +29,7 @@ public class ConfigNetHandler extends FormHandler {
|
|||||||
private String _udpPort;
|
private String _udpPort;
|
||||||
private boolean _ntcpAutoIP;
|
private boolean _ntcpAutoIP;
|
||||||
private boolean _ntcpAutoPort;
|
private boolean _ntcpAutoPort;
|
||||||
|
private boolean _upnp;
|
||||||
private String _inboundRate;
|
private String _inboundRate;
|
||||||
private String _inboundBurstRate;
|
private String _inboundBurstRate;
|
||||||
private String _inboundBurst;
|
private String _inboundBurst;
|
||||||
@ -37,7 +39,7 @@ public class ConfigNetHandler extends FormHandler {
|
|||||||
private String _reseedFrom;
|
private String _reseedFrom;
|
||||||
private boolean _enableLoadTesting;
|
private boolean _enableLoadTesting;
|
||||||
private String _sharePct;
|
private String _sharePct;
|
||||||
private boolean _ratesOnly;
|
private boolean _ratesOnly; // always false
|
||||||
|
|
||||||
protected void processForm() {
|
protected void processForm() {
|
||||||
if (_saveRequested || ( (_action != null) && ("Save changes".equals(_action)) )) {
|
if (_saveRequested || ( (_action != null) && ("Save changes".equals(_action)) )) {
|
||||||
@ -55,10 +57,10 @@ public class ConfigNetHandler extends FormHandler {
|
|||||||
public void setRequireIntroductions(String moo) { _requireIntroductions = true; }
|
public void setRequireIntroductions(String moo) { _requireIntroductions = true; }
|
||||||
public void setHiddenMode(String moo) { _hiddenMode = true; }
|
public void setHiddenMode(String moo) { _hiddenMode = true; }
|
||||||
public void setDynamicKeys(String moo) { _dynamicKeys = true; }
|
public void setDynamicKeys(String moo) { _dynamicKeys = true; }
|
||||||
public void setUpdateratesonly(String moo) { _ratesOnly = true; }
|
|
||||||
public void setEnableloadtesting(String moo) { _enableLoadTesting = true; }
|
public void setEnableloadtesting(String moo) { _enableLoadTesting = true; }
|
||||||
public void setNtcpAutoIP(String moo) { _ntcpAutoIP = true; }
|
public void setNtcpAutoIP(String moo) { _ntcpAutoIP = true; }
|
||||||
public void setNtcpAutoPort(String moo) { _ntcpAutoPort = true; }
|
public void setNtcpAutoPort(String moo) { _ntcpAutoPort = true; }
|
||||||
|
public void setUpnp(String moo) { _upnp = true; }
|
||||||
|
|
||||||
public void setHostname(String hostname) {
|
public void setHostname(String hostname) {
|
||||||
_hostname = (hostname != null ? hostname.trim() : null);
|
_hostname = (hostname != null ? hostname.trim() : null);
|
||||||
@ -194,11 +196,16 @@ public class ConfigNetHandler extends FormHandler {
|
|||||||
hiddenSwitch();
|
hiddenSwitch();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_dynamicKeys) {
|
_context.router().setConfigSetting(Router.PROP_DYNAMIC_KEYS, "" + _dynamicKeys);
|
||||||
_context.router().setConfigSetting(Router.PROP_DYNAMIC_KEYS, "true");
|
|
||||||
} else {
|
if (Boolean.valueOf(_context.getProperty(TransportManager.PROP_ENABLE_UPNP)).booleanValue() !=
|
||||||
_context.router().removeConfigSetting(Router.PROP_DYNAMIC_KEYS);
|
_upnp) {
|
||||||
|
if (_upnp)
|
||||||
|
addFormNotice("Enabling UPnP, restart required to take effect");
|
||||||
|
else
|
||||||
|
addFormNotice("Disabling UPnP, restart required to take effect");
|
||||||
}
|
}
|
||||||
|
_context.router().setConfigSetting(TransportManager.PROP_ENABLE_UPNP, "" + _upnp);
|
||||||
|
|
||||||
if (_requireIntroductions) {
|
if (_requireIntroductions) {
|
||||||
_context.router().setConfigSetting(UDPTransport.PROP_FORCE_INTRODUCERS, "true");
|
_context.router().setConfigSetting(UDPTransport.PROP_FORCE_INTRODUCERS, "true");
|
||||||
@ -207,12 +214,8 @@ public class ConfigNetHandler extends FormHandler {
|
|||||||
_context.router().removeConfigSetting(UDPTransport.PROP_FORCE_INTRODUCERS);
|
_context.router().removeConfigSetting(UDPTransport.PROP_FORCE_INTRODUCERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (true || _timeSyncEnabled) {
|
// Time sync enable, means NOT disabled
|
||||||
// Time sync enable, means NOT disabled
|
_context.router().setConfigSetting(Timestamper.PROP_DISABLED, "false");
|
||||||
_context.router().setConfigSetting(Timestamper.PROP_DISABLED, "false");
|
|
||||||
} else {
|
|
||||||
_context.router().setConfigSetting(Timestamper.PROP_DISABLED, "true");
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadTestManager.setEnableLoadTesting(_context, _enableLoadTesting);
|
LoadTestManager.setEnableLoadTesting(_context, _enableLoadTesting);
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,13 @@ public class ConfigNetHelper extends HelperBase {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getUpnpChecked() {
|
||||||
|
if (Boolean.valueOf(_context.getProperty(TransportManager.PROP_ENABLE_UPNP)).booleanValue())
|
||||||
|
return " checked ";
|
||||||
|
else
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
public String getRequireIntroductionsChecked() {
|
public String getRequireIntroductionsChecked() {
|
||||||
short status = _context.commSystem().getReachabilityStatus();
|
short status = _context.commSystem().getReachabilityStatus();
|
||||||
switch (status) {
|
switch (status) {
|
||||||
|
@ -104,6 +104,11 @@
|
|||||||
in your NAT or firewall for unsolicited TCP connections. If you specify the wrong IP address or
|
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
|
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.</p>
|
substantially. When in doubt, leave the hostname and port number blank.</p>
|
||||||
|
<p>
|
||||||
|
<b>UPnP Configuration:</b><br />
|
||||||
|
Open firewall port using UPnP:
|
||||||
|
<input type="checkbox" name="upnp" value="true" <jsp:getProperty name="nethelper" property="upnpChecked" /> /><br />
|
||||||
|
</p>
|
||||||
<p><b>Note: changing any of these settings will terminate all of your connections and effectively
|
<p><b>Note: changing any of these settings will terminate all of your connections and effectively
|
||||||
restart your router.</b>
|
restart your router.</b>
|
||||||
</p>
|
</p>
|
||||||
|
@ -41,6 +41,7 @@ public class TransportManager implements TransportEventListener {
|
|||||||
private final static String PROP_ENABLE_NTCP = "i2np.ntcp.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_NTCP = "true";
|
||||||
private final static String DEFAULT_ENABLE_UDP = "true";
|
private final static String DEFAULT_ENABLE_UDP = "true";
|
||||||
|
public final static String PROP_ENABLE_UPNP = "i2np.upnp.enable";
|
||||||
|
|
||||||
public TransportManager(RouterContext context) {
|
public TransportManager(RouterContext context) {
|
||||||
_context = context;
|
_context = context;
|
||||||
@ -52,7 +53,8 @@ public class TransportManager implements TransportEventListener {
|
|||||||
_context.statManager().createRateStat("transport.bidFailNoTransports", "Could not attempt to bid on message, as none of the transports could attempt it", "Transport", new long[] { 60*1000, 10*60*1000, 60*60*1000 });
|
_context.statManager().createRateStat("transport.bidFailNoTransports", "Could not attempt to bid on message, as none of the transports could attempt it", "Transport", new long[] { 60*1000, 10*60*1000, 60*60*1000 });
|
||||||
_context.statManager().createRateStat("transport.bidFailAllTransports", "Could not attempt to bid on message, as all of the transports had failed", "Transport", new long[] { 60*1000, 10*60*1000, 60*60*1000 });
|
_context.statManager().createRateStat("transport.bidFailAllTransports", "Could not attempt to bid on message, as all of the transports had failed", "Transport", new long[] { 60*1000, 10*60*1000, 60*60*1000 });
|
||||||
_transports = new ArrayList();
|
_transports = new ArrayList();
|
||||||
_upnpManager = new UPnPManager(context);
|
if (Boolean.valueOf(_context.getProperty(PROP_ENABLE_UPNP)).booleanValue())
|
||||||
|
_upnpManager = new UPnPManager(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTransport(Transport transport) {
|
public void addTransport(Transport transport) {
|
||||||
@ -93,7 +95,8 @@ public class TransportManager implements TransportEventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void startListening() {
|
public void startListening() {
|
||||||
_upnpManager.start();
|
if (_upnpManager != null)
|
||||||
|
_upnpManager.start();
|
||||||
configTransports();
|
configTransports();
|
||||||
_log.debug("Starting up the transport manager");
|
_log.debug("Starting up the transport manager");
|
||||||
for (int i = 0; i < _transports.size(); i++) {
|
for (int i = 0; i < _transports.size(); i++) {
|
||||||
@ -112,7 +115,8 @@ public class TransportManager implements TransportEventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void stopListening() {
|
public void stopListening() {
|
||||||
_upnpManager.stop();
|
if (_upnpManager != null)
|
||||||
|
_upnpManager.stop();
|
||||||
for (int i = 0; i < _transports.size(); i++) {
|
for (int i = 0; i < _transports.size(); i++) {
|
||||||
((Transport)_transports.get(i)).stopListening();
|
((Transport)_transports.get(i)).stopListening();
|
||||||
}
|
}
|
||||||
@ -359,7 +363,8 @@ public class TransportManager implements TransportEventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void transportAddressChanged() {
|
public void transportAddressChanged() {
|
||||||
_upnpManager.update(getAddresses());
|
if (_upnpManager != null)
|
||||||
|
_upnpManager.update(getAddresses());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getMostRecentErrorMessages() {
|
public List getMostRecentErrorMessages() {
|
||||||
@ -392,7 +397,8 @@ public class TransportManager implements TransportEventListener {
|
|||||||
}
|
}
|
||||||
buf.append("</pre>\n");
|
buf.append("</pre>\n");
|
||||||
out.write(buf.toString());
|
out.write(buf.toString());
|
||||||
out.write(_upnpManager.renderStatusHTML());
|
if (_upnpManager != null)
|
||||||
|
out.write(_upnpManager.renderStatusHTML());
|
||||||
buf.append("</p>\n");
|
buf.append("</p>\n");
|
||||||
out.flush();
|
out.flush();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user