]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Starting main test program chkdns
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 14 Aug 2024 14:09:52 +0000 (10:09 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 14 Aug 2024 14:09:52 +0000 (10:09 -0400)
app/chkdns.c
lib/subrou.c
lib/unidns.c
lib/unidns.h

index 16d349d77f43ebe2bf52be8c7317021a7fbd069c..375963d8d9303fb5799c5742edecc841ca161eda 100644 (file)
@@ -1,11 +1,13 @@
 // vim: smarttab tabstop=8 shiftwidth=2 expandtab
 /********************************************************/
 /*                                                     */
-/*     Main SMTP Daemon                                */
+/*     Validation program to check SPF extraction      */
+/*      library.                                        */
 /*                                                     */
 /********************************************************/
 #include       <stdio.h>
 #include       <stdlib.h>
+#include       <string.h>
 #include       <unistd.h>
 
 #include       "subrou.h"
@@ -26,20 +28,39 @@ int main(int argc,char *argv[])
 
 {
 int status;
+char *curname;
 int phase;
 _Bool proceed;
 
 status=0;
+if ((curname=strrchr(argv[0],'/'))==(char *)0)
+  curname=argv[0];
+else
+  curname++;
 phase=0;
 proceed=true;
 while (proceed==true) {
   switch (phase) {
     case 0      :       //checking parameters
+      foreground=true;
+      (void) rou_setappname(curname);
+      if (argc<2) {
+        (void) rou_alert(0,"%s need 2 arguments (domain,IP)",appname);
+        for (int i=1;i<optind;i++) 
+          (void) rou_alert(0,"\targ[%d]=<%s>",i,argv[i]);
+        phase=999;
+        }
       break;
     case 1      :       //initialising process
       (void) rou_modesubrou(true);
       break;
     case 2      :       //doing main tash
+      if (argv[1]!=(char *)0) { //always
+        SPFENU spf;
+
+        spf=dns_get_spf_status(argv[1],argv[2]);
+        (void) rou_alert(0,"%s %s ==> %s",argv[1],argv[2],dns_spfascii(spf));
+        }
       break;
     case 3      :       //doing main tash
       (void) rou_modesubrou(false);
index 93186e70ce8b10882ab6fac07b3b617ee340926a..1b537844072805bf27be085ae49de4c9478950ea 100644 (file)
@@ -21,7 +21,7 @@
 
 //version definition 
 #define VERSION "0.4.2"
-#define RELEASE "1"
+#define RELEASE "2"
 
 //Public variables
 PUBLIC  int debug=0;            //debug level
index 805285122ccc0a09650b493b1d568b64245799cf..13ad64d5bdd5dbfb20362ae75b7eff4c07bf0b45 100644 (file)
 
 static  _Bool modopen;          //module open/close status
 
+/*
+^L
+*/
+/********************************************************/
+/*                                                      */
+/*     Procedure to return the SPF status string value */
+/*                                                      */
+/********************************************************/
+PUBLIC const char *dns_spfascii(SPFENU spf)
+
+{
+static char *spfascii[]=
+        {
+        "spf_pass",
+        "spf_fail",
+        "spf_softfail",
+        "spf_neutral",
+        "spf_timeout",
+        "spf_missing",
+        "spf_unknown"
+        };
+
+const char *ascii;
+
+ascii="Unset (Bug?)";
+switch  (spf) {
+  case spf_pass         :
+  case spf_fail         :
+  case spf_softfail     :
+  case spf_neutral      :
+  case spf_timeout      :
+  case spf_missing      :
+  case spf_unknown      :
+    ascii=spfascii[spf];
+    break;
+  default       :
+    break;
+  }
+return ascii;
+}
+/*
+^L
+*/
+/********************************************************/
+/*                                                      */
+/*     Procedure to get the SPF status according a     */
+/*      domain name and and an IP.                      */
+/*                                                      */
+/********************************************************/
+PUBLIC SPFENU dns_get_spf_status(char *domain,char *peerip)
+
+{
+SPFENU spf;
+
+spf=spf_unknown;
+return spf;
+}
 /*
 ^L
 */
index fbfdbd9eee6de3f4343e3b1f862dd040e9ca948b..9b37cba234e4fcb1a680268561990601547d6dd0 100644 (file)
@@ -8,6 +8,22 @@
 #ifndef        UNIDNS
 #define UNIDNS
 
+typedef        enum    {
+       spf_pass,       //OK if condition apply
+       spf_fail,       //NOK if condition apply
+       spf_softfail,   //Msg origin is dubious
+       spf_neutral,    //same status as no SPF
+       spf_timeout,    //no answer within time
+       spf_missing,    //SPF not found
+       spf_unknown     //Unknown SPF directive
+       }SPFENU;
+
+//procedure to return spf status as an ASCII string
+extern const char *dns_spfascii(SPFENU spf);
+
+//get the SPF status for a specific domain and a remote peer IP
+extern SPFENU dns_get_spf_status(char *domain,char *peerip);
+
 //homework to be done before starting/stopping module.
 extern int dns_modeunidns(_Bool mode);