org.xbill.DNS.Message.getSectionArray()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(259)

本文整理了Java中org.xbill.DNS.Message.getSectionArray()方法的一些代码示例,展示了Message.getSectionArray()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getSectionArray()方法的具体详情如下:
包路径:org.xbill.DNS.Message
类名称:Message
方法名:getSectionArray

Message.getSectionArray介绍

暂无

代码示例

代码示例来源:origin: dnsjava/dnsjava

  1. /**
  2. * Returns the OPT record from the ADDITIONAL section, if one is present.
  3. * @see OPTRecord
  4. * @see Section
  5. */
  6. public OPTRecord
  7. getOPT() {
  8. Record [] additional = getSectionArray(Section.ADDITIONAL);
  9. for (int i = 0; i < additional.length; i++)
  10. if (additional[i] instanceof OPTRecord)
  11. return (OPTRecord) additional[i];
  12. return null;
  13. }

代码示例来源:origin: tiandawu/IotXmpp

  1. /**
  2. * Returns the OPT record from the ADDITIONAL section, if one is present.
  3. * @see OPTRecord
  4. * @see Section
  5. */
  6. public OPTRecord
  7. getOPT() {
  8. Record [] additional = getSectionArray(Section.ADDITIONAL);
  9. for (int i = 0; i < additional.length; i++)
  10. if (additional[i] instanceof OPTRecord)
  11. return (OPTRecord) additional[i];
  12. return null;
  13. }

代码示例来源:origin: net.sf.dnsjava-osgi/dnsjava-osgi

  1. /**
  2. * Returns the OPT record from the ADDITIONAL section, if one is present.
  3. * @see OPTRecord
  4. * @see Section
  5. */
  6. public OPTRecord
  7. getOPT() {
  8. Record [] additional = getSectionArray(Section.ADDITIONAL);
  9. for (int i = 0; i < additional.length; i++)
  10. if (additional[i] instanceof OPTRecord)
  11. return (OPTRecord) additional[i];
  12. return null;
  13. }

代码示例来源:origin: org.littleshoot/dnsjava

  1. /**
  2. * Returns the OPT record from the ADDITIONAL section, if one is present.
  3. * @see OPTRecord
  4. * @see Section
  5. */
  6. public OPTRecord
  7. getOPT() {
  8. Record [] additional = getSectionArray(Section.ADDITIONAL);
  9. for (int i = 0; i < additional.length; i++)
  10. if (additional[i] instanceof OPTRecord)
  11. return (OPTRecord) additional[i];
  12. return null;
  13. }

代码示例来源:origin: posicks/mdnsjava

  1. public static Record[] extractRecords(final Message message, final int... sections)
  2. {
  3. Record[] records = EMPTY_RECORDS;
  4. for (int section : sections)
  5. {
  6. Record[] tempRecords = message.getSectionArray(section);
  7. if ((tempRecords != null) && (tempRecords.length > 0))
  8. {
  9. int size = records.length + tempRecords.length;
  10. Record[] newRecords = new Record[size];
  11. System.arraycopy(records, 0, newRecords, 0, records.length);
  12. System.arraycopy(tempRecords, 0, newRecords, records.length, tempRecords.length);
  13. records = newRecords;
  14. }
  15. }
  16. return records;
  17. }

代码示例来源:origin: org.littleshoot/dnsjava

  1. /**
  2. * Converts the given section of the Message to a String.
  3. * @see Section
  4. */
  5. public String
  6. sectionToString(int i) {
  7. if (i > 3)
  8. return null;
  9. StringBuffer sb = new StringBuffer();
  10. Record [] records = getSectionArray(i);
  11. for (int j = 0; j < records.length; j++) {
  12. Record rec = records[j];
  13. if (i == Section.QUESTION) {
  14. sb.append(";;\t" + rec.name);
  15. sb.append(", type = " + Type.string(rec.type));
  16. sb.append(", class = " + DClass.string(rec.dclass));
  17. }
  18. else
  19. sb.append(rec);
  20. sb.append("\n");
  21. }
  22. return sb.toString();
  23. }

代码示例来源:origin: dnsjava/dnsjava

  1. /**
  2. * Converts the given section of the Message to a String.
  3. * @see Section
  4. */
  5. public String
  6. sectionToString(int i) {
  7. if (i > 3)
  8. return null;
  9. StringBuffer sb = new StringBuffer();
  10. Record [] records = getSectionArray(i);
  11. for (int j = 0; j < records.length; j++) {
  12. Record rec = records[j];
  13. if (i == Section.QUESTION) {
  14. sb.append(";;\t" + rec.name);
  15. sb.append(", type = " + Type.string(rec.type));
  16. sb.append(", class = " + DClass.string(rec.dclass));
  17. }
  18. else
  19. sb.append(rec);
  20. sb.append("\n");
  21. }
  22. return sb.toString();
  23. }

代码示例来源:origin: dnsjava/dnsjava

  1. private void
  2. addAdditional2(Message response, int section, int flags) {
  3. Record [] records = response.getSectionArray(section);
  4. for (int i = 0; i < records.length; i++) {
  5. Record r = records[i];
  6. Name glueName = r.getAdditionalName();
  7. if (glueName != null)
  8. addGlue(response, glueName, flags);
  9. }
  10. }

代码示例来源:origin: OpenNMS/opennms

  1. private void addAdditional2(final Message response, final int section, final int flags) {
  2. final Record[] records = response.getSectionArray(section);
  3. for (int i = 0; i < records.length; i++) {
  4. final Record r = records[i];
  5. final Name glueName = r.getAdditionalName();
  6. if (glueName != null) addGlue(response, glueName, flags);
  7. }
  8. }

代码示例来源:origin: org.echocat.jomon.net/common

  1. private void addAdditional2(Message response, int section, int flags) {
  2. final Record[] records = response.getSectionArray(section);
  3. for (int i = 0; i < records.length; i++) {
  4. final Record r = records[i];
  5. final Name glueName = r.getAdditionalName();
  6. if (glueName != null) {
  7. addGlue(response, glueName, flags);
  8. }
  9. }
  10. }

代码示例来源:origin: org.jboss.resteasy/resteasy-eagledns-fork

  1. private void addAdditional2(Message response, int section, int flags) {
  2. Record[] records = response.getSectionArray(section);
  3. for (Record r : records) {
  4. Name glueName = r.getAdditionalName();
  5. if (glueName != null) {
  6. addGlue(response, glueName, flags);
  7. }
  8. }
  9. }

代码示例来源:origin: julian-klode/dns66

  1. assertArrayEquals(new Record[] {}, responseMsg.getSectionArray(Section.ANSWER));
  2. assertNotEquals(0, responseMsg.getSectionArray(Section.AUTHORITY).length);
  3. assertTrue(responseMsg.getSectionArray(Section.AUTHORITY)[0] instanceof SOARecord);
  4. assertTrue(responseMsg.getSectionArray(Section.AUTHORITY)[0].getTTL() > 0);

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-registry

  1. /**
  2. * Add additional information to a DNS response section if a glue name is
  3. * specified.
  4. *
  5. * @param response the response message.
  6. * @param section the section of the response (e.g. ANSWER, AUTHORITY)
  7. * @param flags the flags.
  8. */
  9. private void addAdditional2(Message response, int section, int flags) {
  10. Record[] records = response.getSectionArray(section);
  11. for (int i = 0; i < records.length; i++) {
  12. Record r = records[i];
  13. Name glueName = r.getAdditionalName();
  14. if (glueName != null) {
  15. addGlue(response, glueName, flags);
  16. }
  17. }
  18. }

代码示例来源:origin: dnsjava/dnsjava

  1. static void
  2. doAXFR(Message response) throws IOException {
  3. System.out.println("; java dig 0.0 <> " + name + " axfr");
  4. if (response.isSigned()) {
  5. System.out.print(";; TSIG ");
  6. if (response.isVerified())
  7. System.out.println("ok");
  8. else
  9. System.out.println("failed");
  10. }
  11. if (response.getRcode() != Rcode.NOERROR) {
  12. System.out.println(response);
  13. return;
  14. }
  15. Record [] records = response.getSectionArray(Section.ANSWER);
  16. for (int i = 0; i < records.length; i++)
  17. System.out.println(records[i]);
  18. System.out.print(";; done (");
  19. System.out.print(response.getHeader().getCount(Section.ANSWER));
  20. System.out.print(" records, ");
  21. System.out.print(response.getHeader().getCount(Section.ADDITIONAL));
  22. System.out.println(" additional)");
  23. }

代码示例来源:origin: julian-klode/dns66

  1. assertArrayEquals(new Record[] {}, responseMsg.getSectionArray(Section.ANSWER));
  2. assertNotEquals(0, responseMsg.getSectionArray(Section.AUTHORITY).length);
  3. assertTrue(responseMsg.getSectionArray(Section.AUTHORITY)[0] instanceof SOARecord);
  4. assertTrue(responseMsg.getSectionArray(Section.AUTHORITY)[0].getTTL() > 0);

代码示例来源:origin: dnsjava/dnsjava

  1. /**
  2. * Verify a message using SIG(0).
  3. * @param message The message to be signed
  4. * @param b An array containing the message in unparsed form. This is
  5. * necessary since SIG(0) signs the message in wire format, and we can't
  6. * recreate the exact wire format (with the same name compression).
  7. * @param key The KEY record to verify the signature with.
  8. * @param previous If this message is a response, the SIG(0) from the query
  9. */
  10. public static void
  11. verifyMessage(Message message, byte [] b, KEYRecord key, SIGRecord previous)
  12. throws DNSSEC.DNSSECException
  13. {
  14. SIGRecord sig = null;
  15. Record [] additional = message.getSectionArray(Section.ADDITIONAL);
  16. for (int i = 0; i < additional.length; i++) {
  17. if (additional[i].getType() != Type.SIG)
  18. continue;
  19. if (((SIGRecord) additional[i]).getTypeCovered() != 0)
  20. continue;
  21. sig = (SIGRecord) additional[i];
  22. break;
  23. }
  24. DNSSEC.verifyMessage(message, b, sig, previous, key);
  25. }

代码示例来源:origin: posicks/mdnsjava

  1. protected Message convertUpdateToQueryResponse(final Message update)
  2. {
  3. Message m = new Message();
  4. Header h = m.getHeader();
  5. h.setOpcode(Opcode.QUERY);
  6. h.setFlag(Flags.AA);
  7. h.setFlag(Flags.QR);
  8. Record[] records = update.getSectionArray(Section.UPDATE);
  9. for (int index = 0; index < records.length; index++ )
  10. {
  11. m.addRecord(records[index], Section.ANSWER);
  12. }
  13. records = update.getSectionArray(Section.ADDITIONAL);
  14. for (int index = 0; index < records.length; index++ )
  15. {
  16. m.addRecord(records[index], Section.ADDITIONAL);
  17. }
  18. return m;
  19. }

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-registry

  1. /**
  2. * Add the NXT record to the authority
  3. * section of the response.
  4. *
  5. * @param response the response message.
  6. */
  7. private void addNXT(Message response, int flags)
  8. throws DNSSEC.DNSSECException, IOException {
  9. Record nxtRecord = getNXTRecord(
  10. response.getSectionArray(Section.QUESTION)[0]);
  11. Zone zone = findBestZone(nxtRecord.getName());
  12. addRecordCommand.exec(zone, nxtRecord);
  13. RRset nxtRR = zone.findExactMatch(nxtRecord.getName(), Type.NXT);
  14. addRRset(nxtRecord.getName(), response, nxtRR, Section.AUTHORITY, flags);
  15. removeRecordCommand.exec(zone, nxtRecord);
  16. }

代码示例来源:origin: org.dspace/dspace-stats

  1. public static String reverseDns(String hostIp) throws IOException {
  2. Resolver res = new ExtendedResolver();
  3. // set the timeout, defaults to 200 milliseconds
  4. int timeout = ConfigurationManager.getIntProperty("solr-statistics", "resolver.timeout", 200);
  5. res.setTimeout(0, timeout);
  6. Name name = ReverseMap.fromAddress(hostIp);
  7. int type = Type.PTR;
  8. int dclass = DClass.IN;
  9. Record rec = Record.newRecord(name, type, dclass);
  10. Message query = Message.newQuery(rec);
  11. Message response = res.send(query);
  12. Record[] answers = response.getSectionArray(Section.ANSWER);
  13. if (answers.length == 0)
  14. {
  15. return hostIp;
  16. }
  17. else
  18. {
  19. return answers[0].rdataToString();
  20. }
  21. }
  22. }

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-registry

  1. Record[] assertDNSQueryNotNull(String lookup, int type, int answerCount)
  2. throws IOException {
  3. Name name = Name.fromString(lookup);
  4. Record question = Record.newRecord(name, type, DClass.IN);
  5. Message query = Message.newQuery(question);
  6. OPTRecord optRecord = new OPTRecord(4096, 0, 0, Flags.DO, null);
  7. query.addRecord(optRecord, Section.ADDITIONAL);
  8. byte[] responseBytes = getRegistryDNS().generateReply(query, null);
  9. Message response = new Message(responseBytes);
  10. assertEquals("not successful", Rcode.NOERROR, response.getRcode());
  11. assertNotNull("Null response", response);
  12. assertEquals("Questions do not match", query.getQuestion(),
  13. response.getQuestion());
  14. Record[] recs = response.getSectionArray(Section.ANSWER);
  15. assertEquals(answerCount, recs.length);
  16. assertEquals(recs[0].getType(), type);
  17. return recs;
  18. }

相关文章