Skip to content

Commit

Permalink
clean up variable names and update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
eyedeekay committed May 30, 2023
1 parent 31a41da commit ed51f15
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 26 deletions.
5 changes: 5 additions & 0 deletions history.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2023-05-29 idk
* adds "virtual contexts" to bloom filter, where each entity that
passes an i2np message to the bloom filter xor's the messageID with a random, local value.
credit Xe Iaso for discovering the issue, obscuratus for the solution

2023-04-12 idk
* Fix missing Java options in docker/rootfs/startapp.sh
* Detect when running in Podman instead of regular Docker
Expand Down
2 changes: 1 addition & 1 deletion router/java/src/net/i2p/data/i2np/I2NPMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public interface I2NPMessage {
/**
* Replay resistant message ID
*/
public long getUniqueId(long msgIdBloomXor);
public long getUniqueId(long msgIDBloomXor);
public long getUniqueId();
public void setUniqueId(long id);

Expand Down
4 changes: 2 additions & 2 deletions router/java/src/net/i2p/data/i2np/I2NPMessageImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ public void writeBytes(OutputStream out) {
/**
* Replay resistant message Id
*/
public synchronized long getUniqueId(long msgIdBloomXor) {
return getUniqueId() ^ msgIdBloomXor;
public synchronized long getUniqueId(long msgIDBloomXor) {
return getUniqueId() ^ msgIDBloomXor;
}

public synchronized long getUniqueId() {
Expand Down
6 changes: 3 additions & 3 deletions router/java/src/net/i2p/router/TunnelPoolSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class TunnelPoolSettings {
private static final int MAX_PRIORITY = 25;
private static final int EXPLORATORY_PRIORITY = 30;

private final long _msgIdBloomXor;
private final long _msgIDBloomXor;

/**
* Exploratory tunnel
Expand Down Expand Up @@ -118,7 +118,7 @@ public TunnelPoolSettings(Hash dest, boolean isInbound) {
_IPRestriction = DEFAULT_IP_RESTRICTION;
_unknownOptions = new Properties();
_randomKey = generateRandomKey();
_msgIdBloomXor = RandomSource.getInstance().nextLong();
_msgIDBloomXor = RandomSource.getInstance().nextLong();

if (_isExploratory && !_isInbound)
_priority = EXPLORATORY_PRIORITY;
Expand Down Expand Up @@ -290,7 +290,7 @@ public void setAliasOf(Hash h) {
*/
public Properties getUnknownOptions() { return _unknownOptions; }

public long getMsgIdBloomXor() { return _msgIdBloomXor; }
public long getMsgIdBloomXor() { return _msgIDBloomXor; }

/**
* Defaults in props are NOT honored.
Expand Down
18 changes: 9 additions & 9 deletions router/java/src/net/i2p/router/message/SendMessageDirectJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class SendMessageDirectJob extends JobImpl {
private boolean _alreadySearched;
private boolean _sent;
private long _searchOn;
private final long _msgIdBloomXor;
private final long _msgIDBloomXor;

/**
* @param toPeer may be ourselves
Expand All @@ -53,10 +53,10 @@ public SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer,

/**
* @param toPeer may be ourselves
* @param msgIdBloomXor value to xor the messageID with before passing to the InNetMessagePool, may be 0
* @param msgIDBloomXor value to xor the messageID with before passing to the InNetMessagePool, may be 0
*/
public SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer, int timeoutMs, int priority, long msgIdBloomXor) {
this(ctx, message, toPeer, null, null, null, null, timeoutMs, priority, msgIdBloomXor);
public SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer, int timeoutMs, int priority, long msgIDBloomXor) {
this(ctx, message, toPeer, null, null, null, null, timeoutMs, priority, msgIDBloomXor);
}

/**
Expand All @@ -75,7 +75,7 @@ public SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer,
* @param onSuccess may be null
* @param onFail may be null
* @param selector be null
* @param msgIdBloomXor value to xor the messageID with before passing to the InNetMessagePool, may be 0
* @param msgIDBloomXor value to xor the messageID with before passing to the InNetMessagePool, may be 0
*/
public SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer, ReplyJob onSuccess,
Job onFail, MessageSelector selector, int timeoutMs, int priority, long msgIDBloomXor) {
Expand All @@ -88,13 +88,13 @@ public SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer,
* @param onSuccess may be null
* @param onFail may be null
* @param selector be null
* @param msgIdBloomXor value to xor the messageID with before passing to the InNetMessagePool, may be 0
* @param msgIDBloomXor value to xor the messageID with before passing to the InNetMessagePool, may be 0
*/
public SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer, Job onSend, ReplyJob onSuccess,
Job onFail, MessageSelector selector, int timeoutMs, int priority, long msgIdBloomXor) {
Job onFail, MessageSelector selector, int timeoutMs, int priority, long msgIDBloomXor) {
super(ctx);
_log = getContext().logManager().getLog(SendMessageDirectJob.class);
_msgIdBloomXor = msgIdBloomXor;
_msgIDBloomXor = msgIDBloomXor;
_message = message;
_targetHash = toPeer;
if (timeoutMs < 10*1000) {
Expand Down Expand Up @@ -182,7 +182,7 @@ private void send() {
if (_onSend != null)
getContext().jobQueue().addJob(_onSend);

getContext().inNetMessagePool().add(_message, _router.getIdentity(), null, _msgIdBloomXor);
getContext().inNetMessagePool().add(_message, _router.getIdentity(), null, _msgIDBloomXor);

if (_log.shouldLog(Log.DEBUG))
_log.debug("Adding " + _message.getClass().getName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public class TransportManager implements TransportEventListener {

private static final long UPNP_REFRESH_TIME = UPnP.LEASE_TIME_SECONDS * 1000L / 3;

private final long _msgIdBloomXor;
private final long _msgIDBloomXor;

public TransportManager(RouterContext context) {
_context = context;
Expand All @@ -136,7 +136,7 @@ public TransportManager(RouterContext context) {
_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();
}

/**
Expand Down Expand Up @@ -968,7 +968,7 @@ public void messageReceived(I2NPMessage message, RouterIdentity fromRouter, Hash
if (_log.shouldLog(Log.DEBUG))
_log.debug("I2NPMessage received: " + message.getClass().getSimpleName() /*, new Exception("Where did I come from again?") */ );
try {
_context.inNetMessagePool().add(message, fromRouter, fromRouterHash, _msgIdBloomXor);
_context.inNetMessagePool().add(message, fromRouter, fromRouterHash, _msgIDBloomXor);
//if (_log.shouldLog(Log.DEBUG))
// _log.debug("Added to in pool");
} catch (IllegalArgumentException iae) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class InboundMessageDistributor implements GarlicMessageReceiver.CloveReceiver {
private final Hash _client;
private final GarlicMessageReceiver _receiver;
private final String _clientNickname;
private final long _msgIdBloomXor;
private final long _msgIDBloomXor;
/**
* @param client null for router tunnel
*/
Expand All @@ -55,10 +55,10 @@ public InboundMessageDistributor(RouterContext ctx, Hash client) {
+ " b32: " + _client.toBase32()
+ ") InboundMessageDistributor with tunnel pool settings: " + clienttps);
_clientNickname = clienttps.getDestinationNickname();
_msgIdBloomXor = clienttps.getMsgIdBloomXor();
_msgIDBloomXor = clienttps.getMsgIdBloomXor();
} else {
_clientNickname = "NULL/Expl";
_msgIdBloomXor = new Random().nextLong();
_msgIDBloomXor = new Random().nextLong();
if (_log.shouldLog(Log.DEBUG))
_log.debug("Initializing null or exploratory InboundMessageDistributor");
}
Expand Down Expand Up @@ -217,7 +217,7 @@ public void distribute(I2NPMessage msg, Hash target, TunnelId tunnel) {
+ " (for client " + _clientNickname + " ("
+ ((_client != null) ? _client.toBase32() : "null")
+ ") to target=NULL/tunnel=NULL " + msg);
_context.inNetMessagePool().add(msg, null, null, _msgIdBloomXor);
_context.inNetMessagePool().add(msg, null, null, _msgIDBloomXor);
}
} else if (_context.routerHash().equals(target)) {
if (type == GarlicMessage.MESSAGE_TYPE)
Expand Down Expand Up @@ -291,7 +291,7 @@ public void handleClove(DeliveryInstructions instructions, I2NPMessage data) {
_log.info("Storing garlic LS down tunnel for: " + dsm.getKey() + " sent to: "
+ _clientNickname + " ("
+ (_client != null ? _client.toBase32() : ") router"));
_context.inNetMessagePool().add(dsm, null, null, _msgIdBloomXor);
_context.inNetMessagePool().add(dsm, null, null, _msgIDBloomXor);
} else {
if (_client != null) {
// drop it, since the data we receive shouldn't include router
Expand All @@ -313,7 +313,7 @@ public void handleClove(DeliveryInstructions instructions, I2NPMessage data) {
if (_log.shouldLog(Log.INFO))
_log.info("Storing garlic RI down tunnel (" + _clientNickname
+ ") for: " + dsm.getKey());
_context.inNetMessagePool().add(dsm, null, null, _msgIdBloomXor);
_context.inNetMessagePool().add(dsm, null, null, _msgIDBloomXor);
}
} else if (_client != null && type == DatabaseSearchReplyMessage.MESSAGE_TYPE) {
// DSRMs show up here now that replies are encrypted
Expand All @@ -332,7 +332,7 @@ public void handleClove(DeliveryInstructions instructions, I2NPMessage data) {
orig = newMsg;
}
****/
_context.inNetMessagePool().add(orig, null, null, _msgIdBloomXor);
_context.inNetMessagePool().add(orig, null, null, _msgIDBloomXor);
} else if (type == DataMessage.MESSAGE_TYPE) {
// a data message targetting the local router is how we send load tests (real
// data messages target destinations)
Expand All @@ -349,7 +349,7 @@ public void handleClove(DeliveryInstructions instructions, I2NPMessage data) {
+ _clientNickname + " (" + _client.toBase32() + ") : "
+ data, new Exception("cause"));
} else {
_context.inNetMessagePool().add(data, null, null, _msgIdBloomXor);
_context.inNetMessagePool().add(data, null, null, _msgIDBloomXor);
}
return;

Expand Down

0 comments on commit ed51f15

Please sign in to comment.