diff --git a/src/FTL.h b/src/FTL.h index fc9e9a05..f413ed76 100644 --- a/src/FTL.h +++ b/src/FTL.h @@ -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; diff --git a/src/api/api.c b/src/api/api.c index f1b14668..aea616a0 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -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 diff --git a/src/config.c b/src/config.c index 11e67132..e907f0a9 100644 --- a/src/config.c +++ b/src/config.c @@ -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); diff --git a/src/config.h b/src/config.h index b333334a..3f43127d 100644 --- a/src/config.h +++ b/src/config.h @@ -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 diff --git a/src/daemon.c b/src/daemon.c index 09477f55..eb21b77a 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -11,6 +11,7 @@ #include "FTL.h" #include "daemon.h" #include "memory.h" +#include "config.h" #include "log.h" void go_daemon(void) diff --git a/src/files.c b/src/files.c index c83f884e..c9a9c6ed 100644 --- a/src/files.c +++ b/src/files.c @@ -11,6 +11,7 @@ #include "FTL.h" #include "files.h" #include "memory.h" +#include "config.h" #include "setupVars.h" #include "log.h" diff --git a/src/memory.c b/src/memory.c index 979aebe3..65f0abac 100644 --- a/src/memory.c +++ b/src/memory.c @@ -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; diff --git a/src/memory.h b/src/memory.h index e626e667..394756df 100644 --- a/src/memory.h +++ b/src/memory.h @@ -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 diff --git a/src/setupVars.c b/src/setupVars.c index 0da5b4fb..80924ecd 100644 --- a/src/setupVars.c +++ b/src/setupVars.c @@ -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;