Author: toad
Date: 2007-11-19 16:09:35 +0000 (Mon, 19 Nov 2007)
New Revision: 15832
Modified:
trunk/freenet/src/freenet/io/comm/DMT.java
trunk/freenet/src/freenet/node/OpennetManager.java
trunk/freenet/src/freenet/node/RequestSender.java
Log:
Remove pre-1070 insecure path folding ref exchange.
Hopefully the new form works now!
Modified: trunk/freenet/src/freenet/io/comm/DMT.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/DMT.java 2007-11-19 15:59:22 UTC (rev
15831)
+++ trunk/freenet/src/freenet/io/comm/DMT.java 2007-11-19 16:09:35 UTC (rev
15832)
@@ -736,6 +736,8 @@
return msg;
}
+ // FIXME remove these two messages once 1074 is mandatory
+
/** Sent when a request completes and the data source does want to path
fold. Old version, includes
* the inline variable-length noderef. Opens up a nasty traffic
analysis (route tracing) vulnerability. */
public static MessageType FNPOpennetConnectDestination = new
MessageType("FNPOpennetConnectDestination") {{
@@ -743,13 +745,6 @@
addField(OPENNET_NODEREF, ShortBuffer.class);
}};
- public static Message createFNPOpennetConnectDestination(long uid,
ShortBuffer buf) {
- Message msg = new Message(FNPOpennetConnectDestination);
- msg.set(UID, uid);
- msg.set(OPENNET_NODEREF, buf);
- return msg;
- }
-
/** Path folding response. Old version, includes the inline
variable-length noderef. Opens up a
* nasty traffic analysis (route tracing) vulnerability. */
public static MessageType FNPOpennetConnectReply = new
MessageType("FNPOpennetConnectReply") {{
@@ -757,13 +752,6 @@
addField(OPENNET_NODEREF, ShortBuffer.class);
}};
- public static Message createFNPOpennetConnectReply(long uid,
ShortBuffer buf) {
- Message msg = new Message(FNPOpennetConnectReply);
- msg.set(UID, uid);
- msg.set(OPENNET_NODEREF, buf);
- return msg;
- }
-
/** Sent when a request completes and the data source wants to path
fold. Starts a bulk data
* transfer including the (padded) noderef.
*/
Modified: trunk/freenet/src/freenet/node/OpennetManager.java
===================================================================
--- trunk/freenet/src/freenet/node/OpennetManager.java 2007-11-19 15:59:22 UTC
(rev 15831)
+++ trunk/freenet/src/freenet/node/OpennetManager.java 2007-11-19 16:09:35 UTC
(rev 15832)
@@ -474,17 +474,9 @@
* @throws NotConnectedException If the peer becomes disconnected while
we are trying to send the noderef.
*/
public void sendOpennetRef(boolean isReply, long uid, PeerNode peer,
byte[] noderef, ByteCounter ctr) throws NotConnectedException {
- ShortBuffer buf = new ShortBuffer(noderef);
- // FIXME remove back compatibility code when a build that
understands the new path folding messages is mandatory.
- Message msg = isReply ? DMT.createFNPOpennetConnectReply(uid,
buf) :
- DMT.createFNPOpennetConnectDestination(uid, buf);
byte[] padded = new byte[PADDED_NODEREF_SIZE];
if(noderef.length > padded.length) {
Logger.error(this, "Noderef too big: "+noderef.length+"
bytes");
- if(!isReply) {
- msg = DMT.createFNPOpennetCompletedAck(uid);
- peer.sendAsync(msg, null, 0, ctr);
- }
return;
}
System.arraycopy(noderef, 0, padded, 0, noderef.length);
@@ -493,7 +485,6 @@
DMT.createFNPOpennetConnectDestinationNew(uid, xferUID,
noderef.length, padded.length);
// Send the new message first.
peer.sendAsync(msg2, null, 0, ctr);
- peer.sendAsync(msg, null, 0, ctr);
ByteArrayRandomAccessThing raf = new
ByteArrayRandomAccessThing(padded);
raf.setReadOnly();
PartiallyReceivedBulk prb =
@@ -515,14 +506,9 @@
*/
public byte[] waitForOpennetNoderef(boolean isReply, PeerNode source,
long uid, ByteCounter ctr) {
// FIXME remove back compat code
- MessageFilter mfReply =
+ MessageFilter mf =
MessageFilter.create().setSource(source).setField(DMT.UID,
uid).setTimeout(RequestSender.OPENNET_TIMEOUT).
- setType(isReply ? DMT.FNPOpennetConnectReply :
DMT.FNPOpennetConnectDestination);
- MessageFilter mfNewReply =
-
MessageFilter.create().setSource(source).setField(DMT.UID,
uid).setTimeout(RequestSender.OPENNET_TIMEOUT).
setType(isReply ? DMT.FNPOpennetConnectReplyNew :
DMT.FNPOpennetConnectDestinationNew);
- MessageFilter mf =
- mfReply.or(mfNewReply);
if(!isReply) {
// Also waiting for an ack
MessageFilter mfAck =
@@ -548,10 +534,6 @@
if(msg.getSpec() == DMT.FNPOpennetCompletedAck)
return null; // Acked (only possible if !isReply)
- // FIXME remove back compat
- if(msg.getSpec() == DMT.FNPOpennetConnectReply || msg.getSpec()
== DMT.FNPOpennetConnectDestination) {
- return
((ShortBuffer)msg.getObject(DMT.OPENNET_NODEREF)).getData();
- } else {
// New format
long xferUID = msg.getLong(DMT.TRANSFER_UID);
int paddedLength = msg.getInt(DMT.PADDED_LENGTH);
@@ -575,7 +557,6 @@
byte[] noderef = new byte[realLength];
System.arraycopy(buf, 0, noderef, 0, realLength);
return noderef;
- }
}
public SimpleFieldSet validateNoderef(byte[] noderef, int offset, int
length, PeerNode from) {
Modified: trunk/freenet/src/freenet/node/RequestSender.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestSender.java 2007-11-19 15:59:22 UTC
(rev 15831)
+++ trunk/freenet/src/freenet/node/RequestSender.java 2007-11-19 16:09:35 UTC
(rev 15832)
@@ -643,9 +643,7 @@
/** Wait for the opennet completion message and discard it */
private void finishOpennetNull(PeerNode next) {
- MessageFilter mfAck =
MessageFilter.create().setSource(next).setField(DMT.UID,
uid).setTimeout(OPENNET_TIMEOUT).setType(DMT.FNPOpennetCompletedAck);
- MessageFilter mfConnect =
MessageFilter.create().setSource(next).setField(DMT.UID,
uid).setTimeout(OPENNET_TIMEOUT).setType(DMT.FNPOpennetConnectDestination);
- MessageFilter mf =
mfAck.or(mfConnect).setMatchesDroppedConnection(true).setMatchesRestartedConnections(true);
+ MessageFilter mf =
MessageFilter.create().setSource(next).setField(DMT.UID,
uid).setTimeout(OPENNET_TIMEOUT).setType(DMT.FNPOpennetCompletedAck).setMatchesDroppedConnection(true).setMatchesRestartedConnections(true);
try {
node.usm.addAsyncFilter(mf, new
NullAsyncMessageFilterCallback());