Search in sources :

Example 1 with TunnelDataMessage

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

the class OutboundReceiver method receiveEncrypted.

public long receiveEncrypted(byte[] encrypted) {
    TunnelDataMessage msg = new TunnelDataMessage(_context);
    msg.setData(encrypted);
    msg.setTunnelId(_config.getConfig(0).getSendTunnel());
    if (_log.shouldLog(Log.DEBUG))
        _log.debug("received encrypted, sending out " + _config + ": " + msg);
    RouterInfo ri = _nextHopCache;
    if (ri == null)
        ri = _context.netDb().lookupRouterInfoLocally(_config.getPeer(1));
    if (ri != null) {
        _nextHopCache = ri;
        send(msg, ri);
        return msg.getUniqueId();
    } else {
        // It should be rare to forget the router info for a peer in our own tunnel.
        if (_log.shouldLog(Log.WARN))
            _log.warn("lookup of " + _config.getPeer(1) + " required for " + msg);
        _context.netDb().lookupRouterInfo(_config.getPeer(1), new SendJob(_context, msg), new FailedJob(_context), MAX_LOOKUP_TIME);
        return -1;
    }
}
Also used : RouterInfo(net.i2p.data.router.RouterInfo) TunnelDataMessage(net.i2p.data.i2np.TunnelDataMessage)

Example 2 with TunnelDataMessage

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

the class InboundGatewayReceiver method receiveEncrypted.

public long receiveEncrypted(byte[] encrypted, boolean alreadySearched) {
    if (!alreadySearched)
        _config.incrementProcessedMessages();
    if (_target == null) {
        _target = _context.netDb().lookupRouterInfoLocally(_config.getSendTo());
        if (_target == null) {
            // It should be rare to forget the router info for the next peer
            ReceiveJob j = null;
            if (alreadySearched)
                _context.statManager().addRateData("tunnel.inboundLookupSuccess", 0);
            else
                j = new ReceiveJob(_context, encrypted);
            _context.netDb().lookupRouterInfo(_config.getSendTo(), j, j, MAX_LOOKUP_TIME);
            return -1;
        }
    }
    if (alreadySearched)
        _context.statManager().addRateData("tunnel.inboundLookupSuccess", 1);
    // We do this before the preprocessor now (i.e. before fragmentation)
    // if (_context.tunnelDispatcher().shouldDropParticipatingMessage("IBGW", encrypted.length))
    // return -1;
    // _config.incrementSentMessages();
    _context.bandwidthLimiter().sentParticipatingMessage(1024);
    TunnelDataMessage msg = new TunnelDataMessage(_context);
    msg.setData(encrypted);
    msg.setTunnelId(_config.getSendTunnel());
    OutNetMessage out = new OutNetMessage(_context, msg, msg.getMessageExpiration(), PRIORITY, _target);
    _context.outNetMessagePool().add(out);
    return msg.getUniqueId();
}
Also used : OutNetMessage(net.i2p.router.OutNetMessage) TunnelDataMessage(net.i2p.data.i2np.TunnelDataMessage)

Aggregations

TunnelDataMessage (net.i2p.data.i2np.TunnelDataMessage)2 RouterInfo (net.i2p.data.router.RouterInfo)1 OutNetMessage (net.i2p.router.OutNetMessage)1