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
}
/* 0 contact timeout */
/* -1 signal received */
/* -2 remote disconnected */
-/* -3 BUG! */
+/* -3 Multiple remote connection */
+/* -4 BUG! */
/* */
/********************************************************/
PUBLIC int eml_docontact(CONTYP *contact)
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
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;
}