mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
Create struct that holds FTL related filenames
This commit is contained in:
@@ -47,6 +47,12 @@
|
||||
#define SOCKETBUFFERLEN 1024
|
||||
|
||||
// Static structs
|
||||
typedef struct {
|
||||
const char* log;
|
||||
const char* pid;
|
||||
const char* port;
|
||||
} FTLFileNamesStruct;
|
||||
|
||||
typedef struct {
|
||||
const char* log;
|
||||
const char* gravity;
|
||||
@@ -112,6 +118,7 @@ typedef struct {
|
||||
enum { QUERIES, FORWARDED, CLIENTS, DOMAINS };
|
||||
|
||||
logFileNamesStruct files;
|
||||
FTLFileNamesStruct FTLfiles;
|
||||
countersStruct counters;
|
||||
|
||||
queriesDataStruct *queries;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
bool test_singularity(void)
|
||||
{
|
||||
FILE *f;
|
||||
if((f = fopen("/etc/pihole/FTL.pid", "r")) == NULL)
|
||||
if((f = fopen(FTLfiles.pid, "r")) == NULL)
|
||||
{
|
||||
logg("WARNING: Unable to read PID from file.");
|
||||
logg(" Cannot test if another FTL process is running!");
|
||||
|
||||
@@ -13,13 +13,9 @@
|
||||
void open_FTL_log(void)
|
||||
{
|
||||
// Open a log file in write mode.
|
||||
if((logfile = fopen("/etc/pihole/FTL.log", "a+")) == NULL) {;
|
||||
printf("FATAL: Opening of /etc/pihole/FTL.log failed!\n");
|
||||
if((logfile = fopen(FTLfiles.log, "a+")) == NULL) {;
|
||||
printf("FATAL: Opening of FTL log (%s) failed!\n",FTLfiles.log);
|
||||
printf(" Make sure it exists and is writable using\n");
|
||||
printf(" sudo touch /etc/pihole/FTL.log\n");
|
||||
printf(" sudo touch /etc/pihole/FTL.port\n");
|
||||
printf(" sudo touch /etc/pihole/FTL.pid\n");
|
||||
printf(" sudo chown user:user /etc/pihole/FTL.*\n");
|
||||
// Return failure in exit status
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ void swrite(void)
|
||||
void saveport(int port)
|
||||
{
|
||||
FILE *f;
|
||||
if((f = fopen("/etc/pihole/FTL.port", "w+")) == NULL)
|
||||
if((f = fopen(FTLfiles.port, "w+")) == NULL)
|
||||
{
|
||||
logg("WARNING: Unable to write used port to file.");
|
||||
logg(" Continuing anyway (API might not find the port).");
|
||||
|
||||
@@ -10,6 +10,15 @@
|
||||
|
||||
#include "FTL.h"
|
||||
|
||||
FTLFileNamesStruct FTLfiles = {
|
||||
"/etc/pihole/pihole-FTL.log",
|
||||
"/etc/pihole/pihole-FTL.pid",
|
||||
"/etc/pihole/pihole-FTL.port"
|
||||
// "/var/log/pihole-FTL.log",
|
||||
// "/var/run/pihole-FTL.pid",
|
||||
// "/var/run/pihole-FTL.port"
|
||||
};
|
||||
|
||||
logFileNamesStruct files = {
|
||||
"/var/log/pihole.log",
|
||||
"/etc/pihole/list.preEventHorizon",
|
||||
|
||||
Reference in New Issue
Block a user