Mercurial > dnsbl
comparison src/context.cpp @ 415:16451edcb962
spf code now handles mx,exists,ptr tags, multiple A records, %{i} macro
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Tue, 25 Apr 2017 15:23:33 -0700 |
parents | d5a1ed33d3ae |
children | 7431e948b5c3 |
comparison
equal
deleted
inserted
replaced
414:d5a1ed33d3ae | 415:16451edcb962 |
---|---|
1191 // ignore it before looking for (a or a:) below | 1191 // ignore it before looking for (a or a:) below |
1192 } | 1192 } |
1193 else if (strncmp(p, "exists:", 7) == 0) { | 1193 else if (strncmp(p, "exists:", 7) == 0) { |
1194 p += 7; | 1194 p += 7; |
1195 char buf[maxlen]; | 1195 char buf[maxlen]; |
1196 uint32_t ipy = ntohl(dns_interface(*priv, p, ns_t_a, false, NULL, buf, maxlen)); | 1196 dns_interface(*priv, p, ns_t_a, false, NULL, buf, maxlen); |
1197 uint32_t *a = (uint32_t *)buf; | 1197 uint32_t *a = (uint32_t *)buf; |
1198 if (a[0]) { | 1198 if (a[0]) { |
1199 log(priv->queueid, "match exists:%s", p); | 1199 log(priv->queueid, "match exists:%s", p); |
1200 return true; | 1200 return true; |
1201 } | 1201 } |
1202 } | 1202 } |
1203 else if (strncmp(p, "mx", 2) == 0) { | 1203 else if (strncmp(p, "mx", 2) == 0) { |
1204 const char *name = (p[2] == ':') ? p+2 : from; | 1204 const char *name = (p[2] == ':') ? p+2 : from; |
1205 char buf[maxlen]; | 1205 char buf[maxlen]; |
1206 uint32_t c = ntohl(dns_interface(*priv, name, ns_t_mx, false, NULL, buf, maxlen)); | 1206 dns_interface(*priv, name, ns_t_mx, false, NULL, buf, maxlen); |
1207 char *b = buf; | 1207 char *b = buf; |
1208 while (*b) { | 1208 while (*b) { |
1209 log(priv->queueid, "found mx %s", b); | 1209 log(priv->queueid, "found mx %s", b); |
1210 char abuf[maxlen]; | 1210 char buf[maxlen]; |
1211 uint32_t ipy = ntohl(dns_interface(*priv, b, ns_t_a, false, NULL, buf, maxlen)); | 1211 dns_interface(*priv, b, ns_t_a, false, NULL, buf, maxlen); |
1212 uint32_t *a = (uint32_t *)buf; | 1212 uint32_t *a = (uint32_t *)buf; |
1213 size_t c = a[0]; | 1213 size_t c = a[0]; |
1214 for (size_t i=1; i++; i<=c) { | 1214 for (size_t i=1; i<=c; i++) { |
1215 ipy = ntohl(a[i]); | 1215 ipy = ntohl(a[i]); |
1216 if (ipy == ip) { | 1216 if (ipy == ip) { |
1217 log(priv->queueid, "match mx:%s", name); | 1217 log(priv->queueid, "match mx:%s", name); |
1218 return true; | 1218 return true; |
1219 } | 1219 } |
1225 const char *name = (p[1] == ':') ? p+2 : from; | 1225 const char *name = (p[1] == ':') ? p+2 : from; |
1226 char buf[maxlen]; | 1226 char buf[maxlen]; |
1227 uint32_t ipy = ntohl(dns_interface(*priv, name, ns_t_a, false, NULL, buf, maxlen)); | 1227 uint32_t ipy = ntohl(dns_interface(*priv, name, ns_t_a, false, NULL, buf, maxlen)); |
1228 uint32_t *a = (uint32_t *)buf; | 1228 uint32_t *a = (uint32_t *)buf; |
1229 size_t c = a[0]; | 1229 size_t c = a[0]; |
1230 for (size_t i=1; i++; i<=c) { | 1230 for (size_t i=1; i<=c; i++) { |
1231 ipy = ntohl(a[i]); | 1231 ipy = ntohl(a[i]); |
1232 if (ipy == ip) { | 1232 if (ipy == ip) { |
1233 log(priv->queueid, "match a:%s", name); | 1233 log(priv->queueid, "match a:%s", name); |
1234 return true; | 1234 return true; |
1235 } | 1235 } |