Commit Graph
92 Commits
Author SHA1 Message Date
DL6ER 3f1be06814 Fix logic for status code parsing
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-12-09 16:43:43 +01:00
DL6ER 983544e6d3 Fix incorrect DNSSEC-related warning during history import
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-12-03 12:43:20 +01:00
DL6ER 7ecd358f96 Allow FTL to analyze stale cache replies. They are assigned to a new query type (17)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-11-09 20:09:48 +01:00
DL6ER 1ccfd9a081 Ensure the API does not try to create DNS cache records for queries that don't have one
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-08-20 15:27:38 +02:00
DL6ER 15942b17ce Store domainlist IDs for blocked/permitted queries
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-08-19 19:44:11 +02:00
DL6ER 613014e81a Merge branch 'development' into new/query_special_domain
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-04-24 09:26:46 +02:00
DL6ER 7acd0f31e4 Add QUERY_SPECIAL_DOMAIN as new query status
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-04-24 09:10:38 +02:00
Adam Warner 671a438c4d Fix some spellings, ignore others
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
2022-04-22 18:26:31 +01:00
DL6ER 8734b60a53 Ensure we subtract from the old reply counter when reply type changes
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-03-26 13:24:08 +01:00
DL6ER 213b7eb7f4 Adjust query type counters when importing from the database
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-03-18 13:05:19 +01:00
DL6ER 2c91e487fd Store NULL in the REPLY_TIME column when the reply time is not available
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-02-05 10:11:20 +01:00
DL6ER 9a257a9bb1 Set response_calculated to true when imported reply_time is not 0.0
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-02-01 21:11:55 +01:00
DL6ER 4994e59282 Add new reply, reply_time, and dnssec columns to the query_storage table and queries view
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-01-19 19:38:44 +01:00
DL6ER feac92edff Use query_storage instead of queries when removing old queries and when couting them
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-01-09 22:18:56 +01:00
DL6ER 4516ee22b0 Do not use AUTOINCREMENT as it will add gaps between the IDs even if nothing is actually INSERTed as we chose the OR IGNORE path.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-12-16 22:30:30 +01:00
DL6ER f350ce5729 Create and use link table for additional_info column
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-12-16 22:10:17 +01:00
DL6ER d134a4943a Use the SQLITE_PREPARE_PERSISTENT flag is a hint to the query planner that the prepared statement will be retained for a long time and probably reused many times. Without this flag, SQLite3 assumes that the prepared statement will be used just once or at most a few times and then destroyed relatively soon. The current implementation acts on this hint by avoiding the use of [lookaside memory] so as not to deplete the limited store of lookaside memory. Also, update the tests for the expected database schema after renaming the table and adding the new view.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-12-16 12:28:19 +01:00
DL6ER beae1b3bf5 Use table name query_storage
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-12-16 11:52:08 +01:00
DL6ER 1cd6f04fb6 Utilize new queries_storage and link-tables for the queries table
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-12-16 10:58:12 +01:00
DL6ER 6c82a9c4f8 Optimize queries table by separating domain, client, and forward strings into a linking table and referencing them by an ID. This also allows storing (IP,hostname) pair for clients.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-12-16 10:58:01 +01:00
DL6ER 028989bcae Reduce code duplication by using labels + ensure we do not run dbclose() multiple times on database issues (e.g., when database is locked)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-11-14 13:01:39 +01:00
DL6ER c5e05a5880 Improve response time calculation. We are interested in the time it takes until we have everything we need to serve content. Typically, this is the first reply (either from cache or from upstream), but sometimes it is a later reply (e.g. when content can only partially be served from cache and needs extra forwarding).
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-10-14 20:57:24 +02:00
DL6ER ac0346b9e2 Improvements based on static-analysis of source code
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-09-23 20:24:57 +02:00
DL6ER 5f4d0395a7 Abort database routines early if database is known to be broken due to database file corruption.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-09-09 13:46:01 +02:00
DL6ER 64f230f551 Update DB counters still within the running TRANSACTION to reduce disk I/O
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-09-03 13:11:14 +02:00
DL6ER 127860e195 Merge pull request #1156 from pi-hole/tweak/blocking_while_busy
Customizable locking while database is busy
2021-08-23 20:19:36 +02:00
DL6ER f73c9d2907 Remove redundant upstream->count
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-08-22 11:58:51 +02:00
DL6ER d57311e56f Allow users to configure how FTL reacts to queries when the gravity database is not available
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-08-18 11:41:16 +02:00
DL6ER 79e853c80a Log how many queries have been saved in the final query storing
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-08-10 14:17:58 +02:00
DL6ER c47fc3b357 Set extended DNS error to UNSET (-1) when importing from the database
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-08-08 20:50:04 +02:00
DL6ER f0f6b1de6f Further reduce memory footprint of FTL by about 12%. We don't store the char pointer of the extended DNS errors because we can get this at any time.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-07-02 18:02:21 +02:00
DL6ER 979951c588 Reduce memory footprint of FTL by 11%. We don't store the rowid of a query in memory because we don't really need that.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-07-02 17:26:41 +02:00
DL6ER 4f8cbe29f7 Store real over-time counts of forwarded queries. So far, we counted only the first server a query was sent to.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-06-25 13:10:39 +02:00
DL6ER 69b4f1f775 Do not relock during database loading
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-05-12 11:54:03 +02:00
DL6ER dfb09a35ce Fix database update to version 7 reporting error when there is none. This is not a critical bug as the issue resolves itself on the next start of FTL.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-04-15 10:23:11 +02:00
DL6ER a5fbaa2ecc Queries read from the database need to be counted as unknown before restoring the query status
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-04-07 17:07:51 +02:00
DL6ER de7c2919c9 Simplify status and reply type handling in FTL
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-04-06 20:01:47 +02:00
DL6ER 0795cf6209 Open individual database connections where we need them. Do not use global pointers anywhere. This may mean we have more than one connection open at the sae time. SQLite3 will take care of thread-safety.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-03-20 20:21:09 +00:00
DL6ER 2485ac92e7 Merge pull request #1072 from pi-hole/tweak/shmem_resize_in_lock
Resize shared memory only when locking
2021-03-02 06:00:10 +01:00
DL6ER 3fd9b8d08a Merge pull request #1061 from pi-hole/fix/retired_dnssec_has_no_upstream
Fix incorrect "FATAL: Trying to access upstream ID -1" warning in the logs
2021-02-28 16:53:54 +01:00
DL6ER 67801b8383 Resize shared memory only when locking. This ensures all shm pointers are invariant inside locks.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-02-21 10:00:16 +01:00
DL6ER cf9018501d Do not detach threads we want to be able to cancel and add logfile log to shared memory locks. Other forks may want to log as well.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-02-17 20:53:34 +01:00
DL6ER d1f764bc30 Retried queries due to missing DNSSEC valdiation have no upstream server (the related DNSSEC queries where retried, not this one). Hence, we shouldn't update the counts of any upstream here. This silences an incorrect "FATAL: Trying to access upstream ID -1" warning in the logs.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-02-16 22:59:24 +01:00
DL6ER 991f128298 Merge pull request #1052 from pi-hole/new/rate_limiting
Add per-client rate-limiting
2021-02-14 15:41:04 +01:00
DL6ER c0d0f0fdca Increment forward counters when immporting QUERY_RETRIED or QUERY_RETRIED_DNSSEC fromthe database
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-02-13 18:48:45 +01:00
DL6ER dd773b0d2f Fix queries sent upstream being counted incorrectly when modified later on (blocked externally, blocked during CNAME inspection). This also applies to queries loaded from the database.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-02-13 16:57:13 +01:00
DL6ER bf52156ae0 Add per-client rate-limiting. The default limit is 1000 queries in 60 seconds.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-02-03 16:55:07 +01:00
DL6ER 6ab9b70021 Fixes incorrect "Found unknown status 14 in long term database" warning in the logs. We change the code to use a enum-based struct so we cannot forget to update this in the future when adding further query status types.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-01-31 11:18:34 +01:00
DL6ER 471fbf7b62 Use blocked property in API code. Make query->upstreamID = -1 the new default to differentiate easily what was forwarded (ID will be >= 0) and what not (ID == -1). Store the upstream server also for other query types that were forwarded (like queries blocked during CNAME inspection).
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-01-18 15:19:50 +01:00
DL6ER c227fc1598 Store blocked property in query flags.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-01-18 15:04:59 +01:00