Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit e72fbcc2 authored by rswindell's avatar rswindell

filter_ip() can now accept an optional filename argument so other filter files

(besides text/ip.can) can be used.
parent 1b8f11f4
......@@ -1012,6 +1012,7 @@ js_filter_ip(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
char* host=NULL;
char* ip_addr=NULL;
char* from=NULL;
char* fname=NULL;
scfg_t* cfg;
if((cfg=(scfg_t*)JS_GetPrivate(cx,obj))==NULL)
......@@ -1033,8 +1034,10 @@ js_filter_ip(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
ip_addr=p;
else if(from==NULL)
from=p;
else if(fname==NULL)
fname=p;
}
*rval = BOOLEAN_TO_JSVAL(filter_ip(cfg,prot,reason,host,ip_addr,from));
*rval = BOOLEAN_TO_JSVAL(filter_ip(cfg,prot,reason,host,ip_addr,from,fname));
return(JS_TRUE);
}
......
......@@ -796,7 +796,6 @@ 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* 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,9 +2228,10 @@ 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* host, char* ip_addr, char* username)
BOOL DLLCALL filter_ip(scfg_t* cfg, char* prot, char* reason, char* host
,char* ip_addr, char* username, char* fname)
{
char filename[MAX_PATH+1];
char ip_can[MAX_PATH+1];
char tstr[64];
FILE* fp;
time_t now=time(NULL);
......@@ -2238,9 +2239,11 @@ BOOL DLLCALL filter_ip(scfg_t* cfg, char* prot, char* reason, char* host, char*
if(ip_addr==NULL)
return(FALSE);
sprintf(filename,"%sip.can",cfg->text_dir);
sprintf(ip_can,"%sip.can",cfg->text_dir);
if(fname==NULL)
fname=ip_can;
if((fp=fopen(filename,"a"))==NULL)
if((fp=fopen(fname,"a"))==NULL)
return(FALSE);
fprintf(fp,"\n; %s %s by %s on %s\n"
......
......@@ -107,6 +107,7 @@ DLLEXPORT void DLLCALL resetdailyuserdat(scfg_t*, user_t*);
DLLEXPORT void DLLCALL subtract_cdt(scfg_t*, user_t*, long amt);
DLLEXPORT int DLLCALL user_rec_len(int offset);
DLLEXPORT BOOL DLLCALL is_download_free(scfg_t* cfg, uint dirnum, user_t* user);
DLLEXPORT BOOL DLLCALL filter_ip(scfg_t* cfg, char* prot, char* reason, char* host, char* ip_addr, char* username, char* fname);
#ifdef __cplusplus
}
......
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