* 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,23 +78,29 @@ 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;
// FVSJ may result in an unsolicited RI store if the peer went non-ff. if (dsm.getEntry().getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO) {
// Maybe we can figure out a way to handle this safely, so we don't ask him again. // FVSJ may result in an unsolicited RI store if the peer went non-ff.
// For now, just hope we eventually find out through other means. // Maybe we can figure out a way to handle this safely, so we don't ask him again.
// Todo: if peer was ff and RI is not ff, queue for exploration in netdb (but that isn't part of the facade now) // For now, just hope we eventually find out through other means.
if (_log.shouldLog(Log.WARN)) // Todo: if peer was ff and RI is not ff, queue for exploration in netdb (but that isn't part of the facade now)
_log.warn("Dropping DSM down a tunnel for " + _client + ": " + msg); if (_log.shouldLog(Log.WARN))
return; _log.warn("Dropping DSM down a tunnel for " + _client + ": " + msg);
return;
} else if (dsm.getReplyToken() != 0) {
if (_log.shouldLog(Log.WARN))
_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)
// 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)
((LeaseSet)dsm.getEntry()).setReceivedAsReply();
}
} else if ( (_client != null) && } else if ( (_client != null) &&
(type != DeliveryStatusMessage.MESSAGE_TYPE) && (type != DeliveryStatusMessage.MESSAGE_TYPE) &&
(type != GarlicMessage.MESSAGE_TYPE) && (type != GarlicMessage.MESSAGE_TYPE) &&
// allow DSM of our own key (used by FloodfillVerifyStoreJob)
// 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)
((type != DatabaseStoreMessage.MESSAGE_TYPE) ||
(((DatabaseStoreMessage)msg).getReplyToken() != 0)) &&
(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);