{
#define OPEP "scarmt.c:check_credibilty,"
-if (dnsbls!=(char **)0) {
- while (*dnsbls!=(char *)0) {
- (void) rou_alert(0,"%s JMPDBG scan <%s> against <%s>",OPEP,rmtip,*dnsbls);
- dnsbls++;
+SRVTYP *srv;
+int phase;
+_Bool proceed;
+
+srv=(SRVTYP *)0;
+phase=0;
+proceed=true;
+while (proceed==true) {
+ switch (phase) {
+ case 0 : //loading rmtip record
+ if (sql_mngremote(sqlptr,sql_select,rmtip,&srv)==false) {
+ (void) rou_alert(0,"%s Unable to get remote <%s> data (database?)",
+ OPEP,rmtip);
+ phase=999; //Trouble trouble
+ }
+ break;
+ case 1 : //updating record according blacklisting
+ srv->credit=0;
+ srv->lastscan=time((time_t *)0);
+ if (dnsbls!=(char **)0) {
+ while (*dnsbls!=(char *)0) {
+ (void) rou_alert(0,"%s JMPDBG scan <%s> against <%s>",OPEP,rmtip,*dnsbls);
+ dnsbls++;
+ }
+ }
+ break;
+ case 2 : //updating record
+ if (sql_mngremote(sqlptr,sql_update,rmtip,&srv)==false) {
+ (void) rou_alert(0,"%s Unable to update remote <%s> data (database?)",
+ OPEP,rmtip);
+ }
+ break;
+ default : //SAFE Guard
+ proceed=false;
+ break;
}
+ phase++;
}
-
+srv=sql_freesrv(srv);
#undef OPEP
}
/*
#define ACTTBL "actions" //action tables
#define SESTBL "sessions" //session tables
+//field available in table "remotes"
+static const FLDTYP usrfield[]={
+ {1,"remoteip"},
+ {2,"lastscan"},
+ {3,"lastupdate"},
+ {4,"links"},
+ {5,"credit"},
+ {6,"listing"},
+ {0,(char *)0}
+ };
+
+_Bool isok;
/*
\f
*/
*/
/********************************************************/
/* */
-/* Procedure to select a user from emails tables */
-/* and return contents; */
+/* Procedure to select a remote server from remotes*/
+/* table and return contents */
/* */
/********************************************************/
static _Bool select_remote(SQLPTR *sqlptr,char *rmtip,SRVTYP **srv)
static const char *sel="SELECT * FROM "RMTTBL" WHERE remoteip=%s";
-//field available in table "emails"
-static const FLDTYP usrfield[]={
- {1,"remoteip"},
- {2,"lastscan"},
- {3,"lastupdate"},
- {4,"links"},
- {5,"credit"},
- {6,"listing"},
- {0,(char *)0}
- };
-
-_Bool isok;
SRVTYP *locsrv;
SQLRES *rs;
register int phase;
*srv=locsrv;
return isok;
+#undef OPEP
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
+/* Procedure to select a remote server from remotes*/
+/* table and update contents */
+/* */
+/********************************************************/
+static _Bool update_remote(SQLPTR *sqlptr,char *rmtip,SRVTYP *srv)
+
+{
+#define OPEP "fgessql.c:update_remote,"
+
+static const char *upd="UPDATE "RMTTBL" SET lastscan='%s',credit=%d,listing=%s WHERE remoteip='%s'";
+
+_Bool isok;
+const char *lastscan;
+char *listing;
+
+isok=true;
+lastscan=sql_fromunixtime(sqlptr,srv->lastscan);
+listing=sql_gooddata(sqlptr,srv->listing);
+if (sql_request(sqlptr,upd,lastscan,srv->credit,listing,srv->rmtip)!=1) {
+ (void) rou_alert(0,"%s Unable to update remote_ip <%s> (Database?)",
+ OPEP,srv->rmtip);
+ isok=false;
+ }
+listing=rou_freestr(listing);
+return isok;
+
#undef OPEP
}
/*
case sql_select :
isok=select_remote(sqlptr,gooddata,srv);
break;
+ case sql_update :
+ isok=update_remote(sqlptr,gooddata,*srv);
+ break;
default :
(void) rou_alert(0,"%s action='%d' not yet implemented!",OPEP,action);
+ break;
}
gooddata=rou_freestr(gooddata);
break;