mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
Add additional_info column to queries table. We fill it with the domain that caused blocking the entire CNAME chain.
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -361,6 +361,24 @@ void db_init(void)
|
||||
dbversion = db_get_FTL_property(DB_VERSION);
|
||||
}
|
||||
|
||||
// Update to version 7 if lower
|
||||
if(dbversion < 7)
|
||||
{
|
||||
// Update to version 7: Create message table
|
||||
logg("Updating long-term database to version 7");
|
||||
if(dbquery("ALTER TABLE queries ADD COLUMN additional_info TEXT;") != SQLITE_OK ||
|
||||
!db_set_FTL_property(DB_VERSION, 7))
|
||||
{
|
||||
logg("Column additional_info not initialized, database not available");
|
||||
dbclose();
|
||||
|
||||
database = false;
|
||||
return;
|
||||
}
|
||||
// Get updated version
|
||||
dbversion = db_get_FTL_property(DB_VERSION);
|
||||
}
|
||||
|
||||
// Close database to prevent having it opened all time
|
||||
// We already closed the database when we returned earlier
|
||||
dbclose();
|
||||
|
||||
@@ -85,7 +85,7 @@ void DB_save_queries(void)
|
||||
return;
|
||||
}
|
||||
|
||||
rc = sqlite3_prepare_v2(FTL_db, "INSERT INTO queries VALUES (NULL,?,?,?,?,?,?)", -1, &stmt, NULL);
|
||||
rc = sqlite3_prepare_v2(FTL_db, "INSERT INTO queries VALUES (NULL,?,?,?,?,?,?,?)", -1, &stmt, NULL);
|
||||
if( rc != SQLITE_OK )
|
||||
{
|
||||
const char *text, *spaces;
|
||||
@@ -169,6 +169,21 @@ void DB_save_queries(void)
|
||||
sqlite3_bind_null(stmt, 6);
|
||||
}
|
||||
|
||||
// Fill additional information column
|
||||
if(query->status == QUERY_GRAVITY_CNAME ||
|
||||
query->status == QUERY_REGEX_CNAME ||
|
||||
query->status == QUERY_BLACKLIST_CNAME)
|
||||
{
|
||||
// Get domain blocked during deep CNAME inspection, if applicable
|
||||
const char* cname = getCNAMEDomainString(query);
|
||||
sqlite3_bind_text(stmt, 7, cname, -1, SQLITE_STATIC);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Nothing to add here
|
||||
sqlite3_bind_null(stmt, 7);
|
||||
}
|
||||
|
||||
// Step and check if successful
|
||||
rc = sqlite3_step(stmt);
|
||||
sqlite3_clear_bindings(stmt);
|
||||
|
||||
Reference in New Issue
Block a user