pihole-FTL.log was renamed to FTL.log

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2022-07-17 12:20:28 +02:00
parent 4615210b59
commit 20ba471ccd
9 changed files with 101 additions and 104 deletions
+1 -1
View File
@@ -131,7 +131,7 @@ void readFTLconf(void)
bool getLogFilePath(void)
{
// Set default
defaults.files.log = (char*)"/var/log/pihole-FTL.log";
defaults.files.log = (char*)"/var/log/pihole/FTL.log";
config.files.log = defaults.files.log;
// Check if the config file contains a different path
+2 -2
View File
@@ -59,7 +59,7 @@ bool getLogFilePathLegacy(FILE *fp)
return false;
// Read LOGFILE value if available
// defaults to: "/var/log/pihole-FTL.log"
// defaults to: "/var/log/pihole/FTL.log"
char *buffer = parseFTLconf(fp, "LOGFILE");
errno = 0;
@@ -67,7 +67,7 @@ bool getLogFilePathLegacy(FILE *fp)
if(buffer == NULL)
{
// Use standard path if no custom path was obtained from the config file
config.files.log = strdup("/var/log/pihole-FTL.log");
config.files.log = strdup("/var/log/pihole/FTL.log");
// Test if memory allocation was successful
if(config.files.log == NULL)
+1 -1
View File
@@ -236,7 +236,7 @@ void SQLite3LogCallback(void *pArg, int iErrCode, const char *zMsg)
void db_init(void)
{
// Initialize SQLite3 logging callback
// This ensures SQLite3 errors and warnings are logged to pihole-FTL.log
// This ensures SQLite3 errors and warnings are logged to FTL.log
// We use this to possibly catch even more errors in places we do not
// explicitly check for failures to have happened
sqlite3_config(SQLITE_CONFIG_LOG, SQLite3LogCallback, NULL);
+8 -11
View File
@@ -978,14 +978,12 @@ bool gravityDB_getTable(const unsigned char list)
return true;
}
// Get a single domain from a running SELECT operation
// This function returns a pointer to a string as long
// as there are domains available. Once we reached the
// end of the table, it returns NULL. It also returns
// NULL when it encounters an error (e.g., on reading
// errors). Errors are logged to pihole-FTL.log
// This function is performance critical as it might
// be called millions of times for large blocking lists
// Get a single domain from a running SELECT operation This function returns a
// pointer to a string as long as there are domains available. Once we reached
// the end of the table, it returns NULL. It also returns NULL when it
// encounters an error (e.g., on reading errors). Errors are logged to FTL.log
// This function is performance critical as it might be called millions of times
// for large blocking lists
inline const char* gravityDB_getDomain(int *rowid)
{
// Perform step
@@ -1028,9 +1026,8 @@ void gravityDB_finalizeTable(void)
table_stmt = NULL;
}
// Get number of domains in a specified table of the gravity database
// We return the constant DB_FAILED and log to pihole-FTL.log if we
// encounter any error
// Get number of domains in a specified table of the gravity database We return
// the constant DB_FAILED and log to FTL.log if we encounter any error
int gravityDB_count(const enum gravity_tables list)
{
if(!gravityDB_opened && !gravityDB_open())
+6 -6
View File
@@ -307,7 +307,7 @@ void logg_regex_warning(const char *type, const char *warning, const int dbindex
if(getpid() != main_pid())
return;
// Log to pihole-FTL.log
// Log to FTL.log
log_warn("Invalid regex %s filter \"%s\": %s",
type, regex, warning);
@@ -320,7 +320,7 @@ void logg_subnet_warning(const char *ip, const int matching_count, const char *m
const int matching_bits, const char *chosen_match_text,
const int chosen_match_id)
{
// Log to pihole-FTL.log
// Log to FTL.log
log_warn("Client %s is managed by %i groups (IDs %s), all describing /%i subnets. "
"FTL chose the most recent entry %s (ID %i) for this client.",
ip, matching_count, matching_ids, matching_bits,
@@ -334,7 +334,7 @@ void logg_subnet_warning(const char *ip, const int matching_count, const char *m
void logg_hostname_warning(const char *ip, const char *name, const unsigned int pos)
{
// Log to pihole-FTL.log
// Log to FTL.log
log_warn("Host name of client \"%s\" => \"%s\" contains (at least) one invalid character at position %d",
ip, name, pos);
@@ -344,7 +344,7 @@ void logg_hostname_warning(const char *ip, const char *name, const unsigned int
void logg_fatal_dnsmasq_message(const char *message)
{
// Log to pihole-FTL.log
// Log to FTL.log
log_crit("Error in dnsmasq core: %s", message);
// Log to database
@@ -359,7 +359,7 @@ void logg_rate_limit_message(const char *clientIP, const unsigned int rate_limit
{
const time_t turnaround = get_rate_limit_turnaround(rate_limit_count);
// Log to pihole-FTL.log
// Log to FTL.log
log_warn("Rate-limiting %s for at least %ld second%s",
clientIP, turnaround, turnaround == 1 ? "" : "s");
@@ -369,7 +369,7 @@ void logg_rate_limit_message(const char *clientIP, const unsigned int rate_limit
void logg_warn_dnsmasq_message(char *message)
{
// Log to pihole-FTL.log
// Log to FTL.log
log_warn("WARNING in dnsmasq core: %s", message);
// Log to database
+1 -1
View File
@@ -213,7 +213,7 @@ INSERT INTO adlist VALUES(1,'https://hosts-file.net/ad_servers.txt',1,1559928803
INSERT INTO gravity VALUES('allowed.ftl',1);
INSERT INTO gravity VALUES('gravity.ftl',1);
INSERT INTO gravity VALUES('gravity-allowed.ftl',1);
INSERT INTO info VALUES("gravity_count",3);
INSERT INTO info VALUES('gravity_count',3);
INSERT INTO "group" VALUES(1,0,'Test group',1559928803,1559928803,'A disabled test group');
INSERT INTO domainlist_by_group VALUES(15,1);
+1 -1
View File
@@ -127,7 +127,7 @@
[files]
# The location of FTL's log file
# Possible values are: <any writable file>
log = "/var/log/pihole/pihole-FTL.log"
log = "/var/log/pihole/FTL.log"
# The location of FTL's PID file
# Possible values are: <any writable file>
+5 -5
View File
@@ -20,15 +20,15 @@ while pidof -s pihole-FTL > /dev/null; do
done
# Clean up possible old files from earlier test runs
rm -f /etc/pihole/gravity.db /etc/pihole/pihole-FTL.db /var/log/pihole/pihole.log /var/log/pihole/pihole-FTL.log /dev/shm/FTL-*
rm -f /etc/pihole/gravity.db /etc/pihole/pihole-FTL.db /var/log/pihole/pihole.log /var/log/pihole/FTL.log /dev/shm/FTL-*
# Create necessary directories and files
mkdir -p /home/pihole /etc/pihole /run/pihole /var/log/pihole
echo "" > /var/log/pihole/pihole-FTL.log
echo "" > /var/log/pihole/FTL.log
echo "" > /var/log/pihole/pihole.log
touch /run/pihole-FTL.pid /run/pihole-FTL.port dig.log ptr.log
touch /var/log/pihole/HTTP_info.log /var/log/pihole/PH7.log
chown pihole:pihole /etc/pihole /run/pihole /var/log/pihole/pihole.log /var/log/pihole/pihole-FTL.log /run/pihole-FTL.pid /run/pihole-FTL.port
chown pihole:pihole /etc/pihole /run/pihole /var/log/pihole/pihole.log /var/log/pihole/FTL.log /run/pihole-FTL.pid /run/pihole-FTL.port
chown pihole:pihole /var/log/pihole/HTTP_info.log /var/log/pihole/PH7.log
# Copy binary into a location the new user pihole can access
@@ -102,8 +102,8 @@ if [[ $RET != 0 ]]; then
echo -n "pihole.log: "
curl_to_tricorder /var/log/pihole/pihole.log
echo ""
echo -n "pihole-FTL.log: "
curl_to_tricorder /var/log/pihole/pihole-FTL.log
echo -n "FTL.log: "
curl_to_tricorder /var/log/pihole/FTL.log
echo ""
echo -n "dig.log: "
curl_to_tricorder ./dig.log
+76 -76
View File
@@ -33,19 +33,19 @@
}
@test "Starting tests without prior history" {
run bash -c 'grep -c "Total DNS queries: 0" /var/log/pihole/pihole-FTL.log'
run bash -c 'grep -c "Total DNS queries: 0" /var/log/pihole/FTL.log'
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
}
@test "Initial blocking status is enabled" {
run bash -c 'grep -c "Blocking status is enabled" /var/log/pihole/pihole-FTL.log'
run bash -c 'grep -c "Blocking status is enabled" /var/log/pihole/FTL.log'
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
}
@test "Number of compiled regex filters as expected" {
run bash -c 'grep "Compiled [0-9]* allow" /var/log/pihole/pihole-FTL.log'
run bash -c 'grep "Compiled [0-9]* allow" /var/log/pihole/FTL.log'
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == *"Compiled 2 allow and 9 deny regex for 1 client in "* ]]
}
@@ -159,31 +159,31 @@
@test "Client 4: Client is recognized by MAC address" {
run bash -c "dig TXT CHAOS version.bind -b 127.0.0.4 @127.0.0.1 +short"
run sleep 0.1
run bash -c "grep -c \"Found database hardware address 127.0.0.4 -> aa:bb:cc:dd:ee:ff\" /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c \"Found database hardware address 127.0.0.4 -> aa:bb:cc:dd:ee:ff\" /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
run bash -c "grep -c \"Gravity database: Client aa:bb:cc:dd:ee:ff found. Using groups (4)\" /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c \"Gravity database: Client aa:bb:cc:dd:ee:ff found. Using groups (4)\" /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} != "0" ]]
run bash -c "grep -c 'Regex deny: Querying groups for client 127.0.0.4: \"SELECT id from vw_regex_blacklist WHERE group_id IN (4);\"' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'Regex deny: Querying groups for client 127.0.0.4: \"SELECT id from vw_regex_blacklist WHERE group_id IN (4);\"' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
run bash -c "grep -c 'Regex allow: Querying groups for client 127.0.0.4: \"SELECT id from vw_regex_whitelist WHERE group_id IN (4);\"' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'Regex allow: Querying groups for client 127.0.0.4: \"SELECT id from vw_regex_whitelist WHERE group_id IN (4);\"' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
run bash -c "grep -c 'get_client_querystr: SELECT EXISTS(SELECT domain from vw_whitelist WHERE domain = ? AND group_id IN (4));' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'get_client_querystr: SELECT EXISTS(SELECT domain from vw_whitelist WHERE domain = ? AND group_id IN (4));' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} != "0" ]]
run bash -c "grep -c 'get_client_querystr: SELECT EXISTS(SELECT domain from vw_blacklist WHERE domain = ? AND group_id IN (4));' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'get_client_querystr: SELECT EXISTS(SELECT domain from vw_blacklist WHERE domain = ? AND group_id IN (4));' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} != "0" ]]
run bash -c "grep -c 'get_client_querystr: SELECT EXISTS(SELECT domain from vw_gravity WHERE domain = ? AND group_id IN (4));' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'get_client_querystr: SELECT EXISTS(SELECT domain from vw_gravity WHERE domain = ? AND group_id IN (4));' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} != "0" ]]
run bash -c "grep -c 'Regex allow ([[:digit:]]*, DB ID [[:digit:]]*) .* NOT ENABLED for client 127.0.0.4' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'Regex allow ([[:digit:]]*, DB ID [[:digit:]]*) .* NOT ENABLED for client 127.0.0.4' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "2" ]]
run bash -c "grep -c 'Regex deny ([[:digit:]]*, DB ID [[:digit:]]*) .* NOT ENABLED for client 127.0.0.4' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'Regex deny ([[:digit:]]*, DB ID [[:digit:]]*) .* NOT ENABLED for client 127.0.0.4' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "9" ]]
}
@@ -191,31 +191,31 @@
@test "Client 5: Client is recognized by MAC address" {
run bash -c "dig TXT CHAOS version.bind -b 127.0.0.5 @127.0.0.1 +short"
run sleep 0.1
run bash -c "grep -c \"Found database hardware address 127.0.0.5 -> aa:bb:cc:dd:ee:ff\" /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c \"Found database hardware address 127.0.0.5 -> aa:bb:cc:dd:ee:ff\" /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
run bash -c "grep -c \"Gravity database: Client aa:bb:cc:dd:ee:ff found. Using groups (4)\" /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c \"Gravity database: Client aa:bb:cc:dd:ee:ff found. Using groups (4)\" /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} != "0" ]]
run bash -c "grep -c 'Regex deny: Querying groups for client 127.0.0.5: \"SELECT id from vw_regex_blacklist WHERE group_id IN (4);\"' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'Regex deny: Querying groups for client 127.0.0.5: \"SELECT id from vw_regex_blacklist WHERE group_id IN (4);\"' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
run bash -c "grep -c 'Regex allow: Querying groups for client 127.0.0.5: \"SELECT id from vw_regex_whitelist WHERE group_id IN (4);\"' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'Regex allow: Querying groups for client 127.0.0.5: \"SELECT id from vw_regex_whitelist WHERE group_id IN (4);\"' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
run bash -c "grep -c 'get_client_querystr: SELECT EXISTS(SELECT domain from vw_whitelist WHERE domain = ? AND group_id IN (4));' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'get_client_querystr: SELECT EXISTS(SELECT domain from vw_whitelist WHERE domain = ? AND group_id IN (4));' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} != "0" ]]
run bash -c "grep -c 'get_client_querystr: SELECT EXISTS(SELECT domain from vw_blacklist WHERE domain = ? AND group_id IN (4));' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'get_client_querystr: SELECT EXISTS(SELECT domain from vw_blacklist WHERE domain = ? AND group_id IN (4));' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} != "0" ]]
run bash -c "grep -c 'get_client_querystr: SELECT EXISTS(SELECT domain from vw_gravity WHERE domain = ? AND group_id IN (4));' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'get_client_querystr: SELECT EXISTS(SELECT domain from vw_gravity WHERE domain = ? AND group_id IN (4));' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} != "0" ]]
run bash -c "grep -c 'Regex allow ([[:digit:]]*, DB ID [[:digit:]]*) .* NOT ENABLED for client 127.0.0.5' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'Regex allow ([[:digit:]]*, DB ID [[:digit:]]*) .* NOT ENABLED for client 127.0.0.5' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "2" ]]
run bash -c "grep -c 'Regex deny ([[:digit:]]*, DB ID [[:digit:]]*) .* NOT ENABLED for client 127.0.0.5' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'Regex deny ([[:digit:]]*, DB ID [[:digit:]]*) .* NOT ENABLED for client 127.0.0.5' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "9" ]]
}
@@ -223,37 +223,37 @@
@test "Client 6: Client is recognized by interface name" {
run bash -c "dig TXT CHAOS version.bind -b 127.0.0.6 @127.0.0.1 +short"
run sleep 0.1
run bash -c "grep -c \"Found database hardware address 127.0.0.6 -> 00:11:22:33:44:55\" /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c \"Found database hardware address 127.0.0.6 -> 00:11:22:33:44:55\" /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
run bash -c "grep -c \"There is no record for 00:11:22:33:44:55 in the client table\" /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c \"There is no record for 00:11:22:33:44:55 in the client table\" /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
run bash -c "grep -c \"Found database interface 127.0.0.6 -> enp0s123\" /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c \"Found database interface 127.0.0.6 -> enp0s123\" /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
run bash -c "grep -c \"Gravity database: Client 00:11:22:33:44:55 found (identified by interface enp0s123). Using groups (5)\" /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c \"Gravity database: Client 00:11:22:33:44:55 found (identified by interface enp0s123). Using groups (5)\" /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
run bash -c "grep -c 'Regex deny: Querying groups for client 127.0.0.6: \"SELECT id from vw_regex_blacklist WHERE group_id IN (5);\"' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'Regex deny: Querying groups for client 127.0.0.6: \"SELECT id from vw_regex_blacklist WHERE group_id IN (5);\"' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
run bash -c "grep -c 'Regex allow: Querying groups for client 127.0.0.6: \"SELECT id from vw_regex_whitelist WHERE group_id IN (5);\"' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'Regex allow: Querying groups for client 127.0.0.6: \"SELECT id from vw_regex_whitelist WHERE group_id IN (5);\"' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
run bash -c "grep -c 'get_client_querystr: SELECT EXISTS(SELECT domain from vw_whitelist WHERE domain = ? AND group_id IN (5));' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'get_client_querystr: SELECT EXISTS(SELECT domain from vw_whitelist WHERE domain = ? AND group_id IN (5));' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
run bash -c "grep -c 'get_client_querystr: SELECT EXISTS(SELECT domain from vw_blacklist WHERE domain = ? AND group_id IN (5));' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'get_client_querystr: SELECT EXISTS(SELECT domain from vw_blacklist WHERE domain = ? AND group_id IN (5));' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
run bash -c "grep -c 'get_client_querystr: SELECT EXISTS(SELECT domain from vw_gravity WHERE domain = ? AND group_id IN (5));' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'get_client_querystr: SELECT EXISTS(SELECT domain from vw_gravity WHERE domain = ? AND group_id IN (5));' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
run bash -c "grep -c 'Regex allow ([[:digit:]]*, DB ID [[:digit:]]*) .* NOT ENABLED for client 127.0.0.6' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'Regex allow ([[:digit:]]*, DB ID [[:digit:]]*) .* NOT ENABLED for client 127.0.0.6' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "2" ]]
run bash -c "grep -c 'Regex deny ([[:digit:]]*, DB ID [[:digit:]]*) .* NOT ENABLED for client 127.0.0.6' /var/log/pihole/pihole-FTL.log"
run bash -c "grep -c 'Regex deny ([[:digit:]]*, DB ID [[:digit:]]*) .* NOT ENABLED for client 127.0.0.6' /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "9" ]]
}
@@ -445,40 +445,40 @@
[[ ${lines[3]} == "Available arguments:" ]]
}
#@test "No WARNING messages in pihole-FTL.log (besides known capability issues)" {
# run bash -c 'grep "WARNING" /var/log/pihole/pihole-FTL.log'
#@test "No WARNING messages in FTL.log (besides known capability issues)" {
# run bash -c 'grep "WARNING" /var/log/pihole/FTL.log'
# printf "%s\n" "${lines[@]}"
# run bash -c 'grep "WARNING" /var/log/pihole/pihole-FTL.log | grep -c -v -E "CAP_NET_ADMIN|CAP_NET_RAW|CAP_SYS_NICE|CAP_IPC_LOCK|CAP_CHOWN"'
# run bash -c 'grep "WARNING" /var/log/pihole/FTL.log | grep -c -v -E "CAP_NET_ADMIN|CAP_NET_RAW|CAP_SYS_NICE|CAP_IPC_LOCK|CAP_CHOWN"'
# printf "%s\n" "${lines[@]}"
# [[ ${lines[0]} == "0" ]]
#}
#@test "No FATAL messages in pihole-FTL.log (besides error due to starting FTL more than once)" {
# run bash -c 'grep "FATAL" /var/log/pihole/pihole-FTL.log'
#@test "No FATAL messages in FTL.log (besides error due to starting FTL more than once)" {
# run bash -c 'grep "FATAL" /var/log/pihole/FTL.log'
# printf "%s\n" "${lines[@]}"
# run bash -c 'grep "FATAL:" /var/log/pihole/pihole-FTL.log | grep -c -v "FATAL: create_shm(): Failed to create shared memory object \"FTL-lock\": File exists"'
# run bash -c 'grep "FATAL:" /var/log/pihole/FTL.log | grep -c -v "FATAL: create_shm(): Failed to create shared memory object \"FTL-lock\": File exists"'
# printf "%s\n" "${lines[@]}"
# [[ ${lines[0]} == "0" ]]
#}
@test "No \"database not available\" messages in pihole-FTL.log" {
run bash -c 'grep -c "database not available" /var/log/pihole/pihole-FTL.log'
@test "No \"database not available\" messages in FTL.log" {
run bash -c 'grep -c "database not available" /var/log/pihole/FTL.log'
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "0" ]]
}
# Regex tests
@test "Compiled deny regex as expected" {
run bash -c 'grep -c "Compiling deny regex 0 (DB ID 6): regex\[0-9\].ftl" /var/log/pihole/pihole-FTL.log'
run bash -c 'grep -c "Compiling deny regex 0 (DB ID 6): regex\[0-9\].ftl" /var/log/pihole/FTL.log'
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
}
@test "Compiled allow regex as expected" {
run bash -c 'grep -c "Compiling allow regex 0 (DB ID 3): regex2" /var/log/pihole/pihole-FTL.log'
run bash -c 'grep -c "Compiling allow regex 0 (DB ID 3): regex2" /var/log/pihole/FTL.log'
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
run bash -c 'grep -c "Compiling allow regex 1 (DB ID 4): ^gravity-allowed" /var/log/pihole/pihole-FTL.log'
run bash -c 'grep -c "Compiling allow regex 1 (DB ID 4): ^gravity-allowed" /var/log/pihole/FTL.log'
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
}
@@ -867,21 +867,21 @@
}
@test "Architecture is correctly reported on startup" {
run bash -c 'grep "Compiled for" /var/log/pihole/pihole-FTL.log'
run bash -c 'grep "Compiled for" /var/log/pihole/FTL.log'
printf "Output: %s\n\$CI_ARCH: %s\nuname -m: %s\n" "${lines[@]:-not set}" "${CI_ARCH:-not set}" "$(uname -m)"
[[ ${lines[0]} == *"Compiled for ${CI_ARCH:-$(uname -m)}"* ]]
}
@test "Building machine (CI) is reported on startup" {
[[ ${CI_ARCH} != "" ]] && compiled_str="on CI" || compiled_str="locally" && export compiled_str
run bash -c 'grep "Compiled for" /var/log/pihole/pihole-FTL.log'
run bash -c 'grep "Compiled for" /var/log/pihole/FTL.log'
printf "Output: %s\n\$CI_ARCH: %s\n" "${lines[@]:-not set}" "${CI_ARCH:-not set}"
[[ ${lines[0]} == *"(compiled ${compiled_str})"* ]]
}
@test "Compiler version is correctly reported on startup" {
compiler_version="$(${CC} --version | head -n1)" && export compiler_version
run bash -c 'grep "Compiled for" /var/log/pihole/pihole-FTL.log'
run bash -c 'grep "Compiled for" /var/log/pihole/FTL.log'
printf "Output: %s\n\$CC: %s\nVersion: %s\n" "${lines[@]:-not set}" "${CC:-not set}" "${compiler_version:-not set}"
[[ ${lines[0]} == *"using ${compiler_version}"* ]]
}
@@ -893,7 +893,7 @@
}
@test "No errors on setting busy handlers for the databases" {
run bash -c 'grep -c "Cannot set busy handler" /var/log/pihole/pihole-FTL.log'
run bash -c 'grep -c "Cannot set busy handler" /var/log/pihole/FTL.log'
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "0" ]]
}
@@ -971,7 +971,7 @@
@test "EDNS(0) analysis working as expected" {
# Get number of lines in the log before the test
before="$(grep -c ^ /var/log/pihole/pihole-FTL.log)"
before="$(grep -c ^ /var/log/pihole/FTL.log)"
# Run test command
# CLIENT SUBNET COOKIE MAC HEX MAC TEXT CPE-ID
@@ -981,10 +981,10 @@
[[ $status == 0 ]]
# Get number of lines in the log after the test
after="$(grep -c ^ /var/log/pihole/pihole-FTL.log)"
after="$(grep -c ^ /var/log/pihole/FTL.log)"
# Extract relevant log lines
log="$(sed -n "${before},${after}p" /var/log/pihole/pihole-FTL.log)"
log="$(sed -n "${before},${after}p" /var/log/pihole/FTL.log)"
printf "%s\n" "${log}"
# Start actual test
@@ -1007,7 +1007,7 @@
@test "EDNS(0) ECS can overwrite client address (IPv4)" {
# Get number of lines in the log before the test
before="$(grep -c ^ /var/log/pihole/pihole-FTL.log)"
before="$(grep -c ^ /var/log/pihole/FTL.log)"
# Run test command
run bash -c 'dig localhost +short +subnet=192.168.47.97/32 @127.0.0.1'
@@ -1016,17 +1016,17 @@
[[ $status == 0 ]]
# Get number of lines in the log after the test
after="$(grep -c ^ /var/log/pihole/pihole-FTL.log)"
after="$(grep -c ^ /var/log/pihole/FTL.log)"
# Extract relevant log lines
run bash -c "sed -n \"${before},${after}p\" /var/log/pihole/pihole-FTL.log"
run bash -c "sed -n \"${before},${after}p\" /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ "${lines[@]}" == *"**** new UDP IPv4 query[A] query \"localhost\" from lo/192.168.47.97#53 "* ]]
}
@test "EDNS(0) ECS can overwrite client address (IPv6)" {
# Get number of lines in the log before the test
before="$(grep -c ^ /var/log/pihole/pihole-FTL.log)"
before="$(grep -c ^ /var/log/pihole/FTL.log)"
# Run test command
run bash -c 'dig localhost +short +subnet=fe80::b167:af1e:968b:dead/128 @127.0.0.1'
@@ -1035,29 +1035,29 @@
[[ $status == 0 ]]
# Get number of lines in the log after the test
after="$(grep -c ^ /var/log/pihole/pihole-FTL.log)"
after="$(grep -c ^ /var/log/pihole/FTL.log)"
# Extract relevant log lines
run bash -c "sed -n \"${before},${after}p\" /var/log/pihole/pihole-FTL.log"
run bash -c "sed -n \"${before},${after}p\" /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ "${lines[@]}" == *"**** new UDP IPv4 query[A] query \"localhost\" from lo/fe80::b167:af1e:968b:dead#53 "* ]]
}
@test "alias-client is imported and used for configured client" {
run bash -c 'grep -c "Added alias-client \"some-aliasclient\" (aliasclient-0) with FTL ID 0" /var/log/pihole/pihole-FTL.log'
run bash -c 'grep -c "Added alias-client \"some-aliasclient\" (aliasclient-0) with FTL ID 0" /var/log/pihole/FTL.log'
printf "Added: %s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
run bash -c 'grep -c "Aliasclient ID 127.0.0.6 -> 0" /var/log/pihole/pihole-FTL.log'
run bash -c 'grep -c "Aliasclient ID 127.0.0.6 -> 0" /var/log/pihole/FTL.log'
printf "Found ID: %s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
run bash -c 'grep -c "Client .* (127.0.0.6) IS managed by this alias-client, adding counts" /var/log/pihole/pihole-FTL.log'
run bash -c 'grep -c "Client .* (127.0.0.6) IS managed by this alias-client, adding counts" /var/log/pihole/FTL.log'
printf "Adding counts: %s\n" "${lines[@]}"
[[ ${lines[0]} == "1" ]]
}
@test "EDNS(0) ECS skipped for loopback address (IPv4)" {
# Get number of lines in the log before the test
before="$(grep -c ^ /var/log/pihole/pihole-FTL.log)"
before="$(grep -c ^ /var/log/pihole/FTL.log)"
# Run test command
run bash -c 'dig localhost +short +subnet=127.0.0.1/32 @127.0.0.1'
@@ -1066,17 +1066,17 @@
[[ $status == 0 ]]
# Get number of lines in the log after the test
after="$(grep -c ^ /var/log/pihole/pihole-FTL.log)"
after="$(grep -c ^ /var/log/pihole/FTL.log)"
# Extract relevant log lines
run bash -c "sed -n \"${before},${after}p\" /var/log/pihole/pihole-FTL.log"
run bash -c "sed -n \"${before},${after}p\" /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ "${lines[@]}" == *"EDNS(0) CLIENT SUBNET: Skipped 127.0.0.1/32 (IPv4 loopback address)"* ]]
}
@test "EDNS(0) ECS skipped for loopback address (IPv6)" {
# Get number of lines in the log before the test
before="$(grep -c ^ /var/log/pihole/pihole-FTL.log)"
before="$(grep -c ^ /var/log/pihole/FTL.log)"
# Run test command
run bash -c 'dig localhost +short +subnet=::1/128 @127.0.0.1'
@@ -1085,10 +1085,10 @@
[[ $status == 0 ]]
# Get number of lines in the log after the test
after="$(grep -c ^ /var/log/pihole/pihole-FTL.log)"
after="$(grep -c ^ /var/log/pihole/FTL.log)"
# Extract relevant log lines
run bash -c "sed -n \"${before},${after}p\" /var/log/pihole/pihole-FTL.log"
run bash -c "sed -n \"${before},${after}p\" /var/log/pihole/FTL.log"
printf "%s\n" "${lines[@]}"
[[ "${lines[@]}" == *"EDNS(0) CLIENT SUBNET: Skipped ::1/128 (IPv6 loopback address)"* ]]
}
@@ -1126,34 +1126,34 @@
[[ "${lines[@]}" != *"ERROR"* ]]
}
@test "No WARNING messages in pihole-FTL.log (besides known capability issues)" {
run bash -c 'grep "WARNING: " /var/log/pihole/pihole-FTL.log'
@test "No WARNING messages in FTL.log (besides known capability issues)" {
run bash -c 'grep "WARNING: " /var/log/pihole/FTL.log'
printf "%s\n" "${lines[@]}"
run bash -c 'grep "WARNING: " /var/log/pihole/pihole-FTL.log | grep -c -v -E "CAP_NET_ADMIN|CAP_NET_RAW|CAP_SYS_NICE"'
run bash -c 'grep "WARNING: " /var/log/pihole/FTL.log | grep -c -v -E "CAP_NET_ADMIN|CAP_NET_RAW|CAP_SYS_NICE"'
printf "count: %s\n" "${lines[@]}"
[[ ${lines[0]} == "0" ]]
}
@test "No ERROR messages in pihole-FTL.log (besides known index.html error)" {
run bash -c 'grep "ERR: " /var/log/pihole/pihole-FTL.log'
@test "No ERROR messages in FTL.log (besides known index.html error)" {
run bash -c 'grep "ERR: " /var/log/pihole/FTL.log'
printf "%s\n" "${lines[@]}"
run bash -c 'grep "ERR: " /var/log/pihole/pihole-FTL.log | grep -c -v -E "(index\.html)|(Failed to create shared memory object)"'
run bash -c 'grep "ERR: " /var/log/pihole/FTL.log | grep -c -v -E "(index\.html)|(Failed to create shared memory object)"'
printf "count: %s\n" "${lines[@]}"
[[ ${lines[0]} == "0" ]]
}
@test "No CRIT messages in pihole-FTL.log (besides error due to testing to start FTL more than once)" {
run bash -c 'grep "CRIT: " /var/log/pihole/pihole-FTL.log'
@test "No CRIT messages in FTL.log (besides error due to testing to start FTL more than once)" {
run bash -c 'grep "CRIT: " /var/log/pihole/FTL.log'
printf "%s\n" "${lines[@]}"
run bash -c 'grep "CRIT: " /var/log/pihole/pihole-FTL.log | grep -c -v "Initialization of shared memory failed."'
run bash -c 'grep "CRIT: " /var/log/pihole/FTL.log | grep -c -v "Initialization of shared memory failed."'
printf "count: %s\n" "${lines[@]}"
[[ ${lines[0]} == "0" ]]
}
@test "No config errors in pihole-FTL.toml" {
run bash -c 'grep "DEBUG_CONFIG: " /var/log/pihole/pihole-FTL.log'
run bash -c 'grep "DEBUG_CONFIG: " /var/log/pihole/FTL.log'
printf "%s\n" "${lines[@]}"
run bash -c 'grep "DEBUG_CONFIG: " /var/log/pihole/pihole-FTL.log | grep -c "DOES NOT EXIST"'
run bash -c 'grep "DEBUG_CONFIG: " /var/log/pihole/FTL.log | grep -c "DOES NOT EXIST"'
printf "count: %s\n" "${lines[@]}"
[[ ${lines[0]} == "0" ]]
}