Commit Graph

97 Commits

Author SHA1 Message Date
DL6ER af8ab3ef2f Large-scale overhaul for the long-term database handling.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-03-24 10:44:27 +01:00
DL6ER 302dbaed84 Use IMMEDIATE transaction when adding to the database. This ensures we do not even try to collect queries when we cannot write to the database.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-03-23 16:15:29 +01:00
DL6ER 0be640e1e8 Clarify that busy timeout is not an error, just a warning.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-03-23 16:09:04 +01:00
DL6ER 07c8de2340 Signal early that database is opened to prevent re-opening in sub-processes.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-03-23 09:58:44 +01:00
DL6ER 2fbdf7b004 Do not open gravity database if already connected.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-03-23 08:33:28 +01:00
DL6ER aa3cc95ae1 Add more debugging output to database opening.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-03-23 08:28:09 +01:00
DL6ER 5c3661015f Fix preparation of client statements when gravity database had to be re-opened.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-03-08 16:27:06 +01:00
DL6ER 71d2c8dcd7 Add busy timeout to gravity per-client group configuration importing. This may help on slow devices where updating the database is not yet finished when FTL is already trying to re-read to database tables.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-02-22 12:31:29 +01:00
DL6ER 3e7641abee Try to reopen gravity database when not available.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-02-22 12:06:26 +01:00
DL6ER 1344c91d12 Merge pull request #697 from pi-hole/fix/incorrect_db_warning
Fix incorrect database warnings
2020-02-21 19:12:40 +01:00
DL6ER 0554597223 Fix incorrect database warning when imporint new CNAME blocked queries.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-02-20 21:54:06 +01:00
DL6ER 620daa7ee6 Remove UNKNOWN DNSSEC status and import queries with UNSPECIFIED DNSSEC status (this will not cause a text to be shown on the Query Log). We do not use the UNKNOWN status anywhere else, so we can now get rid of it.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-02-20 19:33:46 +01:00
DL6ER 7ca81e3d59 Merge pull request #685 from pi-hole/new/CNAME_inspection_details
Improvements to deep CNAME inspection data processing
2020-02-12 19:36:36 +01:00
DL6ER 06b5f3ca6f Merge branch 'release/v5.0' into new/CNAME_inspection_details
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-02-11 10:17:44 +01:00
DL6ER acdd2253e6 Finish renaming "forward destionations" to "upstreams".
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-02-11 10:09:02 +01:00
DL6ER c32d790eba Rename "forwarded" counter to "upstreams" to avoid confusion in the future. We used sed to ensure to have caught every reference.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-02-11 09:35:07 +01:00
DL6ER 0d9b301733 Ensure we group domains read from the views by their ID to avoid importing identical regex filters multiple times.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-02-06 17:45:42 +01:00
DL6ER 66f061265b Special debug logging.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-02-05 23:41:40 +01:00
DL6ER 3ecc42b69d Merge branch 'release/v5.0' into tweak/gravity_count 2020-02-04 20:52:28 +01:00
DL6ER 5c08c56d35 Store ID of matching blacklist regex if this is the blocking reason.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-02-04 08:34:01 +01:00
DL6ER 1af474819c Update tests to use gravity domain count stored in test database.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-02-03 08:43:06 +01:00
DL6ER 2e7e6231e7 Use number of distinct gravity domains as counted and stored by pihole -g itself. This drastically reduces the runtime of reload-lists.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-02-02 23:45:12 +01:00
DL6ER 122a701f16 Add new CNAME-specific blocking modes [QUERY_GRAVITY_CNAME, QUERY_REGEX_CNAME, QUERY_BLACKLIST_CNAME] and store domain that was the reason for blocking during a CNAME inspection
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-01-29 21:58:58 +00:00
DL6ER 6a6608fd60 Clarify gravity database debug message
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-01-28 19:04:30 +01:00
DL6ER 4c74a29f87 Add shared per-client regex array. This ensures TCP and UDP workers know the same details about client/regex combinations. This commit also fixes an issue with regex group associations for configured clients that have no assigned group.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-12-30 17:14:40 +00:00
DL6ER 33940f2cf2 Add group zero support.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-12-12 17:24:12 +00:00
DL6ER 9d65dd566f Check if gravity database is available before trying to use it in get_client_groupids().
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-11-28 09:18:07 +01:00
DL6ER 8752400609 Ensure domains encountered while following CNAME paths are not double-counted.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-11-25 13:44:23 +01:00
DL6ER 367d9aebe5 Merge branch 'development' into new/internal-blocking
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-11-12 07:10:09 +01:00
DL6ER c91c39a541 getDatabaseHostname() is guaranteed to allocate memory. Hence, it should be given the attribute ((malloc)).
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-10-20 22:02:16 +02:00
Mark Drobnak 656ba76d23 Merge pull request #648 from pi-hole/new/get_hostname_from_network_table
Use network table as secondary source for client host names
2019-10-20 15:41:19 -04:00
DL6ER 34f3bfe966 Merge branch 'development' into new/internal-blocking 2019-10-20 15:37:21 +02:00
DL6ER ab50c5ccc4 Update SQLite from 3.30.0 to 3.30.1
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-10-11 17:49:12 +02:00
Mark Drobnak 65737e1f74 Merge pull request #650 from pi-hole/update/sqlite_3.30.0
Update SQLite from 3.29.0 to 3.30.0
2019-10-10 12:47:32 -04:00
DL6ER 5ab2a98c31 Don't finalize SQLite statement too early.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-10-10 17:30:14 +02:00
DL6ER bd60342ec3 Update SQLite from 3.29.0 to 3.30.0
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-10-10 17:06:06 +02:00
DL6ER 9acfddbdc9 Update comment.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-10-02 18:02:46 +02:00
DL6ER 9598f4244e Use network table as secondary source for client host names.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-10-02 17:47:36 +02:00
DL6ER 6f7b4ea82d Ensure to finalize statement before calling DELETE that might affect the running transaction. SQLite3 does not accept such a DELETE in a running statement.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-10-01 22:15:13 +02:00
DL6ER 9dd376b88a Harden network database upgrading procedure. We have at least one bug report that creating the unique index during the upgrade to database version 4 failed. We remove the addition of this unique index as it will anyway be dropped again a second later when upgrading to version 5. Meanwhile, we improve on the upgrading procedure to version 5 by implementing explicit conflict handling for duplicate ID<->IP and duplicate HWADDR entries.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-26 16:36:03 +02:00
DL6ER 0941db9f0d Merge branch 'development' into new/internal-blocking 2019-09-23 21:03:28 +02:00
DL6ER 12df978432 Do not try to bind to statements that might not be available when preparing the database failed.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-20 22:53:49 +02:00
DL6ER fe416709db Count DISTINCT domains when showing the size of gravity, blacklist, etc. Otherwise, we would show the domains once for each group so they might show up multiple times.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-19 16:14:07 +02:00
DL6ER 0b7d9c7a29 Do not import untagged domains for a tagged client.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-18 20:15:24 +02:00
DL6ER 3dde49da4f Ensure that untagged domains and regular expressions are used by clients that use group-based SELECT statements.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-11 09:15:32 +02:00
DL6ER 8e7b31713f Implement per-client regular expressions.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-11 09:14:21 +02:00
DL6ER c2c43a84e7 Check for availablility of prepared statement before trying to use it. This prevents us from preparing statements for clients that have been there within the past 24 hours but might have left the network meanwhile.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-09 13:10:04 +02:00
DL6ER 72bc239b8f Re-prepare per-client statements for the gravity database after gravityDB_close() has finalized them when FTL received SIGHUP.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-09 08:47:45 +02:00
DL6ER d303f5f6e8 Log if we are in DEBUG mode and prepare gravity client statements.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-09 08:38:40 +02:00
DL6ER 424c9be804 Changes due to most addition of the association table client_by_group.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-09 00:04:40 +02:00