Skip to content

Commit

Permalink
Remove "TIMEFRAME" option
Browse files Browse the repository at this point in the history
Signed-off-by: DL6ER <dl6er@dl6er.de>
  • Loading branch information
DL6ER committed Jan 21, 2018
1 parent 1ca9203 commit 6da7c01
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 38 deletions.
2 changes: 0 additions & 2 deletions FTL.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ typedef struct {

typedef struct {
bool socket_listenlocal;
bool include_yesterday;
bool rolling_24h;
bool query_display;
bool analyze_AAAA;
int maxDBdays;
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ You can create a file `/etc/pihole/pihole-FTL.conf` that will be read by `FTL` o
Possible settings (**the option shown first is the default**):

- `SOCKET_LISTENING=localonly|all` (Listen only for local socket connections or permit all connections)
- `TIMEFRAME=rolling24h|yesterday|today` (Rolling data window, up to 48h (today + yesterday), or up to 24h (only today, as in Pi-hole `v2.x` ))
- `QUERY_DISPLAY=yes|no` (Display all queries? Set to `no` to hide query display)
- `AAAA_QUERY_ANALYSIS=yes|no` (Allow `FTL` to analyze AAAA queries from pihole.log?)
- `MAXDBDAYS=365` (How long should queries be stored in the database? Setting this to `0` disables the database altogether)
Expand Down
22 changes: 0 additions & 22 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,6 @@ void read_FTLconf(void)
else
logg(" SOCKET_LISTENING: all destinations");

// TIMEFRAME
// defaults to: ROLLING
config.rolling_24h = true;
config.include_yesterday = true;
buffer = parse_FTLconf(fp, "TIMEFRAME");

if(buffer != NULL && strcmp(buffer, "yesterday") == 0)
{
config.include_yesterday = true;
config.rolling_24h = false;
logg(" TIMEFRAME: Yesterday + Today");
}
else if(buffer != NULL && strcmp(buffer, "today") == 0)
{
config.include_yesterday = false;
config.rolling_24h = false;
logg(" TIMEFRAME: Today");
}

if(config.rolling_24h)
logg(" TIMEFRAME: Rolling 24h");

// QUERY_DISPLAY
// defaults to: Yes
config.query_display = true;
Expand Down
11 changes: 4 additions & 7 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,11 @@ int main (int argc, char* argv[]) {
needGC = false;
runGCthread = false;

if(config.rolling_24h)
pthread_t GCthread;
if(pthread_create( &GCthread, &attr, GC_thread, NULL ) != 0)
{
pthread_t GCthread;
if(pthread_create( &GCthread, &attr, GC_thread, NULL ) != 0)
{
logg("Unable to open GC thread. Exiting...");
killed = 1;
}
logg("Unable to open GC thread. Exiting...");
killed = 1;
}

if(database)
Expand Down
12 changes: 6 additions & 6 deletions parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ void process_pihole_log(void)
// Check if this query has already been imported from the database
if(querytimestamp < lastDBimportedtimestamp) continue;

// Skip parsing of log entries that are too old
// Get minimum time stamp to analyze
int differencetofullhour = time(NULL) % GCinterval;
int mintime = (time(NULL) - GCdelay - differencetofullhour) - MAXLOGAGE;
if(querytimestamp < mintime) continue;

// Test if the read line is a query line
if(strstr(readbuffer," query[A") != NULL)
{
Expand All @@ -271,12 +277,6 @@ void process_pihole_log(void)
continue;
}

// Get minimum time stamp to analyze
int differencetofullhour = time(NULL) % GCinterval;
int mintime = (time(NULL) - GCdelay - differencetofullhour) - MAXLOGAGE;
// Skip parsing of log entries that are too old altogether if 24h window is requested
if(config.rolling_24h && querytimestamp < mintime) continue;

// Ensure we have enough space in the queries struct
memory_check(QUERIES);
int queryID = counters.queries;
Expand Down

0 comments on commit 6da7c01

Please sign in to comment.