changeset 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 5a88320a7547
children be7355b47051
files src/context.cpp src/dnsbl.cpp
diffstat 2 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/context.cpp	Mon Mar 06 12:30:35 2017 -0800
+++ b/src/context.cpp	Mon Mar 06 14:01:14 2017 -0800
@@ -1126,10 +1126,10 @@
 bool CONTEXT::resolve_spf(const char *from, uint32_t ip, mlfiPriv *priv, int level)
 {
     char buf[maxlen];
+    log(priv->queueid, "looking for %s txt record", from);
     dns_interface(*priv, from, ns_t_txt, false, NULL, buf, maxlen);
     if (*buf) {
-        log(priv->queueid, "found txt record for %s", from);
-        log(priv->queueid, "found txt record value %s", buf);
+        log(priv->queueid, "found txt record %s", buf);
         char *p = buf;
         char *e = p + strlen(p);    // point to trailing null
         while (p = strstr(p, " ip4:")) {
--- a/src/dnsbl.cpp	Mon Mar 06 12:30:35 2017 -0800
+++ b/src/dnsbl.cpp	Mon Mar 06 14:01:14 2017 -0800
@@ -418,8 +418,8 @@
                 txt_answer[0] = '\0';  // return null string if there are no txt answers
                 txt_size--; // allow room for terminating null;
                 while (ns_parserr(&handle, ns_s_an, rrnum++, &rr) == 0) {
+                    if (ns_rr_type(rr) == qtype) {
                     size_t offset = 0;
-                    if (ns_rr_type(rr) == qtype) {
                         size_t rdlen = ns_rr_rdlen(rr);
                         const unsigned char *rdata = ns_rr_rdata(rr);
                         while ((offset < txt_size) && rdlen) {
@@ -432,13 +432,13 @@
                             rdata  += m;
                             rdlen  -= m;
                         }
-                    }
                     txt_answer[offset] = '\0';  // trailing null
                     if (strncasecmp(txt_answer, "v=spf1 ", 7) == 0) break;
                 }
-                if (strncasecmp(txt_answer, "v=spf1 ", 7) != 0) {
-                    txt_answer[0] = '\0';  // return null string if there are no spf1 txt answers
                 }
+                //if (strncasecmp(txt_answer, "v=spf1 ", 7) != 0) {
+                //    txt_answer[0] = '\0';  // return null string if there are no spf1 txt answers
+                //}
             }
         }
     pthread_mutex_unlock(&resolve_mutex);