Ejemplo n.º 1
0
 /** Create a new search for the routingKey specified */
 public SearchJob(
     RouterContext context,
     KademliaNetworkDatabaseFacade facade,
     Hash key,
     Job onSuccess,
     Job onFailure,
     long timeoutMs,
     boolean keepStats,
     boolean isLease) {
   super(context);
   if ((key == null) || (key.getData() == null))
     throw new IllegalArgumentException("Search for null key?  wtf");
   _log = getContext().logManager().getLog(getClass());
   _facade = facade;
   _state = new SearchState(getContext(), key);
   _onSuccess = onSuccess;
   _onFailure = onFailure;
   _timeoutMs = timeoutMs;
   _keepStats = keepStats;
   _isLease = isLease;
   _deferredSearches = new ArrayList(0);
   _peerSelector = facade.getPeerSelector();
   _startedOn = -1;
   _expiration = getContext().clock().now() + timeoutMs;
   getContext().statManager().addRateData("netDb.searchCount", 1, 0);
   if (_log.shouldLog(Log.DEBUG))
     _log.debug(
         "Search (" + getClass().getName() + " for " + key.toBase64(),
         new Exception("Search enqueued by"));
 }
Ejemplo n.º 2
0
  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    if (!validPassphrase()) return;

    response.setContentType("text/html");
    PrintWriter out = null;
    try {
      out = response.getWriter();
      out.println("<html><head><title>Addresses</title></head>");
      out.println("<form method=POST>");
      out.println("<table>");
      for (Record record : RecordIndex.getInstance()) {
        out.println("<tr>");
        out.println(
            "<td><input name=\"checked\" type=\"checkbox\" value=\""
                + Long.toHexString(record.id)
                + "\" /></td>");
        out.println(" <td>" + record.getName() + "</td>");
        out.println(" <td>" + formatter.format(record.getModified()) + "</td>");
        out.println(" <td>" + record.getAddress().toBase64() + "</td>");
        out.println("</tr>");
      }
      out.println("</table>");

      out.println("<input name=\"delete\" type=\"submit\" value=\"Delete Selected\" />");
      out.println("</form>");
      out.println("<h3>Deleted addresses:</h3>");
      out.println("<form method=POST>");
      out.println("<table>");
      for (Hash hash : blacklist) {
        String shash = Base32.encode(hash.getData());
        out.println("<tr>");
        out.println(
            "  <td><input name=\"checked\" type=\"checkbox\" value=\"" + shash + "\" /></td>");
        out.println("  <td>" + shash + "</td>");
        out.println("</tr>");
      }
      out.println("</table>");

      out.println("<input type=\"submit\" name=\"submit\" value=\"Undelete Selected\" />");

      out.println("</form></body></html>");
    } finally {
      if (out != null) out.close();
    }
  }