]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Problem with TEXT extraction within dns_is_blacklisted
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 13 Jul 2025 15:49:22 +0000 (11:49 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 13 Jul 2025 15:49:22 +0000 (11:49 -0400)
app/Makefile
app/scarmt.c
lib/unidns.c
lib/unidns.h
sql/datatest.sql

index 1e7fc3096eb1bcebb45d7588b2979a9997a67fa5..06647e8ece4e47d8b0c15376df174c308bb3e40c 100644 (file)
@@ -118,6 +118,7 @@ sorter.o:  sorter.c                                 \
 scarmt.o:  scarmt.c                                    \
           ../lib/devsql.h                              \
           ../lib/gessql.h                              \
+          ../lib/unidns.h                              \
           ../lib/unipar.h                              \
           ../lib/uniprc.h                              \
           ../lib/unisig.h                              \
index b131a59b3015f2f48b36159cbb1e0308575e8e6f..b34524f4cc7c9efc830adaa80bb72cef2f66b801 100644 (file)
@@ -17,6 +17,7 @@
 
 #include        "devsql.h"
 #include        "gessql.h"
+#include        "unidns.h"
 #include        "unipar.h"
 #include        "uniprc.h"
 #include        "unisig.h"
@@ -71,7 +72,12 @@ while (proceed==true) {
       srv->lastscan=time((time_t *)0);
       if (dnsbls!=(char **)0) {
         while (*dnsbls!=(char *)0) {
-          (void) rou_alert(0,"%s JMPDBG scan <%s> against <%s>",OPEP,rmtip,*dnsbls);
+          char *listed;
+
+          (void) rou_alert(0,"%s JMPDBG scan <%s> against <%s> result=<%s>",
+                              OPEP,rmtip,*dnsbls,listed);
+          listed=dns_is_blacklisted(*dnsbls,reversip);
+          listed=rou_freestr(listed);
           dnsbls++;
           }
         }
@@ -156,7 +162,7 @@ while (proceed==true) {
           while (taille>0) {
             taille--;
             ptr=line+taille;
-            if ((*ptr!=' ')&&(*ptr!='\t'))
+            if ((*ptr!=' ')&&(*ptr!='\t')&&(*ptr!='\n')&&(*ptr!='\r'))
               break;
             *ptr='\000'; 
             }
index 3296dd8adbdbc31b1de18caf44b599f5d4b8811d..6b766826f348ebe296fa85ce34d8e01da74575c2 100644 (file)
@@ -528,3 +528,32 @@ return status;
 
 #undef  OPEP
 }
+/*
+\f
+*/
+/********************************************************/
+/*                                                     */
+/*     Procedure to probe one black list site about the*/
+/*     remote IP and return a TXT if it is blacklisted.*/
+/*                                                     */
+/********************************************************/
+PUBLIC char *dns_is_blacklisted(char *blssite,char *reversip)
+
+{
+#define OPEP    "unidns.c:dns_is_blacklisted,"
+
+char *listed;
+char **txt;
+char dnsquest[300];
+
+listed=(char *)0;
+(void) snprintf(dnsquest,sizeof(dnsquest),"%s%s",reversip,blssite);
+(void) rou_alert(12,"%s, checking <%s>",OPEP,dnsquest);
+if ((txt=gettxt(dnsquest,T_TXT,"TXT"))!=(char **)0) {
+  (void) rou_asprintf(&listed,"%s -> %s",blssite,txt[0]);
+  txt=(char **)rou_freelist((void **)txt,(genfree_t)rou_freestr);
+  }
+return listed;
+
+#undef  OPEP
+}
index 1e58cfa8c03cb76ced0973d093bdc1e951390cea..489548d42cdae8d1f3e5e134eb4e842d9421ccf3 100644 (file)
@@ -42,4 +42,7 @@ extern _Bool dns_matchiprec(char *hostname,AFNTYP *afnnum,int mask);
 //smtp server
 extern LOCTYP dns_is_domain_local(const char *domain,AFNTYP **afns);
 
+//procedure returning a string if remote IP si blacklisted
+extern char *dns_is_blacklisted(char *blssite,char *reversip);
+
 #endif
index e04f86cb432c2fa2fede4fd40c1a495409e919da..8894854c755e417bde6c4f7df6cba247265bb35b 100644 (file)
@@ -33,6 +33,9 @@ INSERT INTO remotes (remoteip,credit,lastscan)                        \
          values ('127.127.0.25',10,now());
 //---------------------------------------------------------------
 //selected IP from 'known' spammer
+INSERT INTO remotes (remoteip)                                 \
+         values ('122.175.193.134');
+#ifdef BIGRE
 INSERT INTO remotes (remoteip)                                 \
          values ('27.151.45.98');
 INSERT INTO remotes (remoteip)                                 \
@@ -47,6 +50,7 @@ INSERT INTO remotes (remoteip)                                        \
          values ('209.85.218.68');
 INSERT INTO remotes (remoteip)                                 \
          values ('216.246.113.145');
+#endif
 
 //selected IP from from 'clean' server
 INSERT INTO remotes (remoteip)                                 \