forked from I2P_Developers/i2p.i2p
Transports: New config option i2np.allowLocal,
replaces i2np.udp.allowLocal and i2np.ntcp.allowLocal, fixes test networks (ticket #1875)
This commit is contained in:
@ -193,8 +193,7 @@ public class MultiRouter {
|
||||
props.setProperty("i2np.udp.host", "127.0.0.1");
|
||||
props.setProperty("i2np.ntcp.port", BASE_PORT + id + "");
|
||||
props.setProperty("i2np.udp.port", BASE_PORT + id + "");
|
||||
props.setProperty("i2np.ntcp.allowLocal", "true");
|
||||
props.setProperty("i2np.udp.allowLocal", "true");
|
||||
props.setProperty("i2np.allowLocal", "true");
|
||||
props.setProperty("i2np.udp.internalPort", BASE_PORT + id + "");
|
||||
props.setProperty("i2cp.port", Integer.toString((BASE_PORT + nbrRouters + id)));
|
||||
|
||||
|
@ -943,6 +943,15 @@ public abstract class TransportImpl implements Transport {
|
||||
yes ? new Exception() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Are we allowed to connect to local addresses?
|
||||
*
|
||||
* @since 0.9.28 moved from UDPTransport
|
||||
*/
|
||||
protected boolean allowLocal() {
|
||||
return _context.getBooleanProperty("i2np.allowLocal");
|
||||
}
|
||||
|
||||
/**
|
||||
* IP of the peer from the last connection (in or out, any transport).
|
||||
*
|
||||
|
@ -13,6 +13,7 @@ import java.net.UnknownHostException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.data.router.RouterAddress;
|
||||
import net.i2p.router.RouterContext;
|
||||
|
||||
@ -131,6 +132,8 @@ public abstract class TransportUtil {
|
||||
* @since IPv6
|
||||
*/
|
||||
public static boolean isPubliclyRoutable(byte addr[], boolean allowIPv4, boolean allowIPv6) {
|
||||
if (I2PAppContext.getGlobalContext().getBooleanProperty("i2np.allowLocal"))
|
||||
return true;
|
||||
if (addr.length == 4) {
|
||||
if (!allowIPv4)
|
||||
return false;
|
||||
|
@ -436,7 +436,7 @@ public class NTCPTransport extends TransportImpl {
|
||||
continue;
|
||||
}
|
||||
if (!isValid(ip)) {
|
||||
if (! _context.getBooleanProperty("i2np.ntcp.allowLocal")) {
|
||||
if (! allowLocal()) {
|
||||
//_context.statManager().addRateData("ntcp.bidRejectedLocalAddress", 1);
|
||||
//if (_log.shouldLog(Log.DEBUG))
|
||||
// _log.debug("no bid when trying to send to " + peer + " as they have a private ntcp address");
|
||||
|
@ -1093,16 +1093,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
return true;
|
||||
return allowLocal();
|
||||
}
|
||||
|
||||
/**
|
||||
* Are we allowed to connect to local addresses?
|
||||
*
|
||||
* @since IPv6
|
||||
*/
|
||||
boolean allowLocal() {
|
||||
return _context.getBooleanProperty("i2np.udp.allowLocal");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Was true before 0.9.2
|
||||
* Now false if we need introducers (as perhaps that's why we need them,
|
||||
|
@ -64,8 +64,7 @@ public class SSUDemo {
|
||||
envProps.setProperty("time.disabled", "false");
|
||||
// allow 127.0.0.1/10.0.0.1/etc (useful for testing). If this is false,
|
||||
// peers who say they're on an invalid IP are banlisted
|
||||
envProps.setProperty("i2np.udp.allowLocal", "true");
|
||||
envProps.setProperty("i2np.ntcp.allowLocal", "true");
|
||||
envProps.setProperty("i2np.allowLocal", "true");
|
||||
// IPv6
|
||||
envProps.setProperty("i2np.udp.ipv6", "enable");
|
||||
envProps.setProperty("i2np.ntcp.ipv6", "enable");
|
||||
|
Reference in New Issue
Block a user