]> SAFE projects GIT repository - jmp/mailleur/commitdiff
config with SMTP is woring fine
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 11 Jun 2025 11:58:33 +0000 (07:58 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 11 Jun 2025 11:58:33 +0000 (07:58 -0400)
conf/mailleur.conf.dvl
lib/modrec.c
lib/modrec.h
lib/unitls.c
lib/unitls.h

index 8b6ab889fb5db287930f3eba845ad96118f59da6..3e65d8e2d8b586645526b61c43e5278565c3b624 100644 (file)
@@ -5,9 +5,13 @@
 #format
 #protocol:ipnum:port:iteration[,protocol:ipnum:port:iteration]++
 #example
-#:ipnum:::             -> smtp:ipnum:25:1
-#stmtps:ipnum:465:2    -> smtps protocol,port 465,2 iteration
-#SMTPPORTS     =       "::,:127.127.10.25:1025:,smtps:127.127.10.25:1026:1"
+#stmtps:ipnum:465:5    -> protocol smtps:IP number:port 465:5 iterations
+#:ipnum:::             -> smtp:ipnum:25:2
+#::,smtps::465:2       -> smtp:0.0.0.0:25:2 + smtps::465:2
+#::                    -> smtp:0.0.0.0:25:2
+#SMTPPORTS     "       "::"
+#SMTPPORTS     =       ":127.127.10.25:1025:,smtps:127.127.10.25:1026:1"
+SMTPPORTS      =       ":127.127.10.25:1025:"
 #------------------------------------------------
 #Defining SERVER mode Certificate data
 CA_ROOT_SRV    =       "./certs/root-safe_CA.pem"
index 7c9d6ee161f8f342aaee4c9b8ff0d0d8a6d7c85b..889b7f96340fb33f468e45504143d9836b7e0cce 100644 (file)
 /*              -> smtps protocol,port 465,2 iteration  */
 /*                                                     */
 /********************************************************/
-static int prepbinding(SOCPTR ***bindings,int argc,char *argv[])
+static int prepbinding(SOCPTR ***bindings)
 
 {
 #define OPEP    "modrec.c:prepbinding"
 
-*bindings=(SOCPTR **)0;
-for (int i=0;i<argc;i++) {
-  int iteration;
-  PROTYP proto;
-  char *ipnum;
-  char *port;
-  char *ptr;
-  char config[80];
-
-  (void) strcpy(config,"");
-  (void) strncpy(config,argv[i],sizeof(config)-strlen(config));
-  ptr=config;
-  iteration=1;
-  proto=pro_smtp; 
-  ipnum=DFLTIP;
-  port=SMTPORT;
-  for (int j=0;j<3;j++) {
-    char *sofar;
+LISTYP **l;
 
-    if ((sofar=strchr(ptr,':'))==(char *)0) 
-      break;
-    *sofar='\000';
-    sofar++;
-    switch (j) {
-      case 0    :
-        if ((proto=tls_getprotocol(ptr))==pro_unknwn) {
-          (void) rou_alert(0,"%s, protocol unknown within config <%s>",
-                             OPEP,argv[i]);
-          proto=pro_smtp;
-          }
-        break;
-      case 1    :
-        ipnum=ptr;
-        break;
-      case 2    :
-        if (strlen(ptr)>0) 
-          port=ptr;
-        if (strlen(sofar)>0) 
-          iteration=atoi(sofar);
-        break;
-      default   :
-        (void) rou_alert(0,"%s, Code fault, '%d' unexpected value",OPEP,j);
-        break;
-      }
-    ptr=sofar;
-    }
-  *bindings=soc_mkbindinf(*bindings,proto,ipnum,port,iteration);
+*bindings=(SOCPTR **)0;
+if ((l=tls_get_bind_data())==(LISTYP **)0) {
+  (void) rou_alert(0,"%s SMTPPORTS data fully missing (config?, bug?)",OPEP);
+  (void) exit(-1);
+  }
+while (*l!=(LISTYP *)0) {
+  *bindings=soc_mkbindinf(*bindings,(*l)->proto,(*l)->ipnum,(*l)->port,(*l)->iter);
+  l++;
   }
 return rou_nbrlist(*bindings);
 #undef  OPEP
@@ -278,7 +241,8 @@ while (proceed==true) {
     case 1      :       //binding on channel
       if (soc_openbinding(socptr)==false) {
         (void) rou_alert(0,"%s Aborting binding (config?)",OPEP);
-        phase=999;      //no need to go further
+        (void) sleep(5);        //to avoid avalanche
+        phase=999;
         }
       break;
     case 2      :       //waiting
@@ -306,7 +270,7 @@ while (proceed==true) {
 /*      Waiting and handling smtp request               */
 /*                                                     */
 /********************************************************/
-PUBLIC void rec_handlesmtp(int argc,char *argv[])
+PUBLIC void rec_handlesmtp()
 
 {
 #define OPEP    "modrec.c:rec_handlesmtp"
@@ -329,7 +293,7 @@ while (proceed==true) {
   //(void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase);
   switch (phase) {
     case 0      :       //preparing iteration
-      if ((nbrbind=prepbinding(&bindings,argc,argv))==0) {
+      if ((nbrbind=prepbinding(&bindings))==0) {
         (void) rou_alert(0,"%s, No listening IP found (config?)",OPEP);
         phase=999;
         }
index e13e74759269524858ef5c7255acb16ac0f1b974..01be0b79f858920c7e6716018c2fe7b4f5cd27a5 100644 (file)
@@ -10,6 +10,6 @@
 #include        <stdbool.h>
 
 //procedure to receive email from outside
-extern void rec_handlesmtp(int argc,char *argv[]);
+extern void rec_handlesmtp();
 
 #endif
index 4077e57566726d83d0c7fee96303ce930de94b17..d50a8c99f3981f8bcc880b85a4680579944d823c 100644 (file)
@@ -37,6 +37,7 @@ static LISTYP *freelisten(LISTYP *listen)
 {
 if (listen!=(LISTYP *)0) {
   listen->ipnum=rou_freestr(listen->ipnum);
+  listen->port=rou_freestr(listen->port);
   (void) free(listen);
   listen=(LISTYP *)0;
   }
@@ -441,20 +442,21 @@ while (proceed==true) {
 
       seq=data;
       while (seq!=(char *)0) {
+        LISTYP *list;
         PROTYP proto;
         char *ipnum;
         char *port;
         int iter;
         char *ptr;
 
+        proto=pro_smtp;
         ipnum=DIP;
         port=DPORT;
-        iter=10;
+        iter=2;
         if ((ptr=strchr(seq,','))!=(char *)0) {
           *ptr='\000';
           ptr++;
           }
-        (void) rou_alert(0,"%s JMPDBG seq=<%s>",OPEP,seq);
         for (int j=0;j<3;j++) {
           char *sofar;
 
@@ -483,8 +485,12 @@ while (proceed==true) {
             }
           seq=sofar;
           }
-        (void) rou_alert(0,"%s JMP ipnum=<%s> port=<%s> iter='%d'",
-                            OPEP,ipnum,port,iter);
+        list=(LISTYP *)calloc(1,sizeof(LISTYP));
+        list->proto=proto;
+        list->ipnum=strdup(ipnum);;
+        list->port=strdup(port);;
+        list->iter=iter;
+        binds=(LISTYP **)rou_addlist((void **)binds,(void *)list);
         seq=ptr;
         }
       break;
@@ -1265,6 +1271,19 @@ return ssl;
 */
 /********************************************************/
 /*                                                      */
+/*     Procedure to return the list of binding data    */
+/*                                                      */
+/********************************************************/
+PUBLIC LISTYP **tls_get_bind_data()
+
+{
+return binds;
+}
+/*
+^L
+*/
+/********************************************************/
+/*                                                      */
 /*     Procedure to "open/close" module and do         */
 /*      homework purpose                                */
 /*      return zero if everything right                 */
index 48c57c725187261b49f394d838808bd6c98423a1..3a6f3e5d921f30a7956a9ead871f43444a9e0e3f 100644 (file)
@@ -22,6 +22,7 @@ typedef enum    {
 typedef struct  {       //structure about listening port
         PROTYP proto;   //Protocol to be used
         char *ipnum;    //binding IP number
+        char *port;     //binding port number
         int iter;       //Number of binding iteration
         }LISTYP;