merge of 'c824ff0c12a4b616407365fc175b161e7c3736df'

and 'dede80d3699065f495e330c8bb8e9e579882757c'
This commit is contained in:
z3d
2010-12-02 18:44:35 +00:00
7 changed files with 5 additions and 45 deletions

View File

@ -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)

View File

@ -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

View File

@ -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) ) {

View File

@ -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.
*

View File

@ -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; }

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 = 21;
public final static long BUILD = 22;
/** for example "-test" */
public final static String EXTRA = "";

View File

@ -490,7 +490,8 @@ public class TunnelDispatcher implements Service {
} else {
_context.messageHistory().droppedTunnelGatewayMessageUnknown(msg.getUniqueId(), outboundTunnel.getTunnelId());
int level = (_context.router().getUptime() > 10*60*1000 ? Log.ERROR : Log.WARN);
//int level = (_context.router().getUptime() > 10*60*1000 ? Log.ERROR : Log.WARN);
int level = Log.WARN;
if (_log.shouldLog(level))
_log.log(level, "no matching outbound tunnel for id=" + outboundTunnel
+ ": existing = " + _outboundGateways.size(), new Exception("src"));