Commit Graph

60 Commits

Author SHA1 Message Date
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
DL6ER deae66ba58 Optimize datastructures using bitfields and item re-arrangement (to minimize padding). This reduces the size of query, client, and regex records by 8 bytes per item. Note that this optimization was done on x86_64 and may not apply for other architectures (32bit architectures already used less padding).
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-01-17 13:06:16 +01:00
DL6ER a33c9d337e Implement support for displaying exact type instead of the catch-them-all category OTHER. The OTHER category is still used when it comes to computing statistics to ensure your chart's legend does not explode.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-01-03 22:10:09 +01:00
DL6ER 7459d8235b Rename memory.c -> syscalls.c
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-12-09 20:21:03 +01:00
DL6ER 4bfe4a4fde Do not warn about query status 12 and 13 on import (retried queries)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-11-30 19:27:01 +01:00
DL6ER 6f6ae518d2 Merge branch 'development' into new/super-clients
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-11-15 08:47:44 +01:00
DL6ER 7b0ab09b74 Make FTL upstream destination port-aware
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-11-13 00:16:55 +01:00
DL6ER 036031e0ec Open database for history-reading
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-09-28 23:26:36 +02:00
DL6ER b7fe809467 Reopening the FTL database may lead to rare race-collisions in SQLite3. We avoid them by keeping the database connection open all the time.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-09-27 23:35:44 +02:00
DL6ER 196fca38ff Merge branch 'development' into new/super-clients
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-09-21 23:28:57 +02:00
DL6ER 3bb0fe98be Fix subdirectory include paths. This is only to be explicit, the relative search finds them otherwise as well
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-09-03 20:46:01 +02:00
DL6ER 2d90c17767 Merge branch 'development' into new/super-clients
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-31 19:05:59 +02:00
DL6ER d55d5b14bb Explicitly case time_t to (long long) before printing to address the musl-decision to make time_t 64 bit on 32 bit machines
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-12 22:03:24 +02:00
DL6ER 69c1181085 Change concept of super-clients from MAC-based to index-based. We append a new column to the network table which can be used to assign super-clients to multiple devices. This can both cover automatic grouping (whenever MAC addresses are available) and also situations where this is not possible (when MAC addresses are not available, e.g., due to network layer separation). Real-time signal 3 causes FTL to re-import super-clients from the database without affecting anything else.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-12 19:34:56 +02:00
DL6ER b422beb82a Implement client-based Query Log filtering for super-clients and ensure we always count both the normal and the super-client when there is a new query / garbage collection
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-11 21:13:36 +02:00
DL6ER 3a4d8e2e0d Add ;querytype=AAAA option
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-10 23:43:02 +02:00
DL6ER 8ee044d130 Do not try to bind a value when we should actually read one. This glitch was harmless, however, it prevented regex ID from being loaded from the database.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-03 19:34:47 +02:00
DL6ER 5f4582e436 Merge pull request #832 from pi-hole/new/cname_inspection_logging
Add logging for CNAME inspection
2020-07-23 06:19:17 +02:00
DL6ER 42e9ccc489 Store + import ID of regex used for blocking in additional_info field
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-07-14 18:56:35 +02:00
DL6ER e661bd5389 Load domain causing the blocking in a CNAME inspection from the database during import. This ensures restarting FTL does not mean we lost this information.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-07-13 23:12:47 +02:00
DL6ER 08b00d2b05 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>
2020-07-13 21:18:44 +02:00
DL6ER ee578627a9 Remove privacy level 4. Systems currently running level 4 will automatically pick up the highest available level (which is now 3). Also tidy up enums into a dedicated file.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-07-08 23:48:05 +02:00
DL6ER abe0c5bbab Merge branch 'release/v5.0' into tweak/sqlite_debugging
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-03-29 21:07:46 +00:00
DL6ER 2244adedb8 Inform user if queries are being hold in memory for later saving (due to database being locked).
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-03-24 13:34:16 +01:00
DL6ER 80fbd889f9 Replace sqlite3_errmsg() by sqlite3_errstr() everywhere to ensure we always catch the right error.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-03-24 10:52:01 +01:00
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 2317c8998f Add all clients FTL knowns about to the network table. This requires a yet to be done modification to the web interface to hide the mock hardware addresses we generate for these devices.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-03-07 11:00:12 +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