Ejemplo n.º 1
0
  protected static long getMaximumTTL(final List<Record> records) {
    long maximumTTL = 0;

    for (Record record : records) {
      if (record.getTTL() > maximumTTL) {
        maximumTTL = record.getTTL();
      }
    }

    return maximumTTL;
  }
  private static String createTTLandAnswer(final Message dnsMessage) {
    if (dnsMessage.getSectionArray(Section.ANSWER) == null
        || dnsMessage.getSectionArray(Section.ANSWER).length == 0) {
      return "ttl=\"-\" ans=\"-\"";
    }

    final StringBuilder answerStringBuilder = new StringBuilder();
    final StringBuilder ttlStringBuilder = new StringBuilder();
    for (final Record record : dnsMessage.getSectionArray(Section.ANSWER)) {
      final String s = record.rdataToString() + " ";
      final String ttl = record.getTTL() + " ";
      answerStringBuilder.append(s);
      ttlStringBuilder.append(ttl);
    }

    return "ttl=\""
        + ttlStringBuilder.toString().trim()
        + "\" ans=\""
        + answerStringBuilder.toString().trim()
        + "\"";
  }