Mercurial > dnsbl
comparison src/dnsbl.cpp @ 384:7b7066a51c33
start parsing spf txt records
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 06 Mar 2017 14:01:14 -0800 |
parents | c378e9d03f37 |
children | be7355b47051 |
comparison
equal
deleted
inserted
replaced
383:5a88320a7547 | 384:7b7066a51c33 |
---|---|
416 } | 416 } |
417 if ((qtype == ns_t_txt) && (txt_answer) && (txt_size > 7)) { | 417 if ((qtype == ns_t_txt) && (txt_answer) && (txt_size > 7)) { |
418 txt_answer[0] = '\0'; // return null string if there are no txt answers | 418 txt_answer[0] = '\0'; // return null string if there are no txt answers |
419 txt_size--; // allow room for terminating null; | 419 txt_size--; // allow room for terminating null; |
420 while (ns_parserr(&handle, ns_s_an, rrnum++, &rr) == 0) { | 420 while (ns_parserr(&handle, ns_s_an, rrnum++, &rr) == 0) { |
421 size_t offset = 0; | |
422 if (ns_rr_type(rr) == qtype) { | 421 if (ns_rr_type(rr) == qtype) { |
422 size_t offset = 0; | |
423 size_t rdlen = ns_rr_rdlen(rr); | 423 size_t rdlen = ns_rr_rdlen(rr); |
424 const unsigned char *rdata = ns_rr_rdata(rr); | 424 const unsigned char *rdata = ns_rr_rdata(rr); |
425 while ((offset < txt_size) && rdlen) { | 425 while ((offset < txt_size) && rdlen) { |
426 size_t slen = size_t(*(rdata++)); | 426 size_t slen = size_t(*(rdata++)); |
427 rdlen--; | 427 rdlen--; |
430 memcpy(txt_answer+offset, rdata, m); | 430 memcpy(txt_answer+offset, rdata, m); |
431 offset += m; | 431 offset += m; |
432 rdata += m; | 432 rdata += m; |
433 rdlen -= m; | 433 rdlen -= m; |
434 } | 434 } |
435 txt_answer[offset] = '\0'; // trailing null | |
436 if (strncasecmp(txt_answer, "v=spf1 ", 7) == 0) break; | |
435 } | 437 } |
436 txt_answer[offset] = '\0'; // trailing null | 438 } |
437 if (strncasecmp(txt_answer, "v=spf1 ", 7) == 0) break; | 439 //if (strncasecmp(txt_answer, "v=spf1 ", 7) != 0) { |
438 } | 440 // txt_answer[0] = '\0'; // return null string if there are no spf1 txt answers |
439 if (strncasecmp(txt_answer, "v=spf1 ", 7) != 0) { | 441 //} |
440 txt_answer[0] = '\0'; // return null string if there are no spf1 txt answers | |
441 } | |
442 } | 442 } |
443 } | 443 } |
444 pthread_mutex_unlock(&resolve_mutex); | 444 pthread_mutex_unlock(&resolve_mutex); |
445 #ifdef RESOLVER_DEBUG | 445 #ifdef RESOLVER_DEBUG |
446 snprintf(text, sizeof(text), "dns_interface() found ip %d", ret_address); | 446 snprintf(text, sizeof(text), "dns_interface() found ip %d", ret_address); |