* InboundMessageDistributor:

- Put garlicked DSM messages in the InNetMessagePool instead of handling directly,
     so the IterativeSearchJob will see the response and declare success.
     Only affected LS lookups as we do not request encrypted replies for RI lookups.
     Similar to the fix for verifies 6dc5bed94321ae2b290cfe351511d18465e08f91
     This bug was causing initial lookups to fail but subsequent ones to succeed.
     Broken since 0.9.7 when encrypted replies was introduced.
     Ticket #1125
This commit is contained in:
zzz
2013-11-14 17:39:31 +00:00
parent 19022baa27
commit ea7b42810f
3 changed files with 33 additions and 30 deletions

View File

@ -1,3 +1,6 @@
2013-11-14 zzz
* Tunnels: Fix reception of encrypted responses to LS lookups (ticket #1125)
2013-11-07 zzz
* i2psnark: Fix file links, broken in -12 (ticket #1114)
* Logging: Track duplicates across flush interval (ticket #1110)

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 25;
public final static long BUILD = 26;
/** for example "-test" */
public final static String EXTRA = "";

View File

@ -107,8 +107,8 @@ class InboundMessageDistributor implements GarlicMessageReceiver.CloveReceiver {
if (type == GarlicMessage.MESSAGE_TYPE) {
// in case we're looking for replies to a garlic message (cough load tests cough)
_context.inNetMessagePool().handleReplies(msg);
if (_log.shouldLog(Log.DEBUG))
_log.debug("received garlic message in the tunnel, parse it out");
//if (_log.shouldLog(Log.DEBUG))
// _log.debug("received garlic message in the tunnel, parse it out");
_receiver.receive((GarlicMessage)msg);
} else {
if (_log.shouldLog(Log.INFO))
@ -170,35 +170,29 @@ class InboundMessageDistributor implements GarlicMessageReceiver.CloveReceiver {
// since we don't want to republish (or flood)
// unnecessarily. Reply tokens ignored.
DatabaseStoreMessage dsm = (DatabaseStoreMessage)data;
try {
// Ensure the reply info is cleared, just in case
dsm.setReplyToken(0);
dsm.setReplyTunnel(null);
dsm.setReplyGateway(null);
if (dsm.getEntry().getType() == DatabaseEntry.KEY_TYPE_LEASESET) {
if (dsm.getKey().equals(_client)) {
// Case 1:
// store of our own LS.
// This is almost certainly a response to a FloodfillVerifyStoreJob search.
// We must send to the InNetMessagePool so the message can be matched
// and the verify marked as successful.
// Ensure the reply info is clear...
dsm.setReplyToken(0);
dsm.setReplyTunnel(null);
dsm.setReplyGateway(null);
// Case 2:
// Store of somebody else's LS.
// This could be an encrypted response to an IterativeSearchJob search.
// We must send to the InNetMessagePool so the message can be matched
// and the search marked as successful.
// Or, it's a normal LS bundled with data and a MessageStatusMessage.
// ... and inject it.
_context.inNetMessagePool().add(dsm, null, null);
} else {
// If it was stored to us before, don't undo the
// receivedAsPublished flag so we will continue to respond to requests
// for the leaseset. That is, we don't want this to change the
// RAP flag of the leaseset.
// When the keyspace rotates at midnight, and this leaseset moves out
// of our keyspace, maybe we shouldn't do this?
// Should we do this whether ff or not?
LeaseSet ls = (LeaseSet) dsm.getEntry();
LeaseSet old = _context.netDb().store(dsm.getKey(), ls);
if (old != null && old.getReceivedAsPublished()
/** && ((FloodfillNetworkDatabaseFacade)_context.netDb()).floodfillEnabled() **/ )
ls.setReceivedAsPublished(true);
if (_log.shouldLog(Log.INFO))
_log.info("Storing LS for: " + dsm.getKey() + " sent to: " + _client);
}
_log.info("Storing garlic LS down tunnel for: " + dsm.getKey() + " sent to: " + _client);
_context.inNetMessagePool().add(dsm, null, null);
} else {
if (_client != null) {
// drop it, since the data we receive shouldn't include router
@ -209,12 +203,18 @@ class InboundMessageDistributor implements GarlicMessageReceiver.CloveReceiver {
_log.error("Dropped dangerous message down a tunnel for " + _client + ": " + dsm, new Exception("cause"));
return;
}
_context.netDb().store(dsm.getKey(), (RouterInfo) dsm.getEntry());
// Case 3:
// Store of an RI (ours or somebody else's)
// This is almost certainly a response to an IterativeSearchJob search.
// We must send to the InNetMessagePool so the message can be matched
// and the search marked as successful.
// note that encrypted replies to RI lookups is currently disables in ISJ, we won't get here.
// ... and inject it.
if (_log.shouldLog(Log.INFO))
_log.info("Storing garlic RI down tunnel for: " + dsm.getKey() + " sent to: " + _client);
_context.inNetMessagePool().add(dsm, null, null);
}
} catch (IllegalArgumentException iae) {
if (_log.shouldLog(Log.WARN))
_log.warn("Bad store attempt", iae);
}
} else if (_client != null && type == DatabaseSearchReplyMessage.MESSAGE_TYPE &&
_client.equals(((DatabaseSearchReplyMessage) data).getSearchKey())) {
// DSRMs show up here now that replies are encrypted