* @see us.codecraft.blackhole.server.Handler#handle(org.xbill.DNS.Message,
* org.xbill.DNS.Message)
*/
@Override
public boolean handle(MessageWrapper request, MessageWrapper response) {
Record question = request.getMessage().getQuestion();
String query = question.getName().toString();
int type = question.getType();
if (type == Type.PTR) {
query = filterPTRQuery(query);
}
// some client will query with any
if (type == Type.ANY) {
type = Type.A;
}
if (logger.isDebugEnabled()) {
logger.debug("query \t" + Type.string(type) + "\t"
+ DClass.string(question.getDClass()) + "\t" + query);
}
for (AnswerProvider answerProvider : getaAnswerProviders()) {
String answer = answerProvider.getAnswer(query, type);
if (answer != null) {
try {
Record record = new RecordBuilder()
.dclass(question.getDClass())
.name(question.getName()).answer(answer).type(type)
.toRecord();
response.getMessage().addRecord(record, Section.ANSWER);
if (logger.isDebugEnabled()) {