phase=999; //Trouble trouble
}
break;
- case 2 : //updating record according blacklisting
+ case 2 : //getting the reverss-address
reversip=afn_reversipnum(*afns);
+ srv->reverse=rou_freestr(srv->reverse);
+ srv->reverse=dns_get_reverse_addr(reversip);
+ break;
+ case 3 : //updating record according blacklisting
srv->credit=0;
srv->lastscan=time((time_t *)0);
if (dnsbls!=(char **)0) {
listed=rou_freestr(listed);
dnsbls++;
}
- (void) log_fprintlog(scanref->logptr,true,"IP[%02d]: %s\tCurrent "
+ (void) log_fprintlog(scanref->logptr,true,"IP[%02d]: %s\tRVS='%s'\tCurrent "
"credit='%3d'",
- num,rmtip,srv->credit);
+ num,rmtip,
+ srv->reverse,srv->credit);
(void) log_fprintlog(scanref->logptr,false,"");
}
break;
- case 3 : //updating record
+ case 4 : //updating record
if (sql_mngremote(scanref->sqlptr,sql_update,rmtip,&srv)==false) {
(void) rou_alert(0,"%s Unable to update remote <%s> data (database?)",
OPEP,rmtip);
{4,"links"},
{5,"credit"},
{6,"listing"},
+ {7,"reverse"},
{0,(char *)0}
};
case 6 : //scanning status
locsrv->listing=strdup(locval);
break;
+ case 7 : //scanning status
+ locsrv->reverse=strdup(locval);
+ break;
default :
(void) rou_alert(0,"%s field <%d:%s> not implemented (Bug?)",
OPEP,usrfield[i].num,usrfield[i].name);
{
#define OPEP "gessql.c:update_remote,"
-static const char *upd="UPDATE "RMTTBL" SET lastscan='%s',credit=%d,listing=%s WHERE remoteip='%s'";
+static const char *upd= "UPDATE "RMTTBL
+ " SET lastscan='%s',credit=%d,listing=%s,reverse=%s"
+ " WHERE remoteip='%s'";
_Bool isok;
const char *lastscan;
char *listing;
+char *reverse;
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) {
+reverse=sql_gooddata(sqlptr,srv->reverse);
+if (sql_request(sqlptr,upd,lastscan,srv->credit,listing,reverse,srv->rmtip)!=1) {
(void) rou_alert(0,"%s Unable to update remote_ip <%s> (Database?)",
OPEP,srv->rmtip);
isok=false;
}
+reverse=rou_freestr(reverse);
listing=rou_freestr(listing);
return isok;
listed=(char *)0;
(void) snprintf(dnsquest,sizeof(dnsquest),"%s.%s",reversip,blssite);
-(void) rou_alert(12,"%s, checking <%s>",OPEP,dnsquest);
+//(void) rou_alert(0,"%s, JMPDBG checking <%s>",OPEP,dnsquest);
if ((txt=gettxt(dnsquest,T_TXT,"TXT"))!=(char **)0) {
(void) rou_asprintf(&listed,"%s -> %s",blssite,txt[0]);
txt=(char **)rou_freelist((void **)txt,(genfree_t)rou_freestr);
#undef OPEP
}
+/*
+\f
+*/
+/********************************************************/
+/* */
+/* Procedure to extract the IP reverse address */
+/* Return "No-reverse" if unknown. */
+/* */
+/********************************************************/
+PUBLIC char *dns_get_reverse_addr(char *reversip)
+
+{
+#define OPEP "unidns.c:dns_get_reverse_addr,"
+
+char *reverse;
+char **txt;
+char dnsquest[300];
+
+reverse=(char *)0;
+(void) snprintf(dnsquest,sizeof(dnsquest),"%s.%s",reversip,"in-addr.arpa");
+//(void) rou_alert(0,"%s JMPDBG checking <%s>",OPEP,dnsquest);
+if ((txt=gettxt(dnsquest,T_PTR,"PTR"))!=(char **)0) {
+ (void) rou_asprintf(&reverse,"%s",txt[0]);
+ txt=(char **)rou_freelist((void **)txt,(genfree_t)rou_freestr);
+ }
+if (reverse==(char *)0)
+ reverse=strdup(NORVERS);
+return reverse;
+
+#undef OPEP
+}
#include "subafn.h"
+#define NORVERS "No.Reverse"
+
//defining an MX structure
typedef struct {
int preference; //MX preference
//procedure returning a string if remote IP si blacklisted
extern char *dns_is_blacklisted(char *blssite,char *reversip);
+//procedure returning the IP reverss address as a string
+extern char *dns_get_reverse_addr(char *reversip);
+
#endif
time_t update; //last update time
int links; //Number of connection from this remote
int credit; //Remote credit number
+ char *reverse; //Remote serveur reverss-address
char *listing; //Remote listing explaination
}SRVTYP;
DFLT NOW(),
credit INTEGER //Remote IP current credit (-100..+100)
DFLT -1,
- listing TEXT //explaination obout black listing
+ reverse TEXT //Remote official revers address
+ DFLT NULL,
+ listing TEXT //explaination about black listing
DFLT NULL,
links INTEGER
DFLT 1 //how many time the remote connected