From: Jean-Marc Pigeon (Delson) Date: Wed, 11 Jun 2025 11:58:33 +0000 (-0400) Subject: config with SMTP is woring fine X-Git-Tag: tag-0.8~29 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=2bed8d70853794a0833e5f241a84bd6fd33875a7;p=jmp%2Fmailleur config with SMTP is woring fine --- diff --git a/conf/mailleur.conf.dvl b/conf/mailleur.conf.dvl index 8b6ab88..3e65d8e 100644 --- a/conf/mailleur.conf.dvl +++ b/conf/mailleur.conf.dvl @@ -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" diff --git a/lib/modrec.c b/lib/modrec.c index 7c9d6ee..889b7f9 100644 --- a/lib/modrec.c +++ b/lib/modrec.c @@ -41,58 +41,21 @@ /* -> 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", - 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; } diff --git a/lib/modrec.h b/lib/modrec.h index e13e747..01be0b7 100644 --- a/lib/modrec.h +++ b/lib/modrec.h @@ -10,6 +10,6 @@ #include //procedure to receive email from outside -extern void rec_handlesmtp(int argc,char *argv[]); +extern void rec_handlesmtp(); #endif diff --git a/lib/unitls.c b/lib/unitls.c index 4077e57..d50a8c9 100644 --- a/lib/unitls.c +++ b/lib/unitls.c @@ -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 */ diff --git a/lib/unitls.h b/lib/unitls.h index 48c57c7..3a6f3e5 100644 --- a/lib/unitls.h +++ b/lib/unitls.h @@ -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;