Beispiel #1
0
  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;
    }
  }
Beispiel #2
0
 private void send(TunnelDataMessage msg, RouterInfo ri) {
   if (_log.shouldLog(Log.DEBUG))
     _log.debug("forwarding encrypted data out " + _config + ": " + msg.getUniqueId());
   OutNetMessage m = new OutNetMessage(_context);
   m.setMessage(msg);
   m.setExpiration(msg.getMessageExpiration());
   m.setTarget(ri);
   m.setPriority(PRIORITY);
   _context.outNetMessagePool().add(m);
   _config.incrementProcessedMessages();
 }