Search in sources :

Example 31 with TunnelId

use of net.i2p.data.TunnelId in project i2p.i2p by i2p.

the class FragmentTest method createPending.

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);
}
Also used : DataMessage(net.i2p.data.i2np.DataMessage) Hash(net.i2p.data.Hash) TunnelId(net.i2p.data.TunnelId)

Example 32 with TunnelId

use of net.i2p.data.TunnelId in project i2p.i2p by i2p.

the class LocalClientMessageEventListener method startCreateSessionJob.

/**
 *  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);
}
Also used : LeaseSet(net.i2p.data.LeaseSet) Lease(net.i2p.data.Lease) TunnelId(net.i2p.data.TunnelId) Date(java.util.Date)

Example 33 with TunnelId

use of net.i2p.data.TunnelId in project i2p.i2p by i2p.

the class GatewayITBase method testTunnel.

@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))));
    }
}
Also used : DataMessage(net.i2p.data.i2np.DataMessage) I2NPMessage(net.i2p.data.i2np.I2NPMessage) ArrayList(java.util.ArrayList) Hash(net.i2p.data.Hash) TunnelId(net.i2p.data.TunnelId) Test(org.junit.Test)

Aggregations

TunnelId (net.i2p.data.TunnelId)33 Hash (net.i2p.data.Hash)20 TunnelInfo (net.i2p.router.TunnelInfo)8 RouterInfo (net.i2p.data.router.RouterInfo)5 DataFormatException (net.i2p.data.DataFormatException)3 LeaseSet (net.i2p.data.LeaseSet)3 DatabaseStoreMessage (net.i2p.data.i2np.DatabaseStoreMessage)3 I2NPMessage (net.i2p.data.i2np.I2NPMessage)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 Lease (net.i2p.data.Lease)2 DataMessage (net.i2p.data.i2np.DataMessage)2 DeliveryStatusMessage (net.i2p.data.i2np.DeliveryStatusMessage)2 TunnelGatewayMessage (net.i2p.data.i2np.TunnelGatewayMessage)2 Job (net.i2p.router.Job)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 TreeSet (java.util.TreeSet)1 SessionKey (net.i2p.data.SessionKey)1