From: Jean-Marc Pigeon (Delson) Date: Mon, 11 Aug 2025 09:48:45 +0000 (-0400) Subject: Detecting multiple connection from one remote X-Git-Tag: tag-0.15~20 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=3378de1081af44e0ecbc9b35c44a776b3dc5a107;p=jmp%2Fmailleur Detecting multiple connection from one remote --- diff --git a/lib/Makefile b/lib/Makefile index 7e79c7e..2dc97d8 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -45,7 +45,7 @@ modrec.o: \ lvleml.o: \ subcnv.h subrou.h \ - unidig.h unidns.h unieml.h \ + unidig.h unidns.h unieml.h uniprc.o \ gestcp.h gessql.h \ lvleml.h lvleml.c diff --git a/lib/gessql.c b/lib/gessql.c index a5aa5e9..abc9bf5 100644 --- a/lib/gessql.c +++ b/lib/gessql.c @@ -692,7 +692,7 @@ srv=(SRVTYP *)0; phase=0; proceed=true; while (proceed==true) { - (void) rou_alert(0,"%s JMPDBG phase='%d' connect=%d",OPEP,phase,connect); + //(void) rou_alert(0,"%s JMPDBG phase='%d' connect=%d",OPEP,phase,connect); switch (phase) { case 0 : //lets lock table access if (sql_lock(sqlptr,RMTTBL)==false) { diff --git a/lib/lvleml.c b/lib/lvleml.c index b16194e..234272d 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -23,6 +23,7 @@ #include "subcnv.h" #include "unidig.h" #include "unieml.h" +#include "uniprc.h" #include "devlog.h" #include "gestcp.h" #include "gessql.h" @@ -200,33 +201,6 @@ return done; */ /********************************************************/ /* */ -/* Procedure to transmit a string to the remot peer*/ -/* */ -/********************************************************/ -static void transmit(CONTYP *contact,_Bool flush,const char *fmt,...) - -{ -va_list args; -char *line; - -va_start(args,fmt); -line=(char *)0; -if (rou_vasprintf(&line,fmt,args)>0) { - (void) log_fprintlog(contact->logptr,true,"%s",line); - contact->transout=tcp_addline(contact->transout,line); - } -if (flush==true) { - (void) tcp_write(contact->socptr,contact->transout); - contact->transout=rou_freestr(contact->transout); - } -line=rou_freestr(line); -va_end(args); -} -/* -^L -*/ -/********************************************************/ -/* */ /* Procedure to send the signon once the contact */ /* with peer is detected. */ /* */ @@ -247,7 +221,7 @@ if (contact!=(CONTYP *)0) { APPNAME, rou_getversion(), rou_ascsysstamp(time((time_t *)0))); - (void) transmit(contact,true,"%s",signon); + (void) eml_transmit(contact,true,"%s",signon); } #undef FMT } @@ -274,9 +248,9 @@ if (suite==true) { sepa='-'; } mode=soc_getstrmode(contact->socptr); -(void) transmit(contact,flush,"%d%c%s, link (%s) ready, your IP/FQDN=[%s/%s]", - CMDOK,sepa,contact->locname,mode, - contact->peerip,contact->peername); +(void) eml_transmit(contact,flush,"%d%c%s, link (%s) ready, your IP/FQDN=[%s/%s]", + CMDOK,sepa,contact->locname,mode, + contact->peerip,contact->peername); } /* ^L @@ -376,7 +350,8 @@ while (proceed==true) { case 1 : //checking credential if (srv->links>1) { status=ALREADY; - (void) transmit(contact,true,"%d-4.5.6 Server already connected",status); + (void) eml_transmit(contact,true,"%d-4.5.6 Server already connected", + status); phase=999; //To many server connected } break; @@ -393,8 +368,9 @@ while (proceed==true) { srv->credit,"too low"); (void) setterminator(contact,"Remote server credit is too low"); status=BLCKLST; - (void) transmit(contact,true,"%d-4.5.7 Originator server IP [%s] black listed <%s>", - status,contact->peerip,cmt); + (void) eml_transmit(contact,true,"%d-4.5.7 Originator server IP " + "[%s] black listed <%s>", + status,contact->peerip,cmt); phase=999; //To many server connected } break; @@ -561,7 +537,7 @@ if ((received==(char *)0)||(strlen(received)==0)) { int got; line=(char *)0; - (void) transmit(contact,true,"%d 5.7.1 Please provide auth sequence",SENDB64); + (void) eml_transmit(contact,true,"%d 5.7.1 Please provide auth sequence",SENDB64); got=tcp_getline(contact->socptr,contact->delay,&line); if (got>0) { (void) log_fprintlog(contact->logptr,false,"%s",line); @@ -605,11 +581,11 @@ for (int i=0;i<2;i++) { int got; (void) strcat(local,IOBNULL); - (void) transmit(contact,true,"%d %s",SENDB64,logdat[i]); + (void) eml_transmit(contact,true,"%d %s",SENDB64,logdat[i]); got=tcp_getline(contact->socptr,contact->delay,&line); if (got<=0) { (void) strcpy(local,""); - (void) transmit(contact,true,"%d 5.7.2 auth sequence missing",UKNUSER); + (void) eml_transmit(contact,true,"%d 5.7.2 auth sequence missing",UKNUSER); break; //exiting from loop } (void) log_fprintlog(contact->logptr,false,"%s",line); @@ -673,7 +649,7 @@ while (proceed==true) { char *b64; b64=cnv_setb64(challenge); - (void) transmit(contact,true,"%d %s",SENDB64,b64); + (void) eml_transmit(contact,true,"%d %s",SENDB64,b64); b64=rou_freestr(b64); } break; @@ -733,7 +709,7 @@ while (proceed==true) { } (void) rou_asprintf(&rspauth,"rspauth=%s",HAS); b64=cnv_setb64(rspauth); - (void) transmit(contact,true,"%d %s",SENDB64,b64); + (void) eml_transmit(contact,true,"%d %s",SENDB64,b64); b64=rou_freestr(b64); rspauth=rou_freestr(rspauth); HAS=rou_freestr(HAS); @@ -811,14 +787,14 @@ while (proceed==true) { switch (phase) { case 0 : //are we encrypted and on the right port if (soc_iscrypted(contact->socptr)==false) { - (void) transmit(contact,true,"%d 5.7.0 no authentication on clear chanel", - FAILED); + (void) eml_transmit(contact,true,"%d 5.7.0 no authentication on " + "clear chanel",FAILED); phase=999; //No need to go further } break; case 1 : //check buffer if ((buffer==(char *)0)||(strlen(buffer)==0)) { - (void) transmit(contact,true,"%d 5.7.1 Missing auth type",FAILED); + (void) eml_transmit(contact,true,"%d 5.7.1 Missing auth type",FAILED); phase=999; //No need to go further } break; @@ -837,7 +813,7 @@ while (proceed==true) { } if (vocloc[code]==(char *)0) { (void) rou_alert(0,"%s auth type <%s> unknown (Bug?)",OPEP,local); - (void) transmit(contact,true,"%d 5.7.2 bad authentication type",BADPAR); + (void) eml_transmit(contact,true,"%d 5.7.2 bad authentication type",BADPAR); phase=999; //Trouble Trouble } break; @@ -847,19 +823,21 @@ while (proceed==true) { if (soc_iscrypted(contact->socptr)==true) (void) get_auth_plain(contact,local,&rmtpass); else - (void) transmit(contact,true,"%d 5.7.3 Unsafe PLAIN auth mode",FAILED); + (void) eml_transmit(contact,true,"%d 5.7.3 Unsafe PLAIN auth mode", + FAILED); break; case 1 : //AUTH LOGIN if (soc_iscrypted(contact->socptr)==true) (void) get_auth_login(contact,&rmtpass); else - (void) transmit(contact,true,"%d 5.7.4 Unsafe LOGIN auth mode",FAILED); + (void) eml_transmit(contact,true,"%d 5.7.4 Unsafe LOGIN auth mode", + FAILED); break; case 2 : //AUTH DIGEST-MD5 (void) get_auth_digest_md5(contact,&rmtpass); break; default : //not yet implemented - (void) transmit(contact,true,"%d 5.7.5 Unknown auth mode",FAILED); + (void) eml_transmit(contact,true,"%d 5.7.5 Unknown auth mode",FAILED); (void) rou_alert(0,"%s auth type <%d> not yet implemented",OPEP); phase=999; break; @@ -875,11 +853,11 @@ while (proceed==true) { fmt=DISP"Auth Rejected status='%d' for user=<%s> pass=<%s>"; (void) log_fprintlog(contact->logptr,true,fmt,BADAUTH,auth,rmtpass); (void) sleep(2); - (void) transmit(contact,true,"%d 5.7.4 authentication failed",BADAUTH); + (void) eml_transmit(contact,true,"%d 5.7.4 authentication failed",BADAUTH); } else { (void) log_fprintlog(contact->logptr,true,fmt,auth); - (void) transmit(contact,true,"%d 5.7.5 Authentication successful",IDOK); + (void) eml_transmit(contact,true,"%d 5.7.5 Authentication successful",IDOK); } } break; @@ -919,13 +897,15 @@ while (proceed==true) { switch (phase) { case 0 : //is user a local user if ((sql_mngusr(contact->sqlptr,sql_select,rcptto,&usr))==false) { - (void) transmit(contact,true,"%d 5.6.5 <%s> unknown user",UKNUSER,rcptto); + (void) eml_transmit(contact,true,"%d 5.6.5 <%s> unknown user", + UKNUSER,rcptto); phase=999; //No user found in database } break; case 1 : //is user lock? if (usr->lock==1) { - (void) transmit(contact,true,"%d 5.6.6 <%s> account lock",EXPIRED,rcptto); + (void) eml_transmit(contact,true,"%d 5.6.6 <%s> account lock", + EXPIRED,rcptto); phase=999; //No user found in database } break; @@ -1011,8 +991,8 @@ while (proceed==true) { default : //SAFE Guard if (remotegood==false) { - (void) transmit(contact,true,"%d 2.7.0 %s for domain <%s>", - NORELAY,cmt,rmtusr->domain); + (void) eml_transmit(contact,true,"%d 2.7.0 %s for domain <%s>", + NORELAY,cmt,rmtusr->domain); } proceed=false; break; @@ -1257,7 +1237,7 @@ while (proceed==true) { char *cmt; cmt="RCPT first. transaction protocol command out of sequence"; - (void) transmit(contact,true,"%d 5.5.0 %s",BADSEQ,cmt); + (void) eml_transmit(contact,true,"%d 5.5.0 %s",BADSEQ,cmt); done=true; //lets say DATA will be issued proceed=false; //No recipients } @@ -1272,8 +1252,8 @@ while (proceed==true) { break; case 3 : //sending 'go ahead' to remote (void) clock_gettime(CLOCK_REALTIME,&start); - (void) transmit(contact,true,"%d 3.5.0 %s", - DATAOK,"End data with ."); + (void) eml_transmit(contact,true,"%d 3.5.0 %s", + DATAOK,"End data with ."); break; case 4 : //get incoming line, detect 'single dot' as end while (completed==false) { @@ -1327,17 +1307,17 @@ while (proceed==true) { (void) snprintf(duration,sizeof(duration),"%d.%03d",delta/1000,delta%1000); contact->session->duration=strdup(duration);; fmt="%d-3.5.3 Session ID=<%s>"; - (void) transmit(contact,false,fmt,CMDOK,contact->session->sessid); + (void) eml_transmit(contact,false,fmt,CMDOK,contact->session->sessid); fmt="%d-3.5.3 data stream received: %d Kbytes within %s seconds)"; - (void) transmit(contact,false,fmt,CMDOK,total,duration); + (void) eml_transmit(contact,false,fmt,CMDOK,total,duration); fmt="%d 3.5.3 Message accepted for delivery"; - (void) transmit(contact,true,fmt,CMDOK,contact->session->sessid); + (void) eml_transmit(contact,true,fmt,CMDOK,contact->session->sessid); done=true; proceed=false; //task done break; default : //SAFE guard - (void) transmit(contact,true,"%d 5.5.4 %s", - DATRJC,"Server does not accept mail"); + (void) eml_transmit(contact,true,"%d 5.5.4 Server does not accept mail", + DATRJC); proceed=false; break; } @@ -1366,7 +1346,7 @@ static _Bool dohelo(CONTYP *contact,char *parameter) _Bool done; if ((done=isgoodfqdn(contact,parameter))==false) - (void) transmit(contact,true,"%d 5.5.4 %s.",BADPAR,DETAIL); + (void) eml_transmit(contact,true,"%d 5.5.4 %s.",BADPAR,DETAIL); else (void) linkready(contact,false); return done; @@ -1415,7 +1395,7 @@ while (proceed==true) { switch (phase) { case 0 : //Do we have a parameter if ((done=isgoodfqdn(contact,parameter))==false) { - (void) transmit(contact,true,"%d 5.5.4 %s.",BADPAR,DETAIL); + (void) eml_transmit(contact,true,"%d 5.5.4 %s.",BADPAR,DETAIL); phase=999; //Trouble trouble } break; @@ -1441,9 +1421,9 @@ while (proceed==true) { continue; break; } - (void) transmit(contact,false,"%d%c%s",CMDOK,space,ehlo[i].str); + (void) eml_transmit(contact,false,"%d%c%s",CMDOK,space,ehlo[i].str); } - (void) transmit(contact,true,""); + (void) eml_transmit(contact,true,""); done=true; break; default : //SAFE guard @@ -1581,16 +1561,16 @@ while (proceed==true) { switch (phase) { case 0 : //do we have an originator if ((mailfrom==(char *)0)||(strlen(mailfrom)<3)) { - (void) transmit(contact,true,"%d 5.5.0 <%s> originator not specified", - BADPAR,mailfrom); + (void) eml_transmit(contact,true,"%d 5.5.0 <%s> originator not specified", + BADPAR,mailfrom); phase=999; //no need to go further } break; case 1 : //do we have already a from if (contact->mailfrom!=(char *)0) { - (void) transmit(contact,true,"%d 5.5.1 '%s' %s", - BADPAR,contact->mailfrom, - "was previously defined as originator"); + (void) eml_transmit(contact,true,"%d 5.5.1 '%s' %s", + BADPAR,contact->mailfrom, + "was previously defined as originator"); phase=999; //no need to go further } break; @@ -1605,8 +1585,8 @@ while (proceed==true) { break; case 3 : //check from format if ((mailfrom[0]!='<')||(mailfrom[strlen(mailfrom)-1]!='>')) { - (void) transmit(contact,true,"%d 5.5.3 '%s' bad Format error", - BADPAR,mailfrom); + (void) eml_transmit(contact,true,"%d 5.5.3 '%s' bad Format error", + BADPAR,mailfrom); phase=999; //no need to go further } mailfrom[strlen(mailfrom)-1]='\000'; @@ -1621,22 +1601,22 @@ while (proceed==true) { 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); + (void) eml_transmit(contact,true,"%d 5.5.4 Closing connection",status); phase=999; //bad credit not need to go further } break; default : (void) rou_alert(0,"%s unexpected priviliged='%d' (Bug?)", OPEP,contact->privilege); - (void) transmit(contact,true,"%d 5.5.5 Closing connection",FAILED); - phase=999; //bad credit not need to go further + (void) eml_transmit(contact,true,"%d 5.5.5 Closing connection",FAILED); + phase=999; //bad credit not need to go further break; } break; case 5 : //everything ok contact->mailfrom=strdup(mailfrom); - (void) transmit(contact,true,"%d 2.1.3 %s sender ok", - CMDOK,contact->mailfrom); + (void) eml_transmit(contact,true,"%d 2.1.3 %s sender ok", + CMDOK,contact->mailfrom); success=true; break; default : //SAFE guard @@ -1680,20 +1660,22 @@ while (proceed==true) { switch (phase) { case 0 : //do we have a mailfrom if ((contact->mailfrom==(char *)0)||(strlen(contact->mailfrom)==0)) { - (void) transmit(contact,true,"%d 5.6.0 Bad sequence of commands.",BADSEQ); + (void) eml_transmit(contact,true,"%d 5.6.0 Bad sequence of commands.", + BADSEQ); phase=999; //no need to go further } break; case 1 : //do we have an originator if ((rcptto==(char *)0)||(strlen(rcptto)==0)) { - (void) transmit(contact,true,"%d 5.6.1 recipient not specified",BADPAR); + (void) eml_transmit(contact,true,"%d 5.6.1 recipient not specified", + BADPAR); phase=999; //no need to go further } break; case 2 : //check rcpt format if ((rcptto[0]!='<')||(rcptto[strlen(rcptto)-1]!='>')) { - (void) transmit(contact,true,"%d 5.6.2 '%s' bad Format error", - BADPAR,rcptto); + (void) eml_transmit(contact,true,"%d 5.6.2 '%s' bad Format error", + BADPAR,rcptto); phase=999; //no need to go further } rcptto[strlen(rcptto)-1]='\000'; @@ -1702,17 +1684,17 @@ while (proceed==true) { case 3 : //checking rcptto format neu=eml_isemailok(rcptto,&report); if (neu==(RCPTYP *)0) { - (void) transmit(contact,true,"%d 5.6.3 %s",NOTEML,report); + (void) eml_transmit(contact,true,"%d 5.6.3 %s",NOTEML,report); report=rou_freestr(report); phase=999; //no need to go further } break; case 4 : //Do we have a domain MX if (setlocdom(contact,neu)==false) { - (void) transmit(contact,true,"%d 5.6.4 %s (domain=%s)", - MISSMX, - "No valid MX found for recipient domain name", - neu->domain); + (void) eml_transmit(contact,true,"%d 5.6.4 %s (domain=%s)", + MISSMX, + "No valid MX found for recipient " + "domain name",neu->domain); phase=999; //no need to go further } break; @@ -1727,10 +1709,10 @@ while (proceed==true) { phase=999; break; default : - (void) transmit(contact,true,"%d 5.6.5 %s (domain=%s,code='%c')", - FAILED, - "system error with domain status", - neu->domain,neu->code); + (void) eml_transmit(contact,true,"%d 5.6.5 %s (domain=%s,code='%c')", + FAILED, + "system error with domain status", + neu->domain,neu->code); phase=999; //no need to go further break; } @@ -1742,7 +1724,7 @@ while (proceed==true) { } break; case 7 : //everything ok - (void) transmit(contact,true,"%d 2.6.4 %s <%s>",CMDOK,detail,rcptto); + (void) eml_transmit(contact,true,"%d 2.6.4 %s <%s>",CMDOK,detail,rcptto); success=true; break; default : //SAFE guard @@ -1769,16 +1751,16 @@ static _Bool doreset(CONTYP *contact,char *parameter) { #define LOCSEQ "2.1.0" -(void) transmit(contact,true,"%d-%s flushed session %s", - CMDOK,LOCSEQ,contact->session->sessid); +(void) eml_transmit(contact,true,"%d-%s flushed session %s", + CMDOK,LOCSEQ,contact->session->sessid); (void) freesessid(contact); contact->numreset++; (void) getsessid(contact); contact->recipients=(RCPTYP **)rou_freelist((void **)(contact->recipients), (genfree_t)eml_freerecipient); contact->mailfrom=rou_freestr(contact->mailfrom); -(void) transmit(contact,true,"%d %s opening new session %s", - CMDOK,LOCSEQ,contact->session->sessid); +(void) eml_transmit(contact,true,"%d %s opening new session %s", + CMDOK,LOCSEQ,contact->session->sessid); return true; #undef LOCSEQ @@ -2379,6 +2361,33 @@ while (proceed==true) { */ /********************************************************/ /* */ +/* Procedure to transmit a string to the remot peer*/ +/* */ +/********************************************************/ +PUBLIC void eml_transmit(CONTYP *contact,_Bool flush,const char *fmt,...) + +{ +va_list args; +char *line; + +va_start(args,fmt); +line=(char *)0; +if (rou_vasprintf(&line,fmt,args)>0) { + (void) log_fprintlog(contact->logptr,true,"%s",line); + contact->transout=tcp_addline(contact->transout,line); + } +if (flush==true) { + (void) tcp_write(contact->socptr,contact->transout); + contact->transout=rou_freestr(contact->transout); + } +line=rou_freestr(line); +va_end(args); +} +/* +^L +*/ +/********************************************************/ +/* */ /* Procedure to proceed with peer exchange */ /* 5 return values: */ /* 1 exiting via "quit" */ @@ -2447,14 +2456,14 @@ while (proceed==true) { proceed=doehlo(contact,line); break; case c_noop : //No Operation - (void) transmit(contact,true,"%d 2.0.0 OK, %s", - CMDOK,contact->mainsesid); + (void) eml_transmit(contact,true,"%d 2.0.0 OK, %s", + CMDOK,contact->mainsesid); break; case c_quit : //QUIT SMTP protocol contact->credit++; //clean disconnect (void) setterminator(contact,"QUIT received"); - (void) transmit(contact,true,"%d 2.0.0 Bye, closing connection CNT=%s", - QUITOK,contact->mainsesid); + (void) eml_transmit(contact,true,"%d 2.0.0 Bye, closing connection CNT=%s", + QUITOK,contact->mainsesid); status=1; //every thing fine proceed=false; break; @@ -2482,7 +2491,7 @@ while (proceed==true) { case c_starttls : //EHLO start encrypted link in server mode (void) usleep(100000); (void) soc_purge(contact->socptr,contact->peerip); - (void) transmit(contact,true,"%d 2.0.0 Ready to start TLS",SIGNON); + (void) eml_transmit(contact,true,"%d 2.0.0 Ready to start TLS",SIGNON); switch (soc_starttls(contact->socptr,true)) { case true : { //link now in TLS crypted mode (server mode) int level; @@ -2493,8 +2502,8 @@ while (proceed==true) { break; case false : //unable to establish link (void) setterminator(contact,"starttls not successful"); - (void) transmit(contact,true,"%d 5.3.3 command starttls not successful", - CMDBAD); + (void) eml_transmit(contact,true,"%d 5.3.3 command starttls not " + "successful",CMDBAD); status=-1; proceed=false; break; @@ -2504,20 +2513,21 @@ while (proceed==true) { contact->credit-=2; //Trying to confuse server? (void) rou_alert(0,"SMTP Command <%s> from [%s] is unknown (config?)", line,contact->peerip); - (void) transmit(contact,true,"%d-5.5.1 Unrecognized command, see RFC 5321", - CMDBAD); - (void) transmit(contact,true,"%d-5.5.1 https://www.rfc-editor.org",CMDBAD); - (void) transmit(contact,true,"%d 5.5.1 session %s is still running", - CMDBAD,contact->mainsesid); + (void) eml_transmit(contact,true,"%d-5.5.1 Unrecognized command, " + "see RFC 5321",CMDBAD); + (void) eml_transmit(contact,true,"%d-5.5.1 https://www.rfc-editor.org", + CMDBAD); + (void) eml_transmit(contact,true,"%d 5.5.1 session %s is still running", + CMDBAD,contact->mainsesid); break; default : contact->credit-=10; //Trying to bug server (void) rou_alert(0,"%s Unable to find entry for code='%d' (Bug?)",OPEP,code); - (void) transmit(contact,true,"%d-5.5.1 Unrecognized command, see RFC 5321", - CMDBAD); - (void) transmit(contact,true,"%d 2.0.0 Bug!, closing connection " - "Immediatly (%s)", - QUITOK,contact->mainsesid); + (void) eml_transmit(contact,true,"%d-5.5.1 Unrecognized command, " + "see RFC 5321",CMDBAD); + (void) eml_transmit(contact,true,"%d 2.0.0 Bug!, closing connection " + "Immediatly (%s)", + QUITOK,contact->mainsesid); status=-1; //remote is a trouble maker status=-3; proceed=false; @@ -2622,6 +2632,9 @@ while (proceed==true) { } break; case 7 : //contact is good, then sending a signon + (void) prc_settitle("%s, incoming contact from [%s] on [%s:%s]", + appname,contact->peerip, + contact->locname,contact->locserv); (void) log_fprintlog(contact->logptr,true,"Start CNT=%s",contact->mainsesid); (void) log_fprintlog(contact->logptr,false,"(Contact open from [%s] to " "[%s:%s])", diff --git a/lib/lvleml.h b/lib/lvleml.h index 3a69147..289e3f5 100644 --- a/lib/lvleml.h +++ b/lib/lvleml.h @@ -41,6 +41,9 @@ typedef struct { }CONTYP; +//Procedure to transmit data on the contact channel +extern void eml_transmit(CONTYP *contact,_Bool flush,const char *fmt,...); + //procedure to extract line and proceed with peer contact extern int eml_docontact(CONTYP *contact); diff --git a/lib/modrec.c b/lib/modrec.c index 8796760..d104233 100644 --- a/lib/modrec.c +++ b/lib/modrec.c @@ -179,17 +179,19 @@ while (proceed==true) { phase=999; //No contact! break; case 1 : //check if remote link is acceptable - (void) rou_alert(0,"%s JMPDBG Checking if double connection",OPEP); if (sql_newconnect(contact->sqlptr,contact->peerip,1)!=1) { - (void) rou_alert(0,"%s JMPDBG found double connection",OPEP); - contact->credit-=1; + char *end; + + end="Found ip=[%s] already connected"; + (void) rou_asprintf(&(contact->termend),end,contact->peerip); + end="You have another connection still in progress"; + (void) eml_transmit(contact,true,"%d contact denied <%s>",NOTNOW,end); + contact->credit=-1; //small penalty + (void) sleep(1); //To avoid avalanche phase++; //connection rejected } break; 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 diff --git a/lib/unieml.h b/lib/unieml.h index db20675..90604d2 100644 --- a/lib/unieml.h +++ b/lib/unieml.h @@ -26,6 +26,7 @@ #define ERRPROC 451 //local processing error #define ALREADY 456 //remote server already connected #define BADSITE 457 //Site credential is too low +#define NOTNOW 459 //Site already connected #define NOANSWR 460 //no answer from remote #define BADPAR 501 //error in parameters #define CMDBAD 502 //command not implemented