本文整理了Java中org.xbill.DNS.Message.getSectionArray()
方法的一些代码示例,展示了Message.getSectionArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getSectionArray()
方法的具体详情如下:
包路径:org.xbill.DNS.Message
类名称:Message
方法名:getSectionArray
暂无
代码示例来源:origin: dnsjava/dnsjava
/**
* Returns the OPT record from the ADDITIONAL section, if one is present.
* @see OPTRecord
* @see Section
*/
public OPTRecord
getOPT() {
Record [] additional = getSectionArray(Section.ADDITIONAL);
for (int i = 0; i < additional.length; i++)
if (additional[i] instanceof OPTRecord)
return (OPTRecord) additional[i];
return null;
}
代码示例来源:origin: tiandawu/IotXmpp
/**
* Returns the OPT record from the ADDITIONAL section, if one is present.
* @see OPTRecord
* @see Section
*/
public OPTRecord
getOPT() {
Record [] additional = getSectionArray(Section.ADDITIONAL);
for (int i = 0; i < additional.length; i++)
if (additional[i] instanceof OPTRecord)
return (OPTRecord) additional[i];
return null;
}
代码示例来源:origin: net.sf.dnsjava-osgi/dnsjava-osgi
/**
* Returns the OPT record from the ADDITIONAL section, if one is present.
* @see OPTRecord
* @see Section
*/
public OPTRecord
getOPT() {
Record [] additional = getSectionArray(Section.ADDITIONAL);
for (int i = 0; i < additional.length; i++)
if (additional[i] instanceof OPTRecord)
return (OPTRecord) additional[i];
return null;
}
代码示例来源:origin: org.littleshoot/dnsjava
/**
* Returns the OPT record from the ADDITIONAL section, if one is present.
* @see OPTRecord
* @see Section
*/
public OPTRecord
getOPT() {
Record [] additional = getSectionArray(Section.ADDITIONAL);
for (int i = 0; i < additional.length; i++)
if (additional[i] instanceof OPTRecord)
return (OPTRecord) additional[i];
return null;
}
代码示例来源:origin: posicks/mdnsjava
public static Record[] extractRecords(final Message message, final int... sections)
{
Record[] records = EMPTY_RECORDS;
for (int section : sections)
{
Record[] tempRecords = message.getSectionArray(section);
if ((tempRecords != null) && (tempRecords.length > 0))
{
int size = records.length + tempRecords.length;
Record[] newRecords = new Record[size];
System.arraycopy(records, 0, newRecords, 0, records.length);
System.arraycopy(tempRecords, 0, newRecords, records.length, tempRecords.length);
records = newRecords;
}
}
return records;
}
代码示例来源:origin: org.littleshoot/dnsjava
/**
* Converts the given section of the Message to a String.
* @see Section
*/
public String
sectionToString(int i) {
if (i > 3)
return null;
StringBuffer sb = new StringBuffer();
Record [] records = getSectionArray(i);
for (int j = 0; j < records.length; j++) {
Record rec = records[j];
if (i == Section.QUESTION) {
sb.append(";;\t" + rec.name);
sb.append(", type = " + Type.string(rec.type));
sb.append(", class = " + DClass.string(rec.dclass));
}
else
sb.append(rec);
sb.append("\n");
}
return sb.toString();
}
代码示例来源:origin: dnsjava/dnsjava
/**
* Converts the given section of the Message to a String.
* @see Section
*/
public String
sectionToString(int i) {
if (i > 3)
return null;
StringBuffer sb = new StringBuffer();
Record [] records = getSectionArray(i);
for (int j = 0; j < records.length; j++) {
Record rec = records[j];
if (i == Section.QUESTION) {
sb.append(";;\t" + rec.name);
sb.append(", type = " + Type.string(rec.type));
sb.append(", class = " + DClass.string(rec.dclass));
}
else
sb.append(rec);
sb.append("\n");
}
return sb.toString();
}
代码示例来源:origin: dnsjava/dnsjava
private void
addAdditional2(Message response, int section, int flags) {
Record [] records = response.getSectionArray(section);
for (int i = 0; i < records.length; i++) {
Record r = records[i];
Name glueName = r.getAdditionalName();
if (glueName != null)
addGlue(response, glueName, flags);
}
}
代码示例来源:origin: OpenNMS/opennms
private void addAdditional2(final Message response, final int section, final int flags) {
final Record[] records = response.getSectionArray(section);
for (int i = 0; i < records.length; i++) {
final Record r = records[i];
final Name glueName = r.getAdditionalName();
if (glueName != null) addGlue(response, glueName, flags);
}
}
代码示例来源:origin: org.echocat.jomon.net/common
private void addAdditional2(Message response, int section, int flags) {
final Record[] records = response.getSectionArray(section);
for (int i = 0; i < records.length; i++) {
final Record r = records[i];
final Name glueName = r.getAdditionalName();
if (glueName != null) {
addGlue(response, glueName, flags);
}
}
}
代码示例来源:origin: org.jboss.resteasy/resteasy-eagledns-fork
private void addAdditional2(Message response, int section, int flags) {
Record[] records = response.getSectionArray(section);
for (Record r : records) {
Name glueName = r.getAdditionalName();
if (glueName != null) {
addGlue(response, glueName, flags);
}
}
}
代码示例来源:origin: julian-klode/dns66
assertArrayEquals(new Record[] {}, responseMsg.getSectionArray(Section.ANSWER));
assertNotEquals(0, responseMsg.getSectionArray(Section.AUTHORITY).length);
assertTrue(responseMsg.getSectionArray(Section.AUTHORITY)[0] instanceof SOARecord);
assertTrue(responseMsg.getSectionArray(Section.AUTHORITY)[0].getTTL() > 0);
代码示例来源:origin: org.apache.hadoop/hadoop-yarn-registry
/**
* Add additional information to a DNS response section if a glue name is
* specified.
*
* @param response the response message.
* @param section the section of the response (e.g. ANSWER, AUTHORITY)
* @param flags the flags.
*/
private void addAdditional2(Message response, int section, int flags) {
Record[] records = response.getSectionArray(section);
for (int i = 0; i < records.length; i++) {
Record r = records[i];
Name glueName = r.getAdditionalName();
if (glueName != null) {
addGlue(response, glueName, flags);
}
}
}
代码示例来源:origin: dnsjava/dnsjava
static void
doAXFR(Message response) throws IOException {
System.out.println("; java dig 0.0 <> " + name + " axfr");
if (response.isSigned()) {
System.out.print(";; TSIG ");
if (response.isVerified())
System.out.println("ok");
else
System.out.println("failed");
}
if (response.getRcode() != Rcode.NOERROR) {
System.out.println(response);
return;
}
Record [] records = response.getSectionArray(Section.ANSWER);
for (int i = 0; i < records.length; i++)
System.out.println(records[i]);
System.out.print(";; done (");
System.out.print(response.getHeader().getCount(Section.ANSWER));
System.out.print(" records, ");
System.out.print(response.getHeader().getCount(Section.ADDITIONAL));
System.out.println(" additional)");
}
代码示例来源:origin: julian-klode/dns66
assertArrayEquals(new Record[] {}, responseMsg.getSectionArray(Section.ANSWER));
assertNotEquals(0, responseMsg.getSectionArray(Section.AUTHORITY).length);
assertTrue(responseMsg.getSectionArray(Section.AUTHORITY)[0] instanceof SOARecord);
assertTrue(responseMsg.getSectionArray(Section.AUTHORITY)[0].getTTL() > 0);
代码示例来源:origin: dnsjava/dnsjava
/**
* Verify a message using SIG(0).
* @param message The message to be signed
* @param b An array containing the message in unparsed form. This is
* necessary since SIG(0) signs the message in wire format, and we can't
* recreate the exact wire format (with the same name compression).
* @param key The KEY record to verify the signature with.
* @param previous If this message is a response, the SIG(0) from the query
*/
public static void
verifyMessage(Message message, byte [] b, KEYRecord key, SIGRecord previous)
throws DNSSEC.DNSSECException
{
SIGRecord sig = null;
Record [] additional = message.getSectionArray(Section.ADDITIONAL);
for (int i = 0; i < additional.length; i++) {
if (additional[i].getType() != Type.SIG)
continue;
if (((SIGRecord) additional[i]).getTypeCovered() != 0)
continue;
sig = (SIGRecord) additional[i];
break;
}
DNSSEC.verifyMessage(message, b, sig, previous, key);
}
代码示例来源:origin: posicks/mdnsjava
protected Message convertUpdateToQueryResponse(final Message update)
{
Message m = new Message();
Header h = m.getHeader();
h.setOpcode(Opcode.QUERY);
h.setFlag(Flags.AA);
h.setFlag(Flags.QR);
Record[] records = update.getSectionArray(Section.UPDATE);
for (int index = 0; index < records.length; index++ )
{
m.addRecord(records[index], Section.ANSWER);
}
records = update.getSectionArray(Section.ADDITIONAL);
for (int index = 0; index < records.length; index++ )
{
m.addRecord(records[index], Section.ADDITIONAL);
}
return m;
}
代码示例来源:origin: org.apache.hadoop/hadoop-yarn-registry
/**
* Add the NXT record to the authority
* section of the response.
*
* @param response the response message.
*/
private void addNXT(Message response, int flags)
throws DNSSEC.DNSSECException, IOException {
Record nxtRecord = getNXTRecord(
response.getSectionArray(Section.QUESTION)[0]);
Zone zone = findBestZone(nxtRecord.getName());
addRecordCommand.exec(zone, nxtRecord);
RRset nxtRR = zone.findExactMatch(nxtRecord.getName(), Type.NXT);
addRRset(nxtRecord.getName(), response, nxtRR, Section.AUTHORITY, flags);
removeRecordCommand.exec(zone, nxtRecord);
}
代码示例来源:origin: org.dspace/dspace-stats
public static String reverseDns(String hostIp) throws IOException {
Resolver res = new ExtendedResolver();
// set the timeout, defaults to 200 milliseconds
int timeout = ConfigurationManager.getIntProperty("solr-statistics", "resolver.timeout", 200);
res.setTimeout(0, timeout);
Name name = ReverseMap.fromAddress(hostIp);
int type = Type.PTR;
int dclass = DClass.IN;
Record rec = Record.newRecord(name, type, dclass);
Message query = Message.newQuery(rec);
Message response = res.send(query);
Record[] answers = response.getSectionArray(Section.ANSWER);
if (answers.length == 0)
{
return hostIp;
}
else
{
return answers[0].rdataToString();
}
}
}
代码示例来源:origin: org.apache.hadoop/hadoop-yarn-registry
Record[] assertDNSQueryNotNull(String lookup, int type, int answerCount)
throws IOException {
Name name = Name.fromString(lookup);
Record question = Record.newRecord(name, type, DClass.IN);
Message query = Message.newQuery(question);
OPTRecord optRecord = new OPTRecord(4096, 0, 0, Flags.DO, null);
query.addRecord(optRecord, Section.ADDITIONAL);
byte[] responseBytes = getRegistryDNS().generateReply(query, null);
Message response = new Message(responseBytes);
assertEquals("not successful", Rcode.NOERROR, response.getRcode());
assertNotNull("Null response", response);
assertEquals("Questions do not match", query.getQuestion(),
response.getQuestion());
Record[] recs = response.getSectionArray(Section.ANSWER);
assertEquals(answerCount, recs.length);
assertEquals(recs[0].getType(), type);
return recs;
}
内容来源于网络,如有侵权,请联系作者删除!