Union FTLFileNamesStruct and logFileNamesStruct and define them in config{.c/.h}

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2019-07-05 16:36:06 +02:00
parent 09b8f91617
commit bddbc3ebd4
9 changed files with 58 additions and 7 deletions
+3
View File
@@ -132,6 +132,7 @@ enum { DB_VERSION, DB_LASTTIMESTAMP, DB_FIRSTCOUNTERTIMESTAMP };
enum { DB_TOTALQUERIES, DB_BLOCKEDQUERIES };
// Static structs
<<<<<<< HEAD
typedef struct {
const char* conf;
const char* snapConf;
@@ -147,6 +148,8 @@ typedef struct {
typedef struct {
char* setupVars;
} logFileNamesStruct;
=======
>>>>>>> e13e39a... Union FTLFileNamesStruct and logFileNamesStruct and define them in config{.c/.h}
typedef struct {
int queries;
+5
View File
@@ -290,8 +290,13 @@ void getTopDomains(const char *client_message, const int *sock)
if(excludedomains != NULL && insetupVarsArray(getstr(domain->domainpos)))
continue;
<<<<<<< HEAD
// Skip this domain if already audited
if(audit && in_auditlist(getstr(domain->domainpos)) > 0)
=======
// Skip this domain if already included in audit
if(audit && countlineswith(getstr(domain->domainpos), FTLfiles.auditlist) > 0)
>>>>>>> e13e39a... Union FTLFileNamesStruct and logFileNamesStruct and define them in config{.c/.h}
continue;
// Hidden domain, probably due to privacy level. Skip this in the top lists
+27 -3
View File
@@ -15,12 +15,30 @@
#include "log.h"
ConfigStruct config;
FTLFileNamesStruct FTLfiles = {
// Default path for config file (regular installations)
"/etc/pihole/pihole-FTL.conf",
// Alternative path for config file (snap installations)
"/var/snap/pihole/common/etc/pihole/pihole-FTL.conf",
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
};
// Private global variables
static char *conflinebuffer = NULL;
// Private prototypes
static char *parse_FTLconf(FILE *fp, const char * key);
static void release_config_memory(void);
static void getpath(FILE* fp, const char *option, const char *defaultloc, char **pointer);
static char *conflinebuffer = NULL;
void getLogFilePath(void)
{
FILE *fp;
@@ -293,8 +311,14 @@ void read_FTLconf(void)
getpath(fp, "SOCKETFILE", "/var/run/pihole/FTL.sock", &FTLfiles.socketfile);
// SETUPVARSFILE
getpath(fp, "SETUPVARSFILE", "/etc/pihole/setupVars.conf", &files.setupVars);
getpath(fp, "SETUPVARSFILE", "/etc/pihole/setupVars.conf", &FTLfiles.setupVars);
<<<<<<< HEAD
=======
// AUDITLISTFILE
getpath(fp, "AUDITLISTFILE", "/etc/pihole/auditlog.list", &FTLfiles.auditlist);
>>>>>>> e13e39a... Union FTLFileNamesStruct and logFileNamesStruct and define them in config{.c/.h}
// MACVENDORDB
getpath(fp, "MACVENDORDB", "/etc/pihole/macvendor.db", &FTLfiles.macvendor_db);
+15
View File
@@ -34,6 +34,21 @@ typedef struct {
bool parse_arp_cache;
} ConfigStruct;
typedef struct {
const char* conf;
const char* snapConf;
char* log;
char* pid;
char* port;
char* socketfile;
char* FTL_db;
char* gravity_db;
char* macvendor_db;
char* setupVars;
char* auditlist;
} FTLFileNamesStruct;
extern ConfigStruct config;
extern FTLFileNamesStruct FTLfiles;
#endif //CONFIG_H
+1
View File
@@ -11,6 +11,7 @@
#include "FTL.h"
#include "daemon.h"
#include "memory.h"
#include "config.h"
#include "log.h"
void go_daemon(void)
+1
View File
@@ -11,6 +11,7 @@
#include "FTL.h"
#include "files.h"
#include "memory.h"
#include "config.h"
#include "setupVars.h"
#include "log.h"
+3
View File
@@ -13,6 +13,7 @@
#include "memory.h"
#include "log.h"
<<<<<<< HEAD
FTLFileNamesStruct FTLfiles = {
// Default path for config file (regular installations)
"/etc/pihole/pihole-FTL.conf",
@@ -31,6 +32,8 @@ logFileNamesStruct files = {
NULL
};
=======
>>>>>>> e13e39a... Union FTLFileNamesStruct and logFileNamesStruct and define them in config{.c/.h}
// Fixed size structs
countersStruct *counters = NULL;
overTimeData *overTime = NULL;
-2
View File
@@ -16,8 +16,6 @@ void *FTLcalloc(size_t nmemb, size_t size, const char *file, const char *functio
void *FTLrealloc(void *ptr_in, size_t size, const char *file, const char *function, const int line) __attribute__((alloc_size(2)));
void FTLfree(void *ptr, const char* file, const char *function, const int line);
extern logFileNamesStruct files;
extern FTLFileNamesStruct FTLfiles;
extern countersStruct *counters;
#endif //MEMORY_H
+3 -2
View File
@@ -11,6 +11,7 @@
#include "FTL.h"
#include "log.h"
#include "memory.h"
#include "config.h"
#include "setupVars.h"
int setupVarsElements = 0;
@@ -19,7 +20,7 @@ char ** setupVarsArray = NULL;
void check_setupVarsconf(void)
{
FILE *setupVarsfp;
if((setupVarsfp = fopen(files.setupVars, "r")) == NULL)
if((setupVarsfp = fopen(FTLfiles.setupVars, "r")) == NULL)
{
logg("WARN: Opening of setupVars.conf failed!");
logg(" Make sure it exists and is readable");
@@ -72,7 +73,7 @@ size_t linebuffersize = 0;
char * read_setupVarsconf(const char * key)
{
FILE *setupVarsfp;
if((setupVarsfp = fopen(files.setupVars, "r")) == NULL)
if((setupVarsfp = fopen(FTLfiles.setupVars, "r")) == NULL)
{
logg("WARN: Reading setupVars.conf failed: %s", strerror(errno));
return NULL;