{
#define OPEP "gessql.c:update_remote,"
-static const char *upd= "UPDATE "RMTTBL
- " SET lastscan='%s',credit=%d,listing=%s,reverse=%s"
- " WHERE remoteip='%s'";
+static const char *upd= "UPDATE "RMTTBL"SET "
+ "lastscan='%s',lastupdate='%s',"
+ "credit=%d,listing=%s,reverse=%s "
+ "WHERE remoteip='%s'";
_Bool isok;
-const char *lastscan;
+char *lastscan;
+char *update;
char *listing;
char *reverse;
isok=true;
lastscan=sql_fromunixtime(sqlptr,srv->lastscan);
+update=sql_fromunixtime(sqlptr,srv->update);
listing=sql_gooddata(sqlptr,srv->listing);
reverse=sql_gooddata(sqlptr,srv->reverse);
if (sql_request(sqlptr,upd,lastscan,srv->credit,listing,reverse,srv->rmtip)!=1) {
}
reverse=rou_freestr(reverse);
listing=rou_freestr(listing);
+update=rou_freestr(update);
+lastscan=rou_freestr(lastscan);
return isok;
#undef OPEP
decoded=cnv_getb64(received);
if (decoded!=(char *)0) {
if (checklogin(contact,rmtpass,decoded)==true) {
- contact->credits+=2;
+ contact->credit+=2;
contact->privilege=rel_authentic;
}
decoded=rou_freestr(decoded);
}
if (strlen(local)>0) {
if (checklogin(contact,rmtpass,local)==true) {
- contact->credits+=2;
+ contact->credit+=2;
contact->privilege=rel_authentic;
}
}
break;
}
if (strcmp(HA0,resp->response)==0) {
- contact->credits+=3; //very good authentication
+ contact->credit+=3; //very good authentication
contact->privilege=rel_authentic;
}
HA0=rou_freestr(HA0);
break;
case rel_plain :
cmt="No relay accepted";
- contact->credits-=2; //Trying to abuse server
+ contact->credit-=2; //Trying to abuse server
phase=999; //not relayable
break;
default :
}
(void) log_fprintlog(contact->logptr,true,"Contact terminated (credit='%d'); "
"condition=<%s>",
- contact->credits,str);
+ contact->credit,str);
//(void) rou_alert(0,"%s exit status='%d'",OPEP,status);
break; //no need to go further
CMDOK,contact->mainsesid);
break;
case c_quit : //QUIT SMTP protocol
- contact->credits++; //clean disconnect
+ contact->credit++; //clean disconnect
(void) transmit(contact,true,"%d 2.0.0 Bye, closing connection CNT=%s",
QUITOK,contact->mainsesid);
status=1; //every thing fine
}
break;
case c_unknown : //unknown keyword
- contact->credits-=2; //Trying to confuse server?
+ 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,contact->mainsesid);
break;
default :
- contact->credits-=10; //Trying to bug server
+ 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);
case 1 : //connecting to database
contact=(CONTYP *)calloc(1,sizeof(CONTYP));
contact->sqlptr=sql_opensql();
- contact->credits=0;
+ contact->credit=0;
if (contact->sqlptr==(SQLPTR *)0) {
(void) rou_alert(0,"%s Unable to contact database",OPEP);
(void) sleep(2);//delay to avoid avalanche
case 6 : //checking if remote IP is relayable
if (afn_is_ip_relayable(contact->peerip,contact->relayok)==true) {
contact->privilege=rel_isrelay; //IP is relayable
- contact->credits++;
+ contact->credit++;
}
break;
case 7 : //contact is good, then sending a signon
{
#define OPEP "lvleml.c:eml_dropcontact"
+SRVTYP *srv;
int phase;
_Bool proceed;
+srv=(SRVTYP *)0;
phase=0;
proceed=true;
while (proceed==true) {
phase=999; //not going further
}
break;
- case 1 : //properly closing remote contact
+ case 1 : //getting the remote server information
+ if (sql_mngremote(contact->sqlptr,sql_select,contact->peerip,&srv)==false) {
+ (void) rou_alert(0,"%s Unable to get remote [%s] data (Bug!?)",
+ OPEP,contact->peerip);
+ phase++; //No need to do update
+ }
+ break;
+ case 2 : //Updating remote server data
+ srv->credit+=contact->credit;
+ srv->update=time((time_t *)0);
+ if (sql_mngremote(contact->sqlptr,sql_update,contact->peerip,&srv)==false) {
+ (void) rou_alert(0,"%s Unable to UPDATE remote [%s] data (Bug!?)",
+ OPEP,contact->peerip);
+ }
+ srv=sql_freesrv(srv);
+ break;
+ case 3 : //properly closing remote contact
(void) rou_alert(0,"Contact from peer <%s> to port <%s> terminated",
contact->peerip,contact->locserv);
contact->socptr=soc_release(contact->socptr);
break;
- case 2 : //freeing contact memory
+ case 4 : //freeing contact memory
contact=freecontact(contact);
break;
default : //SAFE guard