/* * Copyright (C), 2010 by TuxWeb S.r.l. - http://www.tuxweb.it/ * Dino Ciuffetti - * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include #include #include #include #include #include #include #include "uthash.h" #define ACCESS_LOG "access_log" // access_log filename if not specified #define BLACKLIST_TIME 120 // blacklist time in seconds if not specified #define BLACKLIST_FREQUENCY 250 // blacklist frequency into BLACKLIST_TIME seconds if not specified #define HT_KEY_LEN 128 // maximum chars of the hashtable key #define DYNABLAST_VERSION "1.0.2 Stable" // version #define MAX_LINEBUF (8*1024) // maximum line length #define FAST_MODE_FILE "/tmp/dynablast_fm.dat" // fast mode file, if not defined #define LOCK_FILE "/tmp/dynablast.lock" // lock file, if not defined typedef struct _haship { char host[HT_KEY_LEN]; // we use this one as the hask table key time_t timefirst; // time of first occurrence time_t timelast; // time of last occurrence ('til now) unsigned long occurrence; // occurrence number int hit_is_new; // this hit is inside the blacklist period or not int hit_is_too_frequent; // this hit is too frequent or not UT_hash_handle hh; // makes this structure uthashable } iphash; // this one must be setted to NULL!! iphash *badguys; FILE * access_log; time_t last_pagehit_time; // unix timestamp of the last occurred pagehit int blacklist_time; int blacklist_frequency; char *accesslog; int debug; char *fastmodefile; char *lockfile;