changeset 390:bcef093b1ba6

start parsing spf txt records
author Carl Byington <carl@five-ten-sg.com>
date Mon, 06 Mar 2017 17:14:41 -0800
parents aa9795b407e8
children 88ef2b4e6f1e
files src/context.cpp src/dnsbl.cpp
diffstat 2 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/context.cpp	Mon Mar 06 16:55:44 2017 -0800
+++ b/src/context.cpp	Mon Mar 06 17:14:41 2017 -0800
@@ -1132,7 +1132,7 @@
         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:")) {
+        while ((p = strstr(p, " ip4:"))) {
             p += 5;
             char *b = strchr(p, ' ');
             if (b) *b = '\0';
--- a/src/dnsbl.cpp	Mon Mar 06 16:55:44 2017 -0800
+++ b/src/dnsbl.cpp	Mon Mar 06 17:14: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,11 +422,11 @@
                         size_t offset = 0;
                         size_t rdlen = ns_rr_rdlen(rr);
                         const unsigned char *rdata = ns_rr_rdata(rr);
-                        //#ifdef RESOLVER_DEBUG
+                        #ifdef RESOLVER_DEBUG
                             char text[1000];
                             snprintf(text, sizeof(text), "found txt record rdlen = %d", rdlen);
                             my_syslog(text);
-                        //#endif
+                        #endif
                         while ((offset < txt_size) && rdlen) {
                             size_t slen = size_t(*(rdata++));
                             rdlen--;
@@ -438,16 +438,16 @@
                             rdlen  -= m;
                         }
                         txt_answer[offset] = '\0';  // trailing null
-                        //#ifdef RESOLVER_DEBUG
+                        #ifdef RESOLVER_DEBUG
                             snprintf(text, sizeof(text), "found txt record %s", txt_answer);
                             my_syslog(text);
-                        //#endif
+                        #endif
                         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);
@@ -889,12 +889,12 @@
 #ifdef NS_PACKETSZ
         int qt = int8_t(question[0]);
         int res_result = res_query(question+1, ns_c_in, qt, glom.answer, sizeof(glom.answer));
-        //#ifdef RESOLVER_DEBUG
+        #ifdef RESOLVER_DEBUG
             char text[1000];
             snprintf(text, sizeof(text), "process_resolver_requests() has a question %s qtype %d buf len %d result %d",
                                          question+1, qt, sizeof(glom.answer), res_result);
             my_syslog(text);
-        //#endif
+        #endif
         if (res_result < 0) glom.length = 0;   // represent all errors as zero length answers
         else                glom.length = (size_t)res_result;
 #else