changeset 385:be7355b47051

start parsing spf txt records
author Carl Byington <carl@five-ten-sg.com>
date Mon, 06 Mar 2017 14:30:41 -0800
parents 7b7066a51c33
children e27e22f6a49a
files NEWS src/dnsbl.cpp
diffstat 2 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Mon Mar 06 14:01:14 2017 -0800
+++ b/NEWS	Mon Mar 06 14:30:41 2017 -0800
@@ -1,4 +1,4 @@
-6.51 2017-02-28 fetch spf txt records for required dkim signers
+6.51 2017-03-06 parse spf txt records for required dkim signers
 6.50 2017-02-22 reject if dkim signer is listed on surbl
 6.49 2017-02-08 RHEL7 systemd and /var/run on tmpfs
 6.48 2016-12-17 Add dkim white/black listing
--- a/src/dnsbl.cpp	Mon Mar 06 14:01:14 2017 -0800
+++ b/src/dnsbl.cpp	Mon Mar 06 14:30:41 2017 -0800
@@ -337,11 +337,11 @@
     char *buf = (char *)&glom;
     priv.my_read(buf, sizeof(glom.length));
     buf += sizeof(glom.length);
-    #ifdef RESOLVER_DEBUG
+    //#ifdef RESOLVER_DEBUG
         char text[1000];
         snprintf(text, sizeof(text), "dns_interface() wrote question %s and has answer length %d", question, glom.length);
         my_syslog(text);
-    #endif
+    //#endif
     if (glom.length == 0) return 0;
     if (glom.length > sizeof(glom.answer)) {
         priv.err = true;
@@ -422,6 +422,11 @@
                         size_t offset = 0;
                         size_t rdlen = ns_rr_rdlen(rr);
                         const unsigned char *rdata = ns_rr_rdata(rr);
+                        //#ifdef RESOLVER_DEBUG
+                            char text[1000];
+                            snprintf(text, sizeof(text), "found txt record rdlen = %d", rdlen);
+                            my_syslog(text);
+                        //#endif
                         while ((offset < txt_size) && rdlen) {
                             size_t slen = size_t(*(rdata++));
                             rdlen--;
@@ -433,6 +438,10 @@
                             rdlen  -= m;
                         }
                         txt_answer[offset] = '\0';  // trailing null
+                        //#ifdef RESOLVER_DEBUG
+                            snprintf(text, sizeof(text), "found txt record %s", txt_answer);
+                            my_syslog(text);
+                        //#endif
                         if (strncasecmp(txt_answer, "v=spf1 ", 7) == 0) break;
                     }
                 }
@@ -878,11 +887,11 @@
 
         // find the answer
 #ifdef NS_PACKETSZ
-        #ifdef RESOLVER_DEBUG
+        //#ifdef RESOLVER_DEBUG
             char text[1000];
             snprintf(text, sizeof(text), "process_resolver_requests() has a question %s qtype %d", question+1, int8_t(question[0]));
             my_syslog(text);
-        #endif
+        //#endif
         int res_result = res_search(question+1, ns_c_in, int8_t(question[0]), glom.answer, sizeof(glom.answer));
         if (res_result < 0) glom.length = 0;   // represent all errors as zero length answers
         else                glom.length = (size_t)res_result;