Search in sources :

Example 6 with DataMessage

use of net.i2p.data.i2np.DataMessage 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 7 with DataMessage

use of net.i2p.data.i2np.DataMessage in project i2p.i2p by i2p.

the class GatewayITBase method testRouter.

@Test
public void testRouter() 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);
        messages.add(m);
        _gw.add(m, to, null);
    }
    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) Test(org.junit.Test)

Example 8 with DataMessage

use of net.i2p.data.i2np.DataMessage in project i2p.i2p by i2p.

the class GatewayITBase method testSmall.

@Test
public void testSmall() 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);
        messages.add(m);
        _gw.add(m, null, null);
    }
    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) Test(org.junit.Test)

Example 9 with DataMessage

use of net.i2p.data.i2np.DataMessage 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)

Example 10 with DataMessage

use of net.i2p.data.i2np.DataMessage in project i2p.i2p by i2p.

the class OutboundClientMessageOneShotJob method buildClove.

/**
 *  Build the payload clove that will be used for all of the messages,
 *  placing the clove in the status structure.
 *
 *  @return null on failure
 */
private PayloadGarlicConfig buildClove() {
    PayloadGarlicConfig clove = new PayloadGarlicConfig();
    DeliveryInstructions instructions = new DeliveryInstructions();
    instructions.setDeliveryMode(DeliveryInstructions.DELIVERY_MODE_DESTINATION);
    instructions.setDestination(_to.calculateHash());
    // defaults
    // instructions.setDelayRequested(false);
    // instructions.setDelaySeconds(0);
    // instructions.setEncrypted(false);
    clove.setCertificate(Certificate.NULL_CERT);
    clove.setDeliveryInstructions(instructions);
    clove.setExpiration(OVERALL_TIMEOUT_MS_DEFAULT + getContext().clock().now());
    clove.setId(getContext().random().nextLong(I2NPMessage.MAX_ID_VALUE));
    DataMessage msg = new DataMessage(getContext());
    Payload p = _clientMessage.getPayload();
    if (p == null)
        return null;
    byte[] d = p.getEncryptedData();
    if (d == null)
        return null;
    msg.setData(d);
    msg.setMessageExpiration(clove.getExpiration());
    clove.setPayload(msg);
    // _log.debug(getJobId() + ": Built payload clove with id " + clove.getId());
    return clove;
}
Also used : DeliveryInstructions(net.i2p.data.i2np.DeliveryInstructions) DataMessage(net.i2p.data.i2np.DataMessage) Payload(net.i2p.data.Payload)

Aggregations

DataMessage (net.i2p.data.i2np.DataMessage)10 ArrayList (java.util.ArrayList)4 Hash (net.i2p.data.Hash)4 I2NPMessage (net.i2p.data.i2np.I2NPMessage)4 Test (org.junit.Test)4 Payload (net.i2p.data.Payload)2 TunnelId (net.i2p.data.TunnelId)2 DeliveryInstructions (net.i2p.data.i2np.DeliveryInstructions)2 DatabaseSearchReplyMessage (net.i2p.data.i2np.DatabaseSearchReplyMessage)1 DatabaseStoreMessage (net.i2p.data.i2np.DatabaseStoreMessage)1 RouterInfo (net.i2p.data.router.RouterInfo)1 ClientMessage (net.i2p.router.ClientMessage)1 OutNetMessage (net.i2p.router.OutNetMessage)1 TunnelPoolSettings (net.i2p.router.TunnelPoolSettings)1