diff --git a/history.txt b/history.txt index 1a2afb197..19f1cee38 100644 --- a/history.txt +++ b/history.txt @@ -1,5 +1,7 @@ 2010-12-02 zzz * Console: Format console refresh time + * I2NP: Allow message to be written more than once, + instead of throwing an IllegalStateException * i2psnark: Fix extension messages * Streaming: Restore I2PSocketManagerFull as public (broke jwebcahe ticket #345) diff --git a/router/java/src/net/i2p/data/i2np/DataMessage.java b/router/java/src/net/i2p/data/i2np/DataMessage.java index dcfff1805..81cde69cf 100644 --- a/router/java/src/net/i2p/data/i2np/DataMessage.java +++ b/router/java/src/net/i2p/data/i2np/DataMessage.java @@ -27,16 +27,13 @@ public class DataMessage extends I2NPMessageImpl { } public byte[] getData() { - verifyUnwritten(); return _data; } public void setData(byte[] data) { - verifyUnwritten(); _data = data; } public int getSize() { - verifyUnwritten(); return _data.length; } @@ -60,7 +57,6 @@ public class DataMessage extends I2NPMessageImpl { } /** write the message body to the output array, starting at the given index */ protected int writeMessageBody(byte out[], int curIndex) { - verifyUnwritten(); if (_data == null) { out[curIndex++] = 0x0; out[curIndex++] = 0x0; @@ -76,12 +72,6 @@ public class DataMessage extends I2NPMessageImpl { return curIndex; } - @Override - protected void written() { - super.written(); - _data = null; - } - public int getType() { return MESSAGE_TYPE; } @Override diff --git a/router/java/src/net/i2p/data/i2np/GarlicMessage.java b/router/java/src/net/i2p/data/i2np/GarlicMessage.java index cf92ce758..ce1466e83 100644 --- a/router/java/src/net/i2p/data/i2np/GarlicMessage.java +++ b/router/java/src/net/i2p/data/i2np/GarlicMessage.java @@ -29,11 +29,9 @@ public class GarlicMessage extends I2NPMessageImpl { } public byte[] getData() { - verifyUnwritten(); return _data; } public void setData(byte[] data) { - verifyUnwritten(); _data = data; } @@ -50,12 +48,10 @@ public class GarlicMessage extends I2NPMessageImpl { /** calculate the message body's length (not including the header and footer */ protected int calculateWrittenLength() { - verifyUnwritten(); return 4 + _data.length; } /** write the message body to the output array, starting at the given index */ protected int writeMessageBody(byte out[], int curIndex) throws I2NPMessageException { - verifyUnwritten(); byte len[] = DataHelper.toLong(4, _data.length); System.arraycopy(len, 0, out, curIndex, 4); curIndex += 4; @@ -71,12 +67,6 @@ public class GarlicMessage extends I2NPMessageImpl { return DataHelper.hashCode(getData()); } - @Override - protected void written() { - super.written(); - _data = null; - } - @Override public boolean equals(Object object) { if ( (object != null) && (object instanceof GarlicMessage) ) { diff --git a/router/java/src/net/i2p/data/i2np/I2NPMessageImpl.java b/router/java/src/net/i2p/data/i2np/I2NPMessageImpl.java index ae22437b8..6b4ab71f4 100644 --- a/router/java/src/net/i2p/data/i2np/I2NPMessageImpl.java +++ b/router/java/src/net/i2p/data/i2np/I2NPMessageImpl.java @@ -31,8 +31,6 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM protected I2PAppContext _context; private long _expiration; private long _uniqueId; - private boolean _written; - private boolean _read; public final static long DEFAULT_EXPIRATION_MS = 1*60*1000; // 1 minute by default public final static int CHECKSUM_LENGTH = 1; //Hash.HASH_LENGTH; @@ -125,7 +123,6 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM //long time = _context.clock().now() - start; //if (time > 50) // _context.statManager().addRateData("i2np.readTime", time, time); - _read = true; return size + Hash.HASH_LENGTH + 1 + 4 + DataHelper.DATE_LENGTH; } catch (DataFormatException dfe) { throw new I2NPMessageException("Error reading the message header", dfe); @@ -170,7 +167,6 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM //long time = _context.clock().now() - start; //if (time > 50) // _context.statManager().addRateData("i2np.readTime", time, time); - _read = true; return cur - offset; } @@ -289,7 +285,6 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM /** used by SSU only */ public int toRawByteArray(byte buffer[]) { - verifyUnwritten(); if (RAW_FULL_SIZE) return toByteArray(buffer); try { @@ -303,8 +298,6 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM _context.logManager().getLog(getClass()).log(Log.CRIT, "Error writing", ime); throw new IllegalStateException("Unable to serialize the message (" + getClass().getName() + "): " + ime.getMessage()); - } finally { - written(); } } @@ -337,7 +330,6 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM } catch (IOException ioe) { throw new I2NPMessageException("Error reading the " + msg, ioe); } - msg.read(); return msg; } @@ -347,7 +339,6 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM int dataSize = len - 1 - 4; msg.readMessage(buffer, offset, dataSize, type, handler); msg.setMessageExpiration(expiration); - msg.read(); return msg; } catch (IOException ioe) { throw new I2NPMessageException("IO error reading raw message", ioe); @@ -356,12 +347,6 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM } } - protected void verifyUnwritten() { - if (_written) throw new IllegalStateException("Already written"); - } - protected void written() { _written = true; } - protected void read() { _read = true; } - /** * Yes, this is fairly ugly, but its the only place it ever happens. * diff --git a/router/java/src/net/i2p/data/i2np/UnknownI2NPMessage.java b/router/java/src/net/i2p/data/i2np/UnknownI2NPMessage.java index dc18cfaa9..898a408ad 100644 --- a/router/java/src/net/i2p/data/i2np/UnknownI2NPMessage.java +++ b/router/java/src/net/i2p/data/i2np/UnknownI2NPMessage.java @@ -37,7 +37,6 @@ public class UnknownI2NPMessage extends I2NPMessageImpl { /** warning - only public for equals() */ public byte[] getData() { - verifyUnwritten(); return _data; } @@ -62,7 +61,6 @@ public class UnknownI2NPMessage extends I2NPMessageImpl { /** write the message body to the output array, starting at the given index */ protected int writeMessageBody(byte out[], int curIndex) { - verifyUnwritten(); if (_data == null) { out[curIndex++] = 0x0; out[curIndex++] = 0x0; @@ -78,12 +76,6 @@ public class UnknownI2NPMessage extends I2NPMessageImpl { return curIndex; } - @Override - protected void written() { - super.written(); - _data = null; - } - /** @return 0-255 */ public int getType() { return _type; } diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 43dca9240..9319fc01c 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -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 = 21; + public final static long BUILD = 22; /** for example "-test" */ public final static String EXTRA = "";