public TunnelId getTunnelIdObj() { if (_tunnelIdObj == null) _tunnelIdObj = new TunnelId(_tunnelId); // not thread safe, but immutable, so who cares return _tunnelIdObj; }
private static TunnelId getTunnel(byte id[]) { if (id == null) return null; else return new TunnelId(DataHelper.fromLong(id, 0, id.length)); }
public DataStructure createStructureToRead() { return new TunnelId(); } }
/** * Get a new random send tunnel ID that isn't a dup. * Note that we do not keep track of IDs for pending builds so this * does not fully prevent joinOutbound() from failing later. * @since 0.9.5 */ public long getNewOBGWID() { long rv; TunnelId tid; do { rv = 1 + _context.random().nextLong(TunnelId.MAX_ID_VALUE); tid = new TunnelId(rv); } while (_outboundGateways.containsKey(tid)); return rv; }
/** * Get a new random receive tunnel ID that isn't a dup. * For zero hop tunnels only. * Note that we do not keep track of IDs for pending builds so this * does not fully prevent joinInbound() from failing later. * @since 0.9.5 */ public long getNewIBZeroHopID() { long rv; TunnelId tid; do { rv = 1 + _context.random().nextLong(TunnelId.MAX_ID_VALUE); tid = new TunnelId(rv); } while (_inboundGateways.containsKey(tid)); return rv; }
/** * Get a new random receive tunnel ID that isn't a dup. * Not for zero hop tunnels. * Note that we do not keep track of IDs for pending builds so this * does not fully prevent joinInbound() from failing later. * @since 0.9.5 */ public long getNewIBEPID() { long rv; TunnelId tid; do { rv = 1 + _context.random().nextLong(TunnelId.MAX_ID_VALUE); tid = new TunnelId(rv); } while (_participants.containsKey(tid)); return rv; }
@Override public void readBytes(InputStream in) throws DataFormatException, IOException { _gateway = Hash.create(in); _tunnelId = new TunnelId(); _tunnelId.readBytes(in); _end = new Date(DataHelper.readLong(in, 4) * 1000); }
public void readBytes(InputStream in) throws DataFormatException, IOException { //_gateway = new Hash(); //_gateway.readBytes(in); _gateway = Hash.create(in); _tunnelId = new TunnelId(); _tunnelId.readBytes(in); _end = DataHelper.readDate(in); }
public DataStructure createDataStructure() throws DataFormatException { TunnelId id = new TunnelId(); id.setTunnelId(42); return id; } public DataStructure createStructureToRead() { return new TunnelId(); }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); _sessionId.readBytes(in); int numTunnels = (int) DataHelper.readLong(in, 1); _endpoints.clear(); for (int i = 0; i < numTunnels; i++) { //Hash router = new Hash(); //router.readBytes(in); Hash router = Hash.create(in); TunnelId tunnel = new TunnelId(); tunnel.readBytes(in); _endpoints.add(new TunnelEndpoint(router, tunnel)); } _end = DataHelper.readDate(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
h.readBytes(bais); l.setGateway(h); TunnelId t = new TunnelId(); t.readBytes(bais); l.setTunnelId(t);
h.readBytes(bais); _leases.get(i).setGateway(h); TunnelId t = new TunnelId(); t.readBytes(bais); _leases.get(i).setTunnelId(t);
_replyTunnel = new TunnelId(DataHelper.fromLong(data, curIndex, 4)); curIndex += 4;
@Test public void testTunnel() throws Exception { int runCount = 1; List<DataMessage> messages = new ArrayList<DataMessage>(runCount); long start = _context.clock().now(); for (int i = 0; i < runCount; i++) { DataMessage m = getTestMessage(64); Hash to = new Hash(new byte[Hash.HASH_LENGTH]); java.util.Arrays.fill(to.getData(), (byte)0xFF); TunnelId tunnel = new TunnelId(42); byte data[] = m.toByteArray(); messages.add(m); _gw.add(m, to, tunnel); } Thread.sleep(1000); List<I2NPMessage> received = _receiver.clearReceived(); for (int i = 0; i < messages.size(); i++) { assertTrue(received.contains(((I2NPMessage)messages.get(i)))); } }
int curIndex = offset; _tunnelId = new TunnelId(DataHelper.fromLong(data, curIndex, 4)); curIndex += 4;
public void runJob() { // decrement in-progress counter _currentLookups.decrementAndGet(); getContext().statManager().addRateData("tunnel.rejectTimeout", 1); getContext().statManager().addRateData("tunnel.buildLookupSuccess", 0); if (_log.shouldLog(Log.WARN)) _log.warn("Next hop lookup failure: " + _req); // ??? should we blame the peer here? getContext().profileManager().tunnelTimedOut(_nextPeer); getContext().messageHistory().tunnelRejected(_state.fromHash, new TunnelId(_req.readReceiveTunnelId()), _nextPeer, // this is all disabled anyway //"rejected because we couldn't find " + _nextPeer + ": " + //_state.msg.getUniqueId() + "/" + _req.readNextTunnelId()); "lookup fail"); } }
/** * Immediately send a fake leaseset */ @Override protected void startCreateSessionJob(SessionConfig config) { long exp = _context.clock().now() + 10*60*1000; LeaseSet ls = new LeaseSet(); Lease lease = new Lease(); lease.setGateway(Hash.FAKE_HASH); TunnelId id = new TunnelId(1); lease.setTunnelId(id); Date date = new Date(exp); lease.setEndDate(date); ls.addLease(lease); _runner.requestLeaseSet(config.getDestination().calculateHash(), ls, exp, null, null); }
public DataStructure createDataStructure() throws DataFormatException { DeliveryInstructions instructions = new DeliveryInstructions(); //instructions.setDelayRequested(true); //instructions.setDelaySeconds(42); instructions.setDeliveryMode(DeliveryInstructions.DELIVERY_MODE_TUNNEL); // encryption key read/write disabled //instructions.setEncrypted(true); //SessionKey key = new SessionKey(); //byte keyData[] = new byte[SessionKey.KEYSIZE_BYTES]; //for (int i = 0; i < keyData.length; i++) // keyData[i] = (byte)i; //key.setData(keyData); //instructions.setEncryptionKey(key); Hash hash = new Hash(); byte hashData[] = new byte[32]; for (int i = 0; i < hashData.length; i++) hashData[i] = (byte)(i%32); hash.setData(hashData); instructions.setRouter(hash); TunnelId id = new TunnelId(); id.setTunnelId(666); instructions.setTunnelId(id); return instructions; } public DataStructure createStructureToRead() { return new DeliveryInstructions(); }
cur += Hash.HASH_LENGTH; setRouter(trh); setTunnelId(new TunnelId(DataHelper.fromLong(data, cur, 4))); cur += 4; break;
protected PendingGatewayMessage createPending(int size, boolean includeRouter, boolean includeTunnel) { DataMessage m = new DataMessage(_context); byte data[] = new byte[size]; _context.random().nextBytes(data); m.setData(data); m.setUniqueId(_context.random().nextLong(I2NPMessage.MAX_ID_VALUE)); m.setMessageExpiration(_context.clock().now() + 60*1000); Hash toRouter = null; TunnelId toTunnel = null; if (includeRouter) { toRouter = new Hash(new byte[Hash.HASH_LENGTH]); _context.random().nextBytes(toRouter.getData()); } if (includeTunnel) toTunnel = new TunnelId(1 + _context.random().nextLong(TunnelId.MAX_ID_VALUE)); return new PendingGatewayMessage(m, toRouter, toTunnel); }