forked from I2P_Developers/i2p.i2p
* I2CP: Fix external I2CP apps, including i2ping, caused by 0 nonce value,
broken in 0.9.2 (tickets #799, #801). Allow nonces == 0. Javadocs and cleanups.
This commit is contained in:
@@ -122,6 +122,7 @@ class I2CPMessageProducer {
|
|||||||
/**
|
/**
|
||||||
* Package up and send the payload to the router for delivery
|
* Package up and send the payload to the router for delivery
|
||||||
*
|
*
|
||||||
|
* @param nonce 0 to 0xffffffff; if 0, the router will not reply with a MessageStatusMessage
|
||||||
* @param tag unused - no end-to-end crypto
|
* @param tag unused - no end-to-end crypto
|
||||||
* @param tags unused - no end-to-end crypto
|
* @param tags unused - no end-to-end crypto
|
||||||
* @param key unused - no end-to-end crypto
|
* @param key unused - no end-to-end crypto
|
||||||
@@ -134,6 +135,8 @@ class I2CPMessageProducer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Package up and send the payload to the router for delivery
|
* Package up and send the payload to the router for delivery
|
||||||
|
*
|
||||||
|
* @param nonce 0 to 0xffffffff; if 0, the router will not reply with a MessageStatusMessage
|
||||||
* @since 0.8.4
|
* @since 0.8.4
|
||||||
*/
|
*/
|
||||||
public void sendMessage(I2PSessionImpl session, Destination dest, long nonce, byte[] payload,
|
public void sendMessage(I2PSessionImpl session, Destination dest, long nonce, byte[] payload,
|
||||||
@@ -160,6 +163,8 @@ class I2CPMessageProducer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Package up and send the payload to the router for delivery
|
* Package up and send the payload to the router for delivery
|
||||||
|
*
|
||||||
|
* @param nonce 0 to 0xffffffff; if 0, the router will not reply with a MessageStatusMessage
|
||||||
* @since 0.9.2
|
* @since 0.9.2
|
||||||
*/
|
*/
|
||||||
public void sendMessage(I2PSessionImpl session, Destination dest, long nonce, byte[] payload,
|
public void sendMessage(I2PSessionImpl session, Destination dest, long nonce, byte[] payload,
|
||||||
|
@@ -309,7 +309,7 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
|||||||
|
|
||||||
//if (_log.shouldLog(Log.DEBUG)) _log.debug("before creating nonce");
|
//if (_log.shouldLog(Log.DEBUG)) _log.debug("before creating nonce");
|
||||||
|
|
||||||
long nonce = _context.random().nextInt(Integer.MAX_VALUE);
|
long nonce = _context.random().nextInt(Integer.MAX_VALUE - 1) + 1;
|
||||||
//if (_log.shouldLog(Log.DEBUG)) _log.debug("before sync state");
|
//if (_log.shouldLog(Log.DEBUG)) _log.debug("before sync state");
|
||||||
MessageState state = new MessageState(_context, nonce, getPrefix());
|
MessageState state = new MessageState(_context, nonce, getPrefix());
|
||||||
//state.setKey(key);
|
//state.setKey(key);
|
||||||
|
@@ -105,17 +105,23 @@ public class SendMessageExpiresMessage extends SendMessageMessage {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void writeMessage(OutputStream out) throws I2CPMessageException, IOException {
|
public void writeMessage(OutputStream out) throws I2CPMessageException, IOException {
|
||||||
if ((getSessionId() == null) || (getDestination() == null) || (getPayload() == null) || (getNonce() <= 0))
|
if (_sessionId == null)
|
||||||
throw new I2CPMessageException("Unable to write out the message as there is not enough data");
|
throw new I2CPMessageException("No session ID");
|
||||||
int len = 2 + getDestination().size() + getPayload().getSize() + 4 + 4 + DataHelper.DATE_LENGTH;
|
if (_destination == null)
|
||||||
|
throw new I2CPMessageException("No dest");
|
||||||
|
if (_payload == null)
|
||||||
|
throw new I2CPMessageException("No payload");
|
||||||
|
if (_nonce < 0)
|
||||||
|
throw new I2CPMessageException("No nonce");
|
||||||
|
int len = 2 + _destination.size() + _payload.getSize() + 4 + 4 + DataHelper.DATE_LENGTH;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DataHelper.writeLong(out, 4, len);
|
DataHelper.writeLong(out, 4, len);
|
||||||
DataHelper.writeLong(out, 1, getType());
|
DataHelper.writeLong(out, 1, MESSAGE_TYPE);
|
||||||
getSessionId().writeBytes(out);
|
_sessionId.writeBytes(out);
|
||||||
getDestination().writeBytes(out);
|
_destination.writeBytes(out);
|
||||||
getPayload().writeBytes(out);
|
_payload.writeBytes(out);
|
||||||
DataHelper.writeLong(out, 4, getNonce());
|
DataHelper.writeLong(out, 4, _nonce);
|
||||||
_daf.writeBytes(out);
|
_daf.writeBytes(out);
|
||||||
} catch (DataFormatException dfe) {
|
} catch (DataFormatException dfe) {
|
||||||
throw new I2CPMessageException("Error writing the msg", dfe);
|
throw new I2CPMessageException("Error writing the msg", dfe);
|
||||||
@@ -142,12 +148,12 @@ public class SendMessageExpiresMessage extends SendMessageMessage {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append("[SendMessageMessage: ");
|
buf.append("[SendMessageExpiresMessage: ");
|
||||||
buf.append("\n\tSessionId: ").append(getSessionId());
|
buf.append("\n\tSessionId: ").append(_sessionId);
|
||||||
buf.append("\n\tNonce: ").append(getNonce());
|
buf.append("\n\tNonce: ").append(_nonce);
|
||||||
buf.append("\n\tDestination: ").append(getDestination());
|
buf.append("\n\tDestination: ").append(_destination);
|
||||||
buf.append("\n\tExpiration: ").append(getExpiration());
|
buf.append("\n\tExpiration: ").append(getExpiration());
|
||||||
buf.append("\n\tPayload: ").append(getPayload());
|
buf.append("\n\tPayload: ").append(_payload);
|
||||||
buf.append("]");
|
buf.append("]");
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
@@ -26,10 +26,10 @@ import net.i2p.data.Payload;
|
|||||||
*/
|
*/
|
||||||
public class SendMessageMessage extends I2CPMessageImpl {
|
public class SendMessageMessage extends I2CPMessageImpl {
|
||||||
public final static int MESSAGE_TYPE = 5;
|
public final static int MESSAGE_TYPE = 5;
|
||||||
private SessionId _sessionId;
|
protected SessionId _sessionId;
|
||||||
private Destination _destination;
|
protected Destination _destination;
|
||||||
private Payload _payload;
|
protected Payload _payload;
|
||||||
private long _nonce;
|
protected long _nonce;
|
||||||
|
|
||||||
public SendMessageMessage() {
|
public SendMessageMessage() {
|
||||||
}
|
}
|
||||||
@@ -58,10 +58,16 @@ public class SendMessageMessage extends I2CPMessageImpl {
|
|||||||
_payload = payload;
|
_payload = payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 0 to 0xffffffff
|
||||||
|
*/
|
||||||
public long getNonce() {
|
public long getNonce() {
|
||||||
return _nonce;
|
return _nonce;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param 0 to 0xffffffff
|
||||||
|
*/
|
||||||
public void setNonce(long nonce) {
|
public void setNonce(long nonce) {
|
||||||
_nonce = nonce;
|
_nonce = nonce;
|
||||||
}
|
}
|
||||||
@@ -109,8 +115,14 @@ public class SendMessageMessage extends I2CPMessageImpl {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void writeMessage(OutputStream out) throws I2CPMessageException, IOException {
|
public void writeMessage(OutputStream out) throws I2CPMessageException, IOException {
|
||||||
if ((_sessionId == null) || (_destination == null) || (_payload == null) || (_nonce <= 0))
|
if (_sessionId == null)
|
||||||
throw new I2CPMessageException("Unable to write out the message as there is not enough data");
|
throw new I2CPMessageException("No session ID");
|
||||||
|
if (_destination == null)
|
||||||
|
throw new I2CPMessageException("No dest");
|
||||||
|
if (_payload == null)
|
||||||
|
throw new I2CPMessageException("No payload");
|
||||||
|
if (_nonce < 0)
|
||||||
|
throw new I2CPMessageException("No nonce");
|
||||||
int len = 2 + _destination.size() + _payload.getSize() + 4 + 4;
|
int len = 2 + _destination.size() + _payload.getSize() + 4 + 4;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
12
history.txt
12
history.txt
@@ -1,6 +1,14 @@
|
|||||||
|
2012-12-05 zzz
|
||||||
|
* GarlicMessage: Fix notes and log in GarlicMessageHandler and HandleGarlicMessageJob,
|
||||||
|
they are used for netdb messages received by floodfills http://zzz.i2p/topics/1282
|
||||||
|
* I2CP: Fix external I2CP apps, including i2ping, caused by 0 nonce value,
|
||||||
|
broken in 0.9.2 (tickets #799, #801). Allow nonces == 0.
|
||||||
|
* Reseed: Don't go on to the next host if we have enough http://zzz.i2p/topics/1287
|
||||||
|
* SSU: Fix rare NPE (ticket #798)
|
||||||
|
|
||||||
2012-11-28 kytv
|
2012-11-28 kytv
|
||||||
* Chinese, French, Italian, Polish, and Ukrainian translation updates from
|
* Chinese, French, Italian, Polish, and Ukrainian translation updates from
|
||||||
Transifex.
|
Transifex.
|
||||||
|
|
||||||
2012-11-24 zzz
|
2012-11-24 zzz
|
||||||
* Addressbook: Disable unused wakeup via http
|
* Addressbook: Disable unused wakeup via http
|
||||||
|
@@ -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 = 12;
|
public final static long BUILD = 13;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
|
@@ -379,9 +379,10 @@ class ClientConnectionRunner {
|
|||||||
* Send a notification to the client that their message (id specified) was accepted
|
* Send a notification to the client that their message (id specified) was accepted
|
||||||
* for delivery (but not necessarily delivered)
|
* for delivery (but not necessarily delivered)
|
||||||
* Doesn't do anything if i2cp.messageReliability = "none"
|
* Doesn't do anything if i2cp.messageReliability = "none"
|
||||||
|
* or if the nonce is 0.
|
||||||
*/
|
*/
|
||||||
void ackSendMessage(MessageId id, long nonce) {
|
void ackSendMessage(MessageId id, long nonce) {
|
||||||
if (_dontSendMSM)
|
if (_dontSendMSM || nonce == 0)
|
||||||
return;
|
return;
|
||||||
SessionId sid = _sessionId;
|
SessionId sid = _sessionId;
|
||||||
if (sid == null) return;
|
if (sid == null) return;
|
||||||
|
Reference in New Issue
Block a user