#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"
/* -> 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
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
/* Waiting and handling smtp request */
/* */
/********************************************************/
-PUBLIC void rec_handlesmtp(int argc,char *argv[])
+PUBLIC void rec_handlesmtp()
{
#define OPEP "modrec.c:rec_handlesmtp"
//(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;
}
{
if (listen!=(LISTYP *)0) {
listen->ipnum=rou_freestr(listen->ipnum);
+ listen->port=rou_freestr(listen->port);
(void) free(listen);
listen=(LISTYP *)0;
}
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;
}
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;
*/
/********************************************************/
/* */
+/* 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 */