Merge branch '2.2.1-xormsgmask-mr' into 'master'

Router/Tunnel: Constrain xor message ID mask to >= 0

See merge request i2p-hackers/i2p.i2p!92
This commit is contained in:
idk
2023-06-11 02:05:56 +00:00
7 changed files with 11 additions and 9 deletions

View File

@ -8,6 +8,7 @@ import java.util.Properties;
import net.i2p.data.Base64;
import net.i2p.data.Hash;
import net.i2p.data.SessionKey;
import net.i2p.data.i2np.I2NPMessage;
import net.i2p.util.ConcurrentHashSet;
import net.i2p.util.NativeBigInteger;
import net.i2p.util.RandomSource;
@ -118,7 +119,7 @@ public class TunnelPoolSettings {
_IPRestriction = DEFAULT_IP_RESTRICTION;
_unknownOptions = new Properties();
_randomKey = generateRandomKey();
_msgIDBloomXor = RandomSource.getInstance().nextLong();
_msgIDBloomXor = RandomSource.getInstance().nextLong(I2NPMessage.MAX_ID_VALUE);
if (_isExploratory && !_isInbound)
_priority = EXPLORATORY_PRIORITY;

View File

@ -34,9 +34,9 @@ public class GarlicMessageHandler implements HandlerJobBuilder {
public GarlicMessageHandler(RouterContext context) {
_context = context;
_msgIDBloomXorLocal = RandomSource.getInstance().nextLong();
_msgIDBloomXorRouter = RandomSource.getInstance().nextLong();
_msgIDBloomXorTunnel = RandomSource.getInstance().nextLong();
_msgIDBloomXorLocal = RandomSource.getInstance().nextLong(I2NPMessage.MAX_ID_VALUE);
_msgIDBloomXorRouter = RandomSource.getInstance().nextLong(I2NPMessage.MAX_ID_VALUE);
_msgIDBloomXorTunnel = RandomSource.getInstance().nextLong(I2NPMessage.MAX_ID_VALUE);
}
public GarlicMessageHandler(RouterContext context, long msgIDBloomXorLocal, long msgIDBloomXorRouter, long msgIDBloomXorTunnel) {

View File

@ -26,7 +26,7 @@ public class FloodfillDatabaseLookupMessageHandler implements HandlerJobBuilder
private RouterContext _context;
private FloodfillNetworkDatabaseFacade _facade;
private Log _log;
private final long _msgIDBloomXor = RandomSource.getInstance().nextLong();
private final long _msgIDBloomXor = RandomSource.getInstance().nextLong(I2NPMessage.MAX_ID_VALUE);
public FloodfillDatabaseLookupMessageHandler(RouterContext context, FloodfillNetworkDatabaseFacade facade) {
_context = context;

View File

@ -24,7 +24,7 @@ import net.i2p.util.RandomSource;
public class FloodfillDatabaseStoreMessageHandler implements HandlerJobBuilder {
private RouterContext _context;
private FloodfillNetworkDatabaseFacade _facade;
private final long _msgIDBloomXor = RandomSource.getInstance().nextLong();
private final long _msgIDBloomXor = RandomSource.getInstance().nextLong(I2NPMessage.MAX_ID_VALUE);
public FloodfillDatabaseStoreMessageHandler(RouterContext context, FloodfillNetworkDatabaseFacade facade) {
_context = context;

View File

@ -13,6 +13,7 @@ import java.util.Set;
import net.i2p.data.Hash;
import net.i2p.data.router.RouterInfo;
import net.i2p.data.i2np.I2NPMessage;
import net.i2p.router.JobImpl;
import net.i2p.router.Router;
import net.i2p.router.RouterContext;
@ -59,7 +60,7 @@ class StartExplorersJob extends JobImpl {
private static final long MAX_LAG = 100;
private static final long MAX_MSG_DELAY = 1500;
private final long _msgIDBloomXor = RandomSource.getInstance().nextLong();
private final long _msgIDBloomXor = RandomSource.getInstance().nextLong(I2NPMessage.MAX_ID_VALUE);
public StartExplorersJob(RouterContext context, KademliaNetworkDatabaseFacade facade) {
super(context);

View File

@ -136,7 +136,7 @@ public class TransportManager implements TransportEventListener {
_dhThread = (_enableUDP || enableNTCP2) ? new DHSessionKeyBuilder.PrecalcRunner(context) : null;
// always created, even if NTCP2 is not enabled, because ratchet needs it
_xdhThread = new X25519KeyFactory(context);
_msgIDBloomXor = _context.random().nextLong();
_msgIDBloomXor = _context.random().nextLong(I2NPMessage.MAX_ID_VALUE);
}
/**

View File

@ -57,7 +57,7 @@ class InboundMessageDistributor implements GarlicMessageReceiver.CloveReceiver {
_msgIDBloomXor = clienttps.getMsgIdBloomXor();
} else {
_clientNickname = "NULL/Expl";
_msgIDBloomXor = RandomSource.getInstance().nextLong();
_msgIDBloomXor = RandomSource.getInstance().nextLong(I2NPMessage.MAX_ID_VALUE);
if (_log.shouldLog(Log.DEBUG))
_log.debug("Initializing null or exploratory InboundMessageDistributor");
}