- Simplify config.jsp some more

- No longer use i2np.udp.forceIntroducers
- Tweak UDP port qualification
- Fix allowing low ports again
- Add option to completely disable NTCP, for those behind nasty firewalls
- Use SSU reachability rather than global reachability for determining NTCP reachability,
  since we are now reporting NTCP reachability too
This commit is contained in:
zzz
2009-05-06 00:54:24 +00:00
parent e82f173f85
commit 0b7fb21263
6 changed files with 49 additions and 32 deletions

View File

@@ -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);

View File

@@ -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";

View File

@@ -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()) );