Reload all lists (but do not clear the DNS cache itself) on receipt of real-time signal 0.

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2019-12-02 15:37:31 +00:00
parent 00c5f24ce7
commit 997d9f9963
6 changed files with 56 additions and 38 deletions
+38
View File
@@ -295,3 +295,41 @@ const char *getClientNameString(const int queryID)
else
return HIDDEN_CLIENT;
}
void FTL_reset_per_client_domain_data(void)
{
for(int domainID = 0; domainID < counters->domains; domainID++)
{
domainsData *domain = getDomain(domainID, true);
if(domain == NULL)
continue;
for(int clientID = 0; clientID < counters->clients; clientID++)
{
// Reset all blocking yes/no fields for all domains and clients
// This forces a reprocessing of all available filters for any
// given domain and client the next time they are seen
domain->clientstatus->set(domain->clientstatus, clientID, UNKNOWN_BLOCKED);
}
}
}
void FTL_reload_all_domainlists(void)
{
// (Re-)open gravity database connection
gravityDB_close();
gravityDB_open();
// gravityDB_close() has finalized all prepared statements, reinitialize them
gravityDB_reload_client_statements();
// Reset number of blocked domains
counters->gravity = gravityDB_count(GRAVITY_TABLE);
// Read and compile possible regex filters
// only after having called gravityDB_open()
read_regex_from_database();
// Reset FTL's internal DNS cache storing whether a specific domain
// has already been validated for a specific user
FTL_reset_per_client_domain_data();
}
+3
View File
@@ -25,6 +25,9 @@ const char *getDomainString(const int queryID);
const char *getClientIPString(const int queryID);
const char *getClientNameString(const int queryID);
void FTL_reload_all_domainlists(void);
void FTL_reset_per_client_domain_data(void);
typedef struct {
unsigned char magic;
unsigned char type;
-1
View File
@@ -1413,7 +1413,6 @@ static void async_event(int pipe, time_t now)
if (daemon->log_file != NULL)
log_reopen(daemon->log_file);
FTL_reset_per_client_domain_data(true);
break;
case EVENT_NEWADDR:
+1 -35
View File
@@ -675,20 +675,7 @@ void FTL_dnsmasq_reload(void)
// Reread pihole-FTL.conf to see which debugging flags are set
read_debuging_settings(NULL);
// (Re-)open gravity database connection
gravityDB_close();
gravityDB_open();
// gravityDB_close() has finalized all prepared statements, reinitialize them
gravityDB_reload_client_statements();
// Reset number of blocked domains
counters->gravity = gravityDB_count(GRAVITY_TABLE);
// Read and compile possible regex filters
// only after having called gravityDB_open()
read_regex_from_database();
FTL_reset_per_client_domain_data(false);
FTL_reload_all_domainlists();
// Print current set of capabilities if requested via debug flag
if(config.debug & DEBUG_CAPS)
@@ -1658,24 +1645,3 @@ static void prepare_blocking_metadata(void)
// Free IPv6addr
clearSetupVarsArray();
}
void FTL_reset_per_client_domain_data(bool sigusr2)
{
if(sigusr2)
logg("Received SIGUSR2, resetting domain blocking data");
for(int domainID = 0; domainID < counters->domains; domainID++)
{
domainsData *domain = getDomain(domainID, true);
if(domain == NULL)
continue;
for(int clientID = 0; clientID < counters->clients; clientID++)
{
// Reset all blocking yes/no fields for all domains and clients
// This forces a reprocessing of all available filters for any
// given domain and client the next time they are seen
domain->clientstatus->set(domain->clientstatus, clientID, UNKNOWN_BLOCKED);
}
}
}
-2
View File
@@ -52,6 +52,4 @@ bool _FTL_CNAME(const char *domain, const struct crec *cpp, const int id, const
void FTL_dnsmasq_reload(void);
void FTL_fork_and_bind_sockets(struct passwd *ent_pw);
void FTL_reset_per_client_domain_data(bool sigusr2);
#endif // DNSMASQ_INTERFACE_H
+14
View File
@@ -17,6 +17,8 @@
#include "memory.h"
// ls_dir()
#include "files.h"
// FTL_reload_all_domainlists()
#include "datastructure.h"
volatile sig_atomic_t killed = 0;
static time_t FTLstarttime = 0;
@@ -82,6 +84,18 @@ static void SIGRT_handler(int signum, siginfo_t *si, void *unused)
{
int rtsig = signum - SIGRTMIN;
logg("Received: %s (%d -> %d)", strsignal(signum), signum, rtsig);
if(rtsig == 0)
{
// Reload
// - gravity
// - exact whitelist
// - regex whitelist
// - exact blacklist
// - exact blacklist
// WITHOUT wiping the DNS cache itself
FTL_reload_all_domainlists();
}
}
void handle_signals(void)