use the explicit max ID values (I2NPMessage.MAX_ID_VALUE and TunnelId.MAX_ID_VALUE)

logging
This commit is contained in:
jrandom
2004-06-29 19:32:46 +00:00
committed by zzz
parent 1cd5a3fcf7
commit d0c61dbf4d
7 changed files with 29 additions and 20 deletions

View File

@ -86,7 +86,7 @@ public class BuildTestMessageJob extends JobImpl {
}
private GarlicConfig buildGarlicCloveConfig() {
_testMessageKey = _context.random().nextInt(Integer.MAX_VALUE);
_testMessageKey = _context.random().nextLong(I2NPMessage.MAX_ID_VALUE);
if (_log.shouldLog(Log.INFO))
_log.info("Test message key: " + _testMessageKey);
GarlicConfig config = new GarlicConfig();
@ -105,7 +105,7 @@ public class BuildTestMessageJob extends JobImpl {
config.setCertificate(new Certificate(Certificate.CERTIFICATE_TYPE_NULL, null));
config.setDeliveryInstructions(instructions);
config.setId(_context.random().nextInt(Integer.MAX_VALUE));
config.setId(_context.random().nextLong(I2NPMessage.MAX_ID_VALUE));
config.setExpiration(_timeoutMs+_context.clock().now()+2*Router.CLOCK_FUDGE_FACTOR);
config.setRecipient(_target);
config.setRequestAck(false);
@ -135,7 +135,7 @@ public class BuildTestMessageJob extends JobImpl {
ackClove.setCertificate(new Certificate(Certificate.CERTIFICATE_TYPE_NULL, null));
ackClove.setDeliveryInstructions(ackInstructions);
ackClove.setExpiration(_timeoutMs+_context.clock().now());
ackClove.setId(_context.random().nextInt(Integer.MAX_VALUE));
ackClove.setId(_context.random().nextLong(I2NPMessage.MAX_ID_VALUE));
ackClove.setPayload(msg);
ackClove.setRecipient(_target);
ackClove.setRequestAck(false);

View File

@ -303,7 +303,7 @@ public class OutboundClientMessageJob extends JobImpl {
*
*/
private void send(Lease lease) {
long token = _context.random().nextInt(Integer.MAX_VALUE);
long token = _context.random().nextLong(I2NPMessage.MAX_ID_VALUE);
PublicKey key = _status.getLeaseSet().getEncryptionKey();
SessionKey sessKey = new SessionKey();
Set tags = new HashSet();
@ -411,7 +411,7 @@ public class OutboundClientMessageJob extends JobImpl {
clove.setCertificate(new Certificate(Certificate.CERTIFICATE_TYPE_NULL, null));
clove.setDeliveryInstructions(instructions);
clove.setExpiration(_overallExpiration);
clove.setId(_context.random().nextInt(Integer.MAX_VALUE));
clove.setId(_context.random().nextLong(I2NPMessage.MAX_ID_VALUE));
DataMessage msg = new DataMessage(_context);
msg.setData(_status.getMessage().getPayload().getEncryptedData());

View File

@ -25,6 +25,7 @@ import net.i2p.data.i2np.DatabaseStoreMessage;
import net.i2p.data.i2np.DeliveryInstructions;
import net.i2p.data.i2np.DeliveryStatusMessage;
import net.i2p.data.i2np.GarlicMessage;
import net.i2p.data.i2np.I2NPMessage;
import net.i2p.router.Router;
import net.i2p.router.RouterContext;
import net.i2p.router.TunnelInfo;
@ -102,7 +103,7 @@ class OutboundClientMessageJobHelper {
config.setCertificate(new Certificate(Certificate.CERTIFICATE_TYPE_NULL, null));
config.setDeliveryInstructions(instructions);
config.setId(ctx.random().nextInt(Integer.MAX_VALUE));
config.setId(ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE));
config.setExpiration(expiration+2*Router.CLOCK_FUDGE_FACTOR);
config.setRecipientPublicKey(recipientPK);
config.setRequestAck(false);
@ -154,7 +155,7 @@ class OutboundClientMessageJobHelper {
ackClove.setCertificate(new Certificate(Certificate.CERTIFICATE_TYPE_NULL, null));
ackClove.setDeliveryInstructions(ackInstructions);
ackClove.setExpiration(expiration);
ackClove.setId(ctx.random().nextInt(Integer.MAX_VALUE));
ackClove.setId(ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE));
ackClove.setPayload(msg);
ackClove.setRecipient(ctx.router().getRouterInfo());
ackClove.setRequestAck(false);
@ -181,7 +182,7 @@ class OutboundClientMessageJobHelper {
clove.setCertificate(new Certificate(Certificate.CERTIFICATE_TYPE_NULL, null));
clove.setDeliveryInstructions(instructions);
clove.setExpiration(expiration);
clove.setId(ctx.random().nextInt(Integer.MAX_VALUE));
clove.setId(ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE));
DataMessage msg = new DataMessage(ctx);
msg.setData(data.getEncryptedData());
clove.setPayload(msg);
@ -207,7 +208,7 @@ class OutboundClientMessageJobHelper {
clove.setCertificate(new Certificate(Certificate.CERTIFICATE_TYPE_NULL, null));
clove.setDeliveryInstructions(instructions);
clove.setExpiration(expiration);
clove.setId(ctx.random().nextInt(Integer.MAX_VALUE));
clove.setId(ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE));
DatabaseStoreMessage msg = new DatabaseStoreMessage(ctx);
msg.setLeaseSet(replyLeaseSet);
msg.setMessageExpiration(new Date(expiration));

View File

@ -210,7 +210,7 @@ class StoreJob extends JobImpl {
}
private void sendStoreThroughGarlic(DatabaseStoreMessage msg, RouterInfo peer, long expiration) {
long token = _context.random().nextInt(Integer.MAX_VALUE);
long token = _context.random().nextLong(I2NPMessage.MAX_ID_VALUE);
TunnelId replyTunnelId = selectInboundTunnel();
TunnelInfo replyTunnel = _context.tunnelManager().getTunnelInfo(replyTunnelId);

View File

@ -460,7 +460,7 @@ public class RequestTunnelJob extends JobImpl {
instructions.setRouter(gateway.getGateway());
instructions.setTunnelId(gateway.getTunnelId());
long replyId = _context.random().nextInt(Integer.MAX_VALUE);
long replyId = _context.random().nextLong(I2NPMessage.MAX_ID_VALUE);
Certificate replyCert = new Certificate(Certificate.CERTIFICATE_TYPE_NULL, null);
@ -500,7 +500,7 @@ public class RequestTunnelJob extends JobImpl {
private DeliveryStatusMessage buildDeliveryStatusMessage() {
DeliveryStatusMessage msg = new DeliveryStatusMessage(_context);
msg.setArrival(new Date(_context.clock().now()));
msg.setMessageId(_context.random().nextInt(Integer.MAX_VALUE));
msg.setMessageId(_context.random().nextLong(I2NPMessage.MAX_ID_VALUE));
Date exp = new Date(_expiration);
if (_log.shouldLog(Log.DEBUG))
_log.debug("Setting the expiration on the delivery status message to " + exp);
@ -567,7 +567,7 @@ public class RequestTunnelJob extends JobImpl {
config.setCertificate(new Certificate(Certificate.CERTIFICATE_TYPE_NULL, null));
config.setDeliveryInstructions(instructions);
config.setId(_context.random().nextInt(Integer.MAX_VALUE));
config.setId(_context.random().nextLong(I2NPMessage.MAX_ID_VALUE));
config.setExpiration(_expiration);
config.setRecipientPublicKey(target.getIdentity().getPublicKey());
config.setRequestAck(false);
@ -595,7 +595,7 @@ public class RequestTunnelJob extends JobImpl {
ackClove.setCertificate(new Certificate(Certificate.CERTIFICATE_TYPE_NULL, null));
ackClove.setDeliveryInstructions(ackInstructions);
ackClove.setExpiration(expiration);
ackClove.setId(_context.random().nextInt(Integer.MAX_VALUE));
ackClove.setId(_context.random().nextLong(I2NPMessage.MAX_ID_VALUE));
ackClove.setPayload(ackMsg);
ackClove.setRecipient(replyPeer);
ackClove.setRequestAck(false);
@ -620,7 +620,7 @@ public class RequestTunnelJob extends JobImpl {
clove.setCertificate(new Certificate(Certificate.CERTIFICATE_TYPE_NULL, null));
clove.setDeliveryInstructions(instructions);
clove.setExpiration(expiration);
clove.setId(_context.random().nextInt(Integer.MAX_VALUE));
clove.setId(_context.random().nextLong(I2NPMessage.MAX_ID_VALUE));
clove.setPayload(data);
clove.setRecipientPublicKey(null);
clove.setRequestAck(false);
@ -771,18 +771,25 @@ public class RequestTunnelJob extends JobImpl {
private TunnelInfo _tunnel;
private Hash _replyThrough;
private long _started;
private Exception _by;
public Failure(TunnelInfo tunnel, Hash replyThrough) {
super(RequestTunnelJob.this._context);
_tunnel = tunnel;
_replyThrough = replyThrough;
_started = _context.clock().now();
_by = new Exception("Failure created");
}
public String getName() { return "Create Tunnel Failed"; }
public void runJob() {
// update the tunnel so its known to be not working
if (_log.shouldLog(Log.WARN))
_log.warn("Tunnel creation timed out for tunnel " + _tunnel.getTunnelId() + " at router " + _tunnel.getThisHop().toBase64() + " with expiration " + new Date(_expiration));
if (_log.shouldLog(Log.ERROR)) {
_log.error("Tunnel creation timed out for tunnel " + _tunnel.getTunnelId() + " at router "
+ _tunnel.getThisHop().toBase64() + " from router "
+ _context.routerHash().toBase64() + " after waiting "
+ (_context.clock().now()-_started) + "ms", _by);
_log.error("Added by", Failure.this.getAddedBy());
}
synchronized (_failedTunnelParticipants) {
_failedTunnelParticipants.add(_tunnel.getThisHop());
_failedTunnelParticipants.add(_replyThrough);

View File

@ -38,7 +38,7 @@ class TestTunnelJob extends JobImpl {
_log = ctx.logManager().getLog(TestTunnelJob.class);
_primaryId = id;
_pool = pool;
_nonce = ctx.random().nextInt(Integer.MAX_VALUE);
_nonce = ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE);
}
public String getName() { return "Test Tunnel"; }
public void runJob() {

View File

@ -20,6 +20,7 @@ import net.i2p.data.SessionKey;
import net.i2p.data.SigningPrivateKey;
import net.i2p.data.SigningPublicKey;
import net.i2p.data.TunnelId;
import net.i2p.data.i2np.I2NPMessage;
import net.i2p.router.ClientTunnelSettings;
import net.i2p.router.PeerSelectionCriteria;
import net.i2p.router.RouterContext;
@ -284,7 +285,7 @@ class TunnelBuilder {
tunnelSettings.setReorder(settings.getReorderInbound());
TunnelId id = new TunnelId();
id.setTunnelId(_context.random().nextInt(Integer.MAX_VALUE));
id.setTunnelId(_context.random().nextLong(TunnelId.MAX_ID_VALUE));
id.setType(TunnelId.TYPE_INBOUND);
TunnelInfo first = null;
@ -363,7 +364,7 @@ class TunnelBuilder {
tunnelSettings.setReorder(settings.getReorderInbound());
TunnelId id = new TunnelId();
id.setTunnelId(_context.random().nextInt(Integer.MAX_VALUE));
id.setTunnelId(_context.random().nextLong(TunnelId.MAX_ID_VALUE));
id.setType(TunnelId.TYPE_OUTBOUND);
TunnelInfo first = new TunnelInfo(_context);