forked from I2P_Developers/i2p.i2p
Router: Ensure nonzero tunnel IDs
This commit is contained in:
@ -389,7 +389,7 @@ public class TunnelDispatcher implements Service {
|
||||
long rv;
|
||||
TunnelId tid;
|
||||
do {
|
||||
rv = _context.random().nextLong(TunnelId.MAX_ID_VALUE);
|
||||
rv = 1 + _context.random().nextLong(TunnelId.MAX_ID_VALUE - 1);
|
||||
tid = new TunnelId(rv);
|
||||
} while (_outboundGateways.containsKey(tid));
|
||||
return rv;
|
||||
@ -406,7 +406,7 @@ public class TunnelDispatcher implements Service {
|
||||
long rv;
|
||||
TunnelId tid;
|
||||
do {
|
||||
rv = _context.random().nextLong(TunnelId.MAX_ID_VALUE);
|
||||
rv = 1 + _context.random().nextLong(TunnelId.MAX_ID_VALUE - 1);
|
||||
tid = new TunnelId(rv);
|
||||
} while (_participants.containsKey(tid));
|
||||
return rv;
|
||||
@ -423,7 +423,7 @@ public class TunnelDispatcher implements Service {
|
||||
long rv;
|
||||
TunnelId tid;
|
||||
do {
|
||||
rv = _context.random().nextLong(TunnelId.MAX_ID_VALUE);
|
||||
rv = 1 + _context.random().nextLong(TunnelId.MAX_ID_VALUE - 1);
|
||||
tid = new TunnelId(rv);
|
||||
} while (_inboundGateways.containsKey(tid));
|
||||
return rv;
|
||||
@ -612,7 +612,7 @@ public class TunnelDispatcher implements Service {
|
||||
* endpoint.
|
||||
*
|
||||
* @param msg raw message to deliver to the target peer
|
||||
* @param outboundTunnel tunnel to send the message out
|
||||
* @param outboundTunnel tunnel to send the message out, or null for direct
|
||||
* @param targetPeer peer to receive the message
|
||||
*/
|
||||
public void dispatchOutbound(I2NPMessage msg, TunnelId outboundTunnel, Hash targetPeer) {
|
||||
@ -626,7 +626,7 @@ public class TunnelDispatcher implements Service {
|
||||
*
|
||||
* @param msg raw message to deliver to the targetTunnel on the targetPeer
|
||||
* @param outboundTunnel tunnel to send the message out
|
||||
* @param targetTunnel tunnel on the targetPeer to deliver the message to
|
||||
* @param targetTunnel tunnel on the targetPeer to deliver the message to, or null for direct
|
||||
* @param targetPeer gateway to the tunnel to receive the message
|
||||
*/
|
||||
public void dispatchOutbound(I2NPMessage msg, TunnelId outboundTunnel, TunnelId targetTunnel, Hash targetPeer) {
|
||||
|
@ -81,7 +81,7 @@ abstract class BuildRequestor {
|
||||
else if (isIB && i == len - 1)
|
||||
id = ctx.tunnelDispatcher().getNewIBEPID();
|
||||
else
|
||||
id = ctx.random().nextLong(TunnelId.MAX_ID_VALUE);
|
||||
id = 1 + ctx.random().nextLong(TunnelId.MAX_ID_VALUE - 1);
|
||||
cfg.getConfig(i).setReceiveTunnelId(DataHelper.toLong(4, id));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user