dns json: log TXT response data

Log TXT data in the rdata field.
pull/972/head
Victor Julien 12 years ago
parent 683d2d64e9
commit bddb2c3bdc

@ -179,6 +179,17 @@ static void OutputAnswer(LogDnsLogThread *aft, json_t *djs, DNSTransaction *tx,
json_object_set_new(js, "rdata", json_string(a));
} else if (entry->data_len == 0) {
json_object_set_new(js, "rdata", json_string(""));
} else if (entry->type == DNS_RECORD_TYPE_TXT) {
if (entry->data_len != 0) {
char buffer[256] = "";
uint16_t copy_len = entry->data_len < (sizeof(buffer) - 1) ?
entry->data_len : sizeof(buffer) - 1;
memcpy(buffer, ptr, copy_len);
buffer[copy_len] = '\0';
json_object_set_new(js, "rdata", json_string(buffer));
} else {
json_object_set_new(js, "rdata", json_string(""));
}
}
}

Loading…
Cancel
Save