예제 #1
0
  /**
   * Handles a query reply locally.
   *
   * @param address can be null, if not null overrides the address info in <code>reply</code>
   */
  public void handleQueryReply(QueryReply reply, ReplyHandler handler, Address address) {
    // do not allow a faked multicast reply.
    if (reply.isFakeMulticast()) {
      return;
    }

    // Drop if it's a reply to mcast and conditions aren't met ...
    if (reply.isReplyToMulticastQuery()) {
      if (reply.isTCP()) return; // shouldn't be on TCP.
      if (reply.getHops() != 1 || reply.getTTL() != 0) return; // should only have hopped once.
    }

    // XML must be added to the response first, so that
    // whomever calls toRemoteFileDesc on the response
    // will create the cachedRFD with the correct XML.
    boolean validResponses = addXMLToResponses(reply, limeXMLDocumentHelper);
    // responses invalid?  exit.
    if (!validResponses) {
      return;
    }

    // check for unwanted results after xml has been constructed
    if (handler != null && handler.isPersonalSpam(reply)) {
      return;
    }

    if (reply.hasSecureData() && ApplicationSettings.USE_SECURE_RESULTS.getValue()) {
      secureMessageVerifier.verify(reply, this);
    } else {
      routeQueryReplyInternal(reply, address);
    }
  }