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

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

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

Message.setHeader介绍

暂无

代码示例

代码示例来源:origin: undera/jmeter-plugins

protected byte[] getMessageBytes(String data) {
  Message msg = new Message();
  String recs[] = data.split(NL);
  for (String rec : recs) {
    if (rec.length() <= 3) {
      Header head = msg.getHeader();
      int val = Integer.parseInt(rec.trim());
      if (val < 0) {
        head.unsetFlag(-val);
      } else {
        head.setFlag(val);
      }
      msg.setHeader(head);
    } else {
      msg.addRecord(getRecord(rec.trim()), Section.QUESTION);
    }
  }
  return msg.toWire();
}

代码示例来源:origin: kg.apc/jmeter-plugins-extras-libs

protected byte[] getMessageBytes(String data) {
  Message msg = new Message();
  String recs[] = data.split(NL);
  for (String rec : recs) {
    if (rec.length() <= 3) {
      Header head = msg.getHeader();
      int val = Integer.parseInt(rec.trim());
      if (val < 0) {
        head.unsetFlag(-val);
      } else {
        head.setFlag(val);
      }
      msg.setHeader(head);
    } else {
      msg.addRecord(getRecord(rec.trim()), Section.QUESTION);
    }
  }
  return msg.toWire();
}

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

byte[] buildErrorMessage(final Header header, final int rcode, final Record question) {
  final Message response = new Message();
  response.setHeader(header);
  for (int i = 0; i < 4; i++)
    response.removeAllRecords(i);
  if (rcode == Rcode.SERVFAIL)
    response.addRecord(question, Section.QUESTION);
  header.setRcode(rcode);
  return response.toWire();
}

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

byte[] buildErrorMessage(Header header, int rcode, Record question) {
  final Message response = new Message();
  response.setHeader(header);
  for (int i = 0; i < 4; i++) {
    response.removeAllRecords(i);
  }
  if (rcode == Rcode.SERVFAIL) {
    response.addRecord(question, Section.QUESTION);
  }
  header.setRcode(rcode);
  return response.toWire();
}

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

byte []
buildErrorMessage(Header header, int rcode, Record question) {
  Message response = new Message();
  response.setHeader(header);
  for (int i = 0; i < 4; i++)
    response.removeAllRecords(i);
  if (rcode == Rcode.SERVFAIL)
    response.addRecord(question, Section.QUESTION);
  header.setRcode(rcode);
  return response.toWire();
}

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

private byte[] buildErrorMessage(Header header, int rcode, Record question) {
  Message response = new Message();
  response.setHeader(header);
  for (int i = 0; i < 4; i++) {
    response.removeAllRecords(i);
  }
  if (rcode == Rcode.SERVFAIL) {
    response.addRecord(question, Section.QUESTION);
  }
  header.setRcode(rcode);
  return response.toWire();
}

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

/**
 * Create an error message.
 *
 * @param header   the response header.
 * @param rcode    the response code.
 * @param question the question record.
 * @return  the error message.
 */
byte[] buildErrorMessage(Header header, int rcode, Record question) {
 Message response = new Message();
 response.setHeader(header);
 for (int i = 0; i < 4; i++) {
  response.removeAllRecords(i);
 }
 response.addRecord(question, Section.QUESTION);
 header.setRcode(rcode);
 return response.toWire();
}

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

header.setCount(2, 0);
  header.setCount(3, 0);
  m.setHeader(header);
  m.addRecord(records[index], section);
} else

代码示例来源: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: github/elasticsearch-srv-discovery

@Override
  public Message send(Message query) throws IOException {
    final String HOSTNAME = "localhost.";
    if (query.getQuestion().getName().toString().equals(Constants.TEST_QUERY)) {
      Record question = Record.newRecord(query.getQuestion().getName(), Type.SRV, DClass.IN);
      Message queryMessage = Message.newQuery(question);
      Message result = new Message();
      result.setHeader(queryMessage.getHeader());
      result.addRecord(question, Section.QUESTION);
      result.addRecord(new SRVRecord(query.getQuestion().getName(), DClass.IN, 1, 1, 1, Constants.NODE_0_TRANSPORT_TCP_PORT, Name.fromString(HOSTNAME)), Section.ANSWER);
      result.addRecord(new SRVRecord(query.getQuestion().getName(), DClass.IN, 1, 1, 1, Constants.NODE_1_TRANSPORT_TCP_PORT, Name.fromString(HOSTNAME)), Section.ANSWER);
      result.addRecord(new SRVRecord(query.getQuestion().getName(), DClass.IN, 1, 1, 1, Constants.NODE_2_TRANSPORT_TCP_PORT, Name.fromString(HOSTNAME)), Section.ANSWER);
      result.addRecord(new SRVRecord(query.getQuestion().getName(), DClass.IN, 1, 1, 1, Constants.NODE_3_TRANSPORT_TCP_PORT, Name.fromString(HOSTNAME)), Section.ANSWER);
      result.addRecord(new SRVRecord(query.getQuestion().getName(), DClass.IN, 1, 1, 1, Constants.NODE_4_TRANSPORT_TCP_PORT, Name.fromString(HOSTNAME)), Section.ANSWER);
      return result;
    }
    if (query.getQuestion().getName().toString().equals(HOSTNAME)) {
      Record question = Record.newRecord(query.getQuestion().getName(), Type.A, DClass.IN);
      Message queryMessage = Message.newQuery(question);
      Message result = new Message();
      result.setHeader(queryMessage.getHeader());
      result.addRecord(question, Section.QUESTION);
      result.addRecord(new ARecord(query.getQuestion().getName(), DClass.IN, 1, InetAddress.getLoopbackAddress()), Section.ANSWER);
      return result;
    }
    throw new IllegalArgumentException("Unknown test query: " + query.getQuestion().getName().toString());
  }
};

相关文章