Commit 5d634f09 authored by rswindell's avatar rswindell
Browse files

Added hostname to filter_ip() prototype.

parent ca37cbfc
......@@ -1009,6 +1009,7 @@ js_filter_ip(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
char* p;
char* prot=NULL;
char* reason=NULL;
char* host=NULL;
char* ip_addr=NULL;
char* from=NULL;
scfg_t* cfg;
......@@ -1026,12 +1027,14 @@ js_filter_ip(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
prot=p;
else if(reason==NULL)
reason=p;
else if(host==NULL)
host=p;
else if(ip_addr==NULL)
ip_addr=p;
else if(from==NULL)
from=p;
}
*rval = BOOLEAN_TO_JSVAL(filter_ip(cfg,prot,reason,ip_addr,from));
*rval = BOOLEAN_TO_JSVAL(filter_ip(cfg,prot,reason,host,ip_addr,from));
return(JS_TRUE);
}
......@@ -1265,7 +1268,7 @@ static jsMethodSpec js_system_functions[] = {
{"hacklog", js_hacklog, 5, JSTYPE_BOOLEAN, JSDOCSTR("[protocol, user, text, host, ip, port]")
,JSDOCSTR("log a suspected hack attempt")
},
{"filter_ip", js_filter_ip, 4, JSTYPE_BOOLEAN, JSDOCSTR("[protocol, reason, ip, username]")
{"filter_ip", js_filter_ip, 4, JSTYPE_BOOLEAN, JSDOCSTR("[protocol, reason, host, ip, username]")
,JSDOCSTR("add an IP address (with comment) to the system's IP filter file")
},
{"get_node_message",js_get_node_message,0, JSTYPE_STRING, JSDOCSTR("number node")
......
......@@ -2467,7 +2467,7 @@ static void smtp_thread(void* arg)
strcpy(tmp,"REFUSED");
if(dnsbl_result.s_addr==0) { /* Don't double-filter */
lprintf("%04d !FILTERING IP ADDRESS: %s", socket, host_ip);
filter_ip(&scfg, "SMTP", str, host_ip, reverse_path);
filter_ip(&scfg, "SMTP", str, host_name, host_ip, reverse_path);
strcat(tmp," and FILTERED");
}
spamlog(&scfg, "SMTP", tmp, "Attempted recipient in SPAM BAIT list"
......
......@@ -796,7 +796,7 @@ extern "C" {
DLLEXPORT char * DLLCALL ascii_str(uchar* str);
DLLEXPORT BOOL DLLCALL findstr(char *insearch, char *fname);
DLLEXPORT BOOL DLLCALL trashcan(scfg_t* cfg, char *insearch, char *name);
DLLEXPORT BOOL DLLCALL filter_ip(scfg_t* cfg, char* prot, char* reason, char* ip_addr, char* username);
DLLEXPORT BOOL DLLCALL filter_ip(scfg_t* cfg, char* prot, char* reason, char* host, char* ip_addr, char* username);
DLLEXPORT char * DLLCALL strip_exascii(char *str);
DLLEXPORT char * DLLCALL prep_file_desc(char *str);
DLLEXPORT char * DLLCALL strip_ctrl(char *str);
......
......@@ -2228,20 +2228,28 @@ BOOL DLLCALL is_download_free(scfg_t* cfg, uint dirnum, user_t* user)
/* Add an IP address (with comment) to the IP filter/trashcan file */
/* ToDo: Move somewhere more appropriate (filter.c?) */
/****************************************************************************/
BOOL DLLCALL filter_ip(scfg_t* cfg, char* prot, char* reason, char* ip_addr, char* username)
BOOL DLLCALL filter_ip(scfg_t* cfg, char* prot, char* reason, char* host, char* ip_addr, char* username)
{
char filename[MAX_PATH+1];
char tstr[64];
FILE* fp;
time_t now=time(NULL);
if(ip_addr==NULL)
return(FALSE);
sprintf(filename,"%sip.can",cfg->text_dir);
if((fp=fopen(filename,"a"))==NULL)
return(FALSE);
fprintf(fp,"\n;%s %s by %s on %s\n%s\n"
,prot,reason,username,timestr(cfg,&now,tstr),ip_addr);
fprintf(fp,"\n; %s %s by %s on %s\n"
,prot,reason,username,timestr(cfg,&now,tstr));
if(host!=NULL)
fprintf(fp,"; Hostname: %s\n",host);
fprintf(fp,"%s\n",ip_addr);
fclose(fp);
return(TRUE);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment