Skip to content

Commit

Permalink
debug: add debug info for dns response parse
Browse files Browse the repository at this point in the history
Signed-off-by: Dengfeng Liu <[email protected]>
  • Loading branch information
liudf0716 committed Jun 12, 2024
1 parent 06e86cf commit 005d856
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/dns_forward.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,14 @@ process_dns_response(unsigned char *response, int response_len) {
for (int i = 0; i < ancount; i++) {
char answer_name[MAX_DNS_NAME] = {0};
parse_name(response, &ptr, answer_name);
debug(LOG_DEBUG, "Answer name: %s", answer_name);

unsigned short type = ntohs(*(unsigned short *)ptr);
ptr += 8; // Skip class, TTL, and data length
unsigned short data_len = ntohs(*(unsigned short *)ptr);
ptr += 2;

debug(LOG_DEBUG, "Type: %d, Data length: %d", type, data_len);
if (type == 1 && data_len == 4) { // Type A record
t_ip_trusted *ip_trusted = p->ips_trusted;
while(ip_trusted) {
Expand Down

0 comments on commit 005d856

Please sign in to comment.