* InboundMessageDistributor: Set reply flag on LeaseSets

This commit is contained in:
zzz
2014-01-30 13:02:16 +00:00
parent 2cea7cdb30
commit 5e16c42e4e
3 changed files with 26 additions and 15 deletions

View File

@ -1,3 +1,6 @@
2014-01-30 zzz
* InboundMessageDistributor: Set reply flag on LeaseSets
2014-01-28 zzz 2014-01-28 zzz
* /configclients: Add link to plugins.i2p; don't show delete button for console * /configclients: Add link to plugins.i2p; don't show delete button for console
* Tunnels: Change expl. IB default to 2 + 0-1 * Tunnels: Change expl. IB default to 2 + 0-1

View File

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

View File

@ -2,6 +2,7 @@ package net.i2p.router.tunnel;
import net.i2p.data.DatabaseEntry; import net.i2p.data.DatabaseEntry;
import net.i2p.data.Hash; import net.i2p.data.Hash;
import net.i2p.data.LeaseSet;
import net.i2p.data.Payload; import net.i2p.data.Payload;
import net.i2p.data.TunnelId; import net.i2p.data.TunnelId;
import net.i2p.data.i2np.DataMessage; import net.i2p.data.i2np.DataMessage;
@ -77,8 +78,9 @@ class InboundMessageDistributor implements GarlicMessageReceiver.CloveReceiver {
msg = newMsg; msg = newMsg;
} }
} else if ( (_client != null) && } else if ( (_client != null) &&
(type == DatabaseStoreMessage.MESSAGE_TYPE) && (type == DatabaseStoreMessage.MESSAGE_TYPE)) {
(((DatabaseStoreMessage)msg).getEntry().getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO)) { DatabaseStoreMessage dsm = (DatabaseStoreMessage) msg;
if (dsm.getEntry().getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO) {
// FVSJ may result in an unsolicited RI store if the peer went non-ff. // FVSJ may result in an unsolicited RI store if the peer went non-ff.
// Maybe we can figure out a way to handle this safely, so we don't ask him again. // Maybe we can figure out a way to handle this safely, so we don't ask him again.
// For now, just hope we eventually find out through other means. // For now, just hope we eventually find out through other means.
@ -86,14 +88,19 @@ class InboundMessageDistributor implements GarlicMessageReceiver.CloveReceiver {
if (_log.shouldLog(Log.WARN)) if (_log.shouldLog(Log.WARN))
_log.warn("Dropping DSM down a tunnel for " + _client + ": " + msg); _log.warn("Dropping DSM down a tunnel for " + _client + ": " + msg);
return; return;
} else if ( (_client != null) && } else if (dsm.getReplyToken() != 0) {
(type != DeliveryStatusMessage.MESSAGE_TYPE) && if (_log.shouldLog(Log.WARN))
(type != GarlicMessage.MESSAGE_TYPE) && _log.warn("Dropping LS DSM w/ reply token down a tunnel for " + _client + ": " + msg);
return;
} else {
// allow DSM of our own key (used by FloodfillVerifyStoreJob) // allow DSM of our own key (used by FloodfillVerifyStoreJob)
// or other keys (used by IterativeSearchJob) // or other keys (used by IterativeSearchJob)
// as long as there's no reply token (we will never set a reply token but an attacker might) // as long as there's no reply token (we will never set a reply token but an attacker might)
((type != DatabaseStoreMessage.MESSAGE_TYPE) || ((LeaseSet)dsm.getEntry()).setReceivedAsReply();
(((DatabaseStoreMessage)msg).getReplyToken() != 0)) && }
} else if ( (_client != null) &&
(type != DeliveryStatusMessage.MESSAGE_TYPE) &&
(type != GarlicMessage.MESSAGE_TYPE) &&
(type != TunnelBuildReplyMessage.MESSAGE_TYPE) && (type != TunnelBuildReplyMessage.MESSAGE_TYPE) &&
(type != VariableTunnelBuildReplyMessage.MESSAGE_TYPE)) { (type != VariableTunnelBuildReplyMessage.MESSAGE_TYPE)) {
// drop it, since we should only get tunnel test messages and garlic messages down // drop it, since we should only get tunnel test messages and garlic messages down
@ -192,6 +199,7 @@ class InboundMessageDistributor implements GarlicMessageReceiver.CloveReceiver {
// Or, it's a normal LS bundled with data and a MessageStatusMessage. // Or, it's a normal LS bundled with data and a MessageStatusMessage.
// ... and inject it. // ... and inject it.
((LeaseSet)dsm.getEntry()).setReceivedAsReply();
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.INFO))
_log.info("Storing garlic LS down tunnel 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); _context.inNetMessagePool().add(dsm, null, null);