From 336c78dc0eb3883dfa06b9a9ba8a6cee4aa74013 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Wed, 6 Aug 2025 14:15:21 -0400 Subject: [PATCH] TRying to improve contact credit management --- app/feeder.c | 2 +- lib/lvleml.c | 4 +++- lib/modrec.c | 41 ++++++++++++++++++++++------------------- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/app/feeder.c b/app/feeder.c index 2aaf7fc..48f60db 100644 --- a/app/feeder.c +++ b/app/feeder.c @@ -24,7 +24,7 @@ #define FNAME "feeder" -#define WRESP 5 //wait 5 sec for SMTP server +#define WRESP 30 //wait 30 sec for SMTP server //to answer static char titre[100]; //test title diff --git a/lib/lvleml.c b/lib/lvleml.c index 5142314..4d5963d 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -1619,6 +1619,7 @@ while (proceed==true) { break; case rel_plain : //remote IP is plain if ((status=checkcredit(contact))!=CMDOK) { + contact->credit=-1; //found bad guy. (void) transmit(contact,true,"%d 5.5.4 Closing connection",status); phase=999; //bad credit not need to go further } @@ -2383,7 +2384,8 @@ while (proceed==true) { /* 0 contact timeout */ /* -1 signal received */ /* -2 remote disconnected */ -/* -3 BUG! */ +/* -3 Multiple remote connection */ +/* -4 BUG! */ /* */ /********************************************************/ PUBLIC int eml_docontact(CONTYP *contact) diff --git a/lib/modrec.c b/lib/modrec.c index a99dbcf..fcb045a 100644 --- a/lib/modrec.c +++ b/lib/modrec.c @@ -178,18 +178,16 @@ while (proceed==true) { if ((contact=eml_getcontact(socptr,pos))==(CONTYP *)0) phase=999; //No contact! break; - case 1 : //within forked process - (void) prc_settitle("%s, incoming contact from [%s] on [%s:%s]", - appname,contact->peerip, - contact->locname,contact->locserv); - break; - case 2 : //check if remote link is acceptable + case 1 : //check if remote link is acceptable if (sql_newconnect(contact->sqlptr,contact->peerip,1)==false) { contact->credit-=1; - phase=999; //connection rejected + phase++; //connection rejected } break; - case 3 : //do contact + case 2 : //do contact + (void) prc_settitle("%s, incoming contact from [%s] on [%s:%s]", + appname,contact->peerip, + contact->locname,contact->locserv); intstat=eml_docontact(contact); switch (intstat) { case 1 : //command 'quit' recieved @@ -208,19 +206,24 @@ while (proceed==true) { break; } break; - case 4 : //connection terminated + case 3 : { //connection terminated + static const char *cmt; + SRVTYP *srv; + int total; + + cmt="(Contact terminated, credit='%3d/%3d' condition=<%s>)"; + total=0; + if (sql_mngremote(contact->sqlptr,sql_select,contact->peerip,&srv)==true) { + total=srv->credit; + srv=sql_freesrv(srv); + } + (void) log_fprintlog(contact->logptr,true,cmt,contact->credit,total, + contact->termend); + (void) sql_newconnect(contact->sqlptr,contact->peerip,-1); + contact=eml_dropcontact(contact); + } break; default : //SAFE guard - if (contact!=(CONTYP *)0) { - static const char *cmt; - - cmt="(Contact terminated, credit='%d' condition=<%s>)"; - (void) log_fprintlog(contact->logptr,true,cmt, - contact->credit, - contact->termend); - (void) sql_newconnect(contact->sqlptr,contact->peerip,-1); - contact=eml_dropcontact(contact); - } proceed=false; break; } -- 2.47.3