本文整理了Java中org.xbill.DNS.Header
类的一些代码示例,展示了Header
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Header
类的具体详情如下:
包路径:org.xbill.DNS.Header
类名称:Header
暂无
代码示例来源:origin: dnsjava/dnsjava
/** Converts the header into a String */
public String
toString() {
return toStringWithRcode(getRcode());
}
代码示例来源:origin: dnsjava/dnsjava
/**
* Creates a new Message with a random Message ID suitable for sending as a
* query.
* @param r A record containing the question
*/
public static Message
newQuery(Record r) {
Message m = new Message();
m.header.setOpcode(Opcode.QUERY);
m.header.setFlag(Flags.RD);
m.addRecord(r, Section.QUESTION);
return m;
}
代码示例来源:origin: dnsjava/dnsjava
boolean []
getFlags() {
boolean [] array = new boolean[16];
for (int i = 0; i < array.length; i++)
if (validFlag(i))
array[i] = getFlag(i);
return array;
}
代码示例来源:origin: julian-klode/dns66
} else {
Log.i(TAG, "handleDnsRequest: DNS Name " + dnsQueryName + " Blocked!");
dnsMsg.getHeader().setFlag(Flags.QR);
dnsMsg.getHeader().setRcode(Rcode.NOERROR);
dnsMsg.addRecord(NEGATIVE_CACHE_SOA_RECORD, Section.AUTHORITY);
handleDnsResponse(parsedPacket, dnsMsg.toWire());
代码示例来源:origin: dnsjava/dnsjava
/**
* Sets a flag to the supplied value
* @see Flags
*/
public void
setFlag(int bit) {
checkFlag(bit);
flags = setFlag(flags, bit, true);
}
代码示例来源:origin: org.apache.hadoop/hadoop-yarn-registry
if (header.getFlag(Flags.QR)) {
LOG.debug("returning null");
return null;
if (header.getRcode() != Rcode.NOERROR) {
return errorMessage(query, Rcode.FORMERR);
if (header.getOpcode() != Opcode.QUERY) {
return errorMessage(query, Rcode.NOTIMP);
Message response = new Message(query.getHeader().getID());
response.getHeader().setFlag(Flags.QR);
if (query.getHeader().getFlag(Flags.RD)) {
response.getHeader().setFlag(Flags.RD);
response.getHeader().setFlag(Flags.RA);
if (rcode != Rcode.NOERROR) {
rcode = remoteLookup(response, name, type, 0);
response.getHeader().setRcode(rcode);
代码示例来源:origin: net.sf.dnsjava-osgi/dnsjava-osgi
Message(DNSInput in) throws IOException {
this(new Header(in));
boolean isUpdate = (header.getOpcode() == Opcode.UPDATE);
boolean truncated = header.getFlag(Flags.TC);
try {
for (int i = 0; i < 4; i++) {
int count = header.getCount(i);
if (count > 0)
sections[i] = new ArrayList(count);
for (int j = 0; j < count; j++) {
int pos = in.current();
Record rec = Record.fromWire(in, i, isUpdate);
sections[i].add(rec);
if (rec.getType() == Type.TSIG)
tsigstart = pos;
}
}
} catch (WireParseException e) {
if (!truncated)
throw e;
}
size = in.current();
}
代码示例来源:origin: dnsjava/dnsjava
String
toStringWithRcode(int newrcode) {
StringBuffer sb = new StringBuffer();
sb.append(";; ->>HEADER<<- ");
sb.append("opcode: " + Opcode.string(getOpcode()));
sb.append(", status: " + Rcode.string(newrcode));
sb.append(", id: " + getID());
sb.append("\n");
sb.append(";; flags: " + printFlags());
sb.append("; ");
for (int i = 0; i < 4; i++)
sb.append(Section.string(i) + ": " + getCount(i) + " ");
return sb.toString();
}
代码示例来源:origin: posicks/mdnsjava
if ((messages != null) && (messages.length > 0))
header.setRcode(Rcode.NOERROR);
header.setOpcode(Opcode.QUERY);
header.setFlag(Flags.QR);
if (h.getRcode() == Rcode.NOERROR)
if (h.getFlag(Flags.AA))
header.setFlag(Flags.AA);
if (h.getFlag(Flags.AD))
header.setFlag(Flags.AD);
header.setRcode(Rcode.NXDOMAIN);
代码示例来源:origin: tiandawu/IotXmpp
header.toWire(out);
Compression c = new Compression();
for (int i = 0; i < 4; i++) {
if (skipped != 0) {
if (newheader == null)
newheader = (Header) header.clone();
if (i != Section.ADDITIONAL)
newheader.setFlag(Flags.TC);
int count = newheader.getCount(i);
newheader.setCount(i, count - skipped);
for (int j = i + 1; j < 4; j++)
newheader.setCount(j, 0);
newheader.toWire(out);
out.restore();
break;
newheader = (Header) header.clone();
tsigrec.toWire(out, Section.ADDITIONAL, c);
newheader.incCount(Section.ADDITIONAL);
newheader.toWire(out);
out.restore();
代码示例来源:origin: RIPE-NCC/hadoop-pcap
@Override
protected void processPacketPayload(Packet packet, byte[] payload) {
String protocol = (String)packet.get(Packet.PROTOCOL);
if (!PcapReader.PROTOCOL_UDP.equals(protocol) && !PcapReader.PROTOCOL_TCP.equals(protocol))
return;
DnsPacket dnsPacket = (DnsPacket)packet;
if (DNS_PORT == (Integer)packet.get(Packet.SRC_PORT) || DNS_PORT == (Integer)packet.get(Packet.DST_PORT)) {
if (PROTOCOL_TCP.equals(protocol) &&
payload.length > 2) // TODO Support DNS responses with multiple messages (as used for XFRs)
payload = Arrays.copyOfRange(payload, 2, payload.length); // First two bytes denote the size of the DNS message, ignore them
try {
Message msg = new Message(payload);
Header header = msg.getHeader();
dnsPacket.put(DnsPacket.QUERYID, header.getID());
dnsPacket.put(DnsPacket.FLAGS, header.printFlags());
dnsPacket.put(DnsPacket.QR, header.getFlag(Flags.QR));
dnsPacket.put(DnsPacket.OPCODE, Opcode.string(header.getOpcode()));
dnsPacket.put(DnsPacket.RCODE, Rcode.string(header.getRcode()));
dnsPacket.put(DnsPacket.QUESTION, convertRecordToString(msg.getQuestion()));
dnsPacket.put(DnsPacket.QNAME, convertRecordOwnerToString(msg.getQuestion()));
dnsPacket.put(DnsPacket.QTYPE, convertRecordTypeToInt(msg.getQuestion()));
dnsPacket.put(DnsPacket.ANSWER, convertRecordsToStrings(msg.getSectionArray(Section.ANSWER)));
dnsPacket.put(DnsPacket.AUTHORITY, convertRecordsToStrings(msg.getSectionArray(Section.AUTHORITY)));
dnsPacket.put(DnsPacket.ADDITIONAL, convertRecordsToStrings(msg.getSectionArray(Section.ADDITIONAL)));
} catch (Exception e) {
// If we cannot decode a DNS packet we ignore it
}
}
}
代码示例来源:origin: org.nhind/dns
/**
* Processes a DNS error condition and creates an appropriate DNS response.
* @param request The original DNS request.
* @param error The error condition that occured.
* @return A response to the DNS request.
*/
protected Message processError(Message request, DNSError<?> error)
{
Message errorResponse = null;
try
{
Header respHeader = new Header(request.toWire());
Message response = new Message();
response.setHeader(respHeader);
for (int i = 0; i < 4; i++)
response.removeAllRecords(i);
response.addRecord(request.getQuestion(), Section.QUESTION);
response.getHeader().setFlag(Flags.QR);
if (request.getHeader().getFlag(Flags.RD))
response.getHeader().setFlag(Flags.RD);
respHeader.setRcode(Integer.parseInt(error.getError().toString()));
return response;
}
catch (IOException e) {}
return errorResponse;
}
代码示例来源:origin: dnsjava/dnsjava
private Message
sendAXFR(Message query) throws IOException {
Name qname = query.getQuestion().getName();
ZoneTransferIn xfrin = ZoneTransferIn.newAXFR(qname, address, tsig);
xfrin.setTimeout((int)(getTimeout() / 1000));
xfrin.setLocalAddress(localAddress);
try {
xfrin.run();
}
catch (ZoneTransferException e) {
throw new WireParseException(e.getMessage());
}
List records = xfrin.getAXFR();
Message response = new Message(query.getHeader().getID());
response.getHeader().setFlag(Flags.AA);
response.getHeader().setFlag(Flags.QR);
response.addRecord(query.getQuestion(), Section.QUESTION);
Iterator it = records.iterator();
while (it.hasNext())
response.addRecord((Record)it.next(), Section.ANSWER);
return response;
}
代码示例来源:origin: posicks/mdnsjava
public static Message newQueryResponse(final Record[] records, final int section)
{
Message message = new Message();
Header header = message.getHeader();
header.setRcode(Rcode.NOERROR);
header.setOpcode(Opcode.QUERY);
header.setFlag(Flags.QR);
for (int index = 0; index < records.length; index++)
{
message.addRecord(records[index], section);
}
return message;
}
代码示例来源:origin: org.littleshoot/dnsjava
/**
* Returns the message's rcode (error code). This incorporates the EDNS
* extended rcode.
*/
public int
getRcode() {
int rcode = header.getRcode();
OPTRecord opt = getOPT();
if (opt != null)
rcode += (opt.getExtendedRcode() << 4);
return rcode;
}
代码示例来源:origin: posicks/mdnsjava
header.setID(0);
applyEDNS(message);
if (tsig != null)
if (header.getFlag(Flags.QR))
resolverListenerDispatcher.handleException(message.getHeader().getID(), e);
代码示例来源:origin: dnsjava/dnsjava
/** Creates a new Message with a random Message ID */
public
Message() {
this(new Header());
}
代码示例来源:origin: org.littleshoot/dnsjava
/**
* Converts the Message to a String.
*/
public String
toString() {
StringBuffer sb = new StringBuffer();
OPTRecord opt = getOPT();
if (opt != null)
sb.append(header.toStringWithRcode(getRcode()) + "\n");
else
sb.append(header + "\n");
if (isSigned()) {
sb.append(";; TSIG ");
if (isVerified())
sb.append("ok");
else
sb.append("invalid");
sb.append('\n');
}
for (int i = 0; i < 4; i++) {
if (header.getOpcode() != Opcode.UPDATE)
sb.append(";; " + Section.longString(i) + ":\n");
else
sb.append(";; " + Section.updString(i) + ":\n");
sb.append(sectionToString(i) + "\n");
}
sb.append(";; Message size: " + numBytes() + " bytes");
return sb.toString();
}
代码示例来源:origin: org.littleshoot/dnsjava
/**
* Create a new empty header.
* @param id The message id
*/
public
Header(int id) {
init();
setID(id);
}
代码示例来源:origin: tiandawu/IotXmpp
out.writeByteArray(previous.getSignature());
Header header = (Header) message.getHeader().clone();
header.decCount(Section.ADDITIONAL);
out.writeByteArray(header.toWire());
内容来源于网络,如有侵权,请联系作者删除!