I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 0c4cf5d3 authored by zzz's avatar zzz
Browse files

Ratchet: Add timeout job in OCMOSJ

parent eeb7ea4c
No related branches found
No related tags found
No related merge requests found
...@@ -657,9 +657,12 @@ public class OutboundClientMessageOneShotJob extends JobImpl { ...@@ -657,9 +657,12 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
// Per-message flag > 0 overrides per-session option // Per-message flag > 0 overrides per-session option
int tagsToSend = SendMessageOptions.getTagsToSend(sendFlags); int tagsToSend = SendMessageOptions.getTagsToSend(sendFlags);
ReplyCallback callback; ReplyCallback callback;
SendTimeoutJob eciesTimeout;
if (wantACK && _encryptionKey.getType() == EncType.ECIES_X25519) { if (wantACK && _encryptionKey.getType() == EncType.ECIES_X25519) {
callback = new ECIESReplyCallback(replyLeaseSet); eciesTimeout = new SendTimeoutJob(null, null);
callback = new ECIESReplyCallback(replyLeaseSet, eciesTimeout);
} else { } else {
eciesTimeout = null;
callback = null; callback = null;
} }
GarlicMessage msg = OutboundClientMessageJobHelper.createGarlicMessage(getContext(), token, GarlicMessage msg = OutboundClientMessageJobHelper.createGarlicMessage(getContext(), token,
...@@ -697,6 +700,11 @@ public class OutboundClientMessageOneShotJob extends JobImpl { ...@@ -697,6 +700,11 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
onReply = new SendSuccessJob(sessKey, tsh, replyLeaseSet, onFail); onReply = new SendSuccessJob(sessKey, tsh, replyLeaseSet, onFail);
long expiration = Math.max(_overallExpiration, _start + REPLY_TIMEOUT_MS_MIN); long expiration = Math.max(_overallExpiration, _start + REPLY_TIMEOUT_MS_MIN);
selector = new ReplySelector(token, expiration); selector = new ReplySelector(token, expiration);
} else if (wantACK && _encryptionKey.getType() == EncType.ECIES_X25519) {
// Timeout only. ECIESReplyCallback handles the reply (and will cancel the timeout)
onReply = null;
onFail = eciesTimeout;
selector = null;
} else { } else {
onReply = null; onReply = null;
onFail = null; onFail = null;
...@@ -769,6 +777,11 @@ public class OutboundClientMessageOneShotJob extends JobImpl { ...@@ -769,6 +777,11 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
DataHelper.formatDuration(_selector.getExpiration() - _overallExpiration) + DataHelper.formatDuration(_selector.getExpiration() - _overallExpiration) +
" after message, queueing separate timeout job"); " after message, queueing separate timeout job");
} }
} else if (_replyTimeout != null) {
// ECIES
long expiration = Math.max(_overallExpiration, _start + REPLY_TIMEOUT_MS_MIN);
_replyTimeout.getTiming().setStartAfter(expiration);
getContext().jobQueue().addJob(_replyTimeout);
} }
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.INFO))
_log.info(OutboundClientMessageOneShotJob.this.getJobId() + _log.info(OutboundClientMessageOneShotJob.this.getJobId() +
...@@ -1129,8 +1142,8 @@ public class OutboundClientMessageOneShotJob extends JobImpl { ...@@ -1129,8 +1142,8 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
* @since 0.9.46 * @since 0.9.46
*/ */
private class ECIESReplyCallback extends SendSuccessJob implements ReplyCallback { private class ECIESReplyCallback extends SendSuccessJob implements ReplyCallback {
public ECIESReplyCallback(LeaseSet ls) { public ECIESReplyCallback(LeaseSet ls, SendTimeoutJob timeout) {
super(null, null, ls, null); super(null, null, ls, timeout);
} }
public long getExpiration() { public long getExpiration() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment