Commit Graph

170 Commits

Author SHA1 Message Date
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 c9c7c27888 Add shared DNS cache for FTL. This cache is shared across forks and can be used by TCP and UDP clients avoiding any doubled amount of work.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-12-30 14:08:22 +00:00
DL6ER 45b5b0e0f6 Merge pull request #668 from pi-hole/fix/deep_CNAME_blocking_top_lists
Top lists fix for deeply blocked CNAME chains
2019-12-28 16:56:23 +01:00
DL6ER 9cc4e0d76f Merge pull request #670 from pi-hole/tweak/CNAME_inspection
Tweak CNAME whitelisting behavior
2019-12-28 16:50:59 +01:00
DL6ER b0f0e9ac68 Set query as whitelist permitted when the domain is already known to FTL.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-12-27 23:29:33 +00:00
DL6ER 8604804a19 Change ownership of all shared memory objects before switching user.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-12-27 22:42:15 +00:00
DL6ER a4f4a09a22 Implement a query-wide whitelisted property that can hold the to-be-permitted property during an entire CNAME inspection process.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-12-27 21:32:19 +00:00
DL6ER 36c491791d Explicitly store domains as being whitelisted in FTLs cache for using this information during possible later CNAME inspection. This avoids the necessity to check the whitelist filters multiple times.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-12-27 21:11:39 +00:00
DL6ER e15d9504ce If we find during a CNAME inspection that we want to block the entire chain, the originally queried domain itself was not counted as blocked (but as (permitted). Later in the chain, when we find that this is a bad guy, we short-circuit it. We need to correct the domain counter of the domain at the head of the chain, otherwise, the data for the top lists is misleading. For this, we go back the entire path and change the original request to blocked by increasing the blocked count of this domain by one. Fortunately, each CNAME path can easily be tracked back to the original head in FTL's data so we do not need to search it. This makes the change able to happen without causing any delay.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-12-21 11:10:43 +00:00
DL6ER bb9f25cb85 Merge pull request #664 from pi-hole/new/group_zero
Add group zero support
2019-12-18 22:36:46 +01:00
DL6ER 33940f2cf2 Add group zero support.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-12-12 17:24:12 +00:00
DL6ER 699f25d3ba Add CNAME_DEEP_INSPECT config option (default: true). It can be used to disable deep CNAME inspection. This might be beneficial for very low-end devices.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-12-12 12:43:04 +00:00
DL6ER c2755d895a Merge branch 'development' into new/internal-blocking
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-12-11 21:32:35 +00:00
DL6ER 841719e593 Merge branch 'development' of github.com:pi-hole/FTL into development 2019-12-11 21:31:04 +00:00
DL6ER 8d28bf4b55 Remove commented out generic vector implementation.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-12-11 21:19:41 +00:00
DL6ER 32d013b457 Add DEBUG_DNSMASQ_LINES debug flag
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-12-10 11:12:17 +00:00
DL6ER 57bcb4d7a5 Add DEBUG_DNSMASQ_LINES debug flag
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-12-10 10:55:59 +00:00
DL6ER 997d9f9963 Reload all lists (but do not clear the DNS cache itself) on receipt of real-time signal 0.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-12-02 15:37:31 +00:00
DL6ER 00c5f24ce7 Use sigaction() instead of signal() for portability reasons (recommended by man signal(2)).
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-12-02 15:26:29 +00:00
DL6ER f6dd4fac39 Implement real-time signals.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-12-02 15:26:18 +00:00
DL6ER 5e60930e70 Only initialize regex associations when dnsmasq is ready (otherwise, we're still in history reading mode)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-11-28 17:18:25 +01: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 2e97d2e6cd Implement CNAME path walking. If any domain along a returned CNAME path is found in any of Pi-hole's blocking lists (and is not whitelisted), the entire query will be answered with NODATA.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-11-25 12:42:54 +01:00
DL6ER 68aef3f0c4 Ensure shared memory is not already destroyed when calling gravityDB_close().
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-11-25 10:05:03 +01:00
DL6ER cc2991aebe Slightly reduce code duplication and add some more comments to _FTL_check_blocking()
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-11-25 09:39:14 +01:00
DL6ER 11159d1c40 Increase shared memory version due to the new (FTL-private) field clientstatus in domainsData.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-11-24 09:50:10 +01:00
DL6ER e0dc41c76b Also reset per-client domain data on receipt of SIGHUP. The user expects all cache to be cleared on this signal.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-11-23 23:00:18 +01:00
DL6ER f9be16e61b Reset per-client domain blocking cache at receipt of SIGUSR2. This is a convenient alternative to sending SIGHUP (which also clears the entire DNS cache).
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-11-23 22:55:57 +01:00
DL6ER 4269897b58 Fix: Only set domain as not-to-be-blocked when this is true.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-11-22 10:42:12 +01:00
DL6ER 7fc340c16a Add more debugging output.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-11-22 10:24:58 +01:00
DL6ER 25a403a7c4 Remove static instruction from query_blocked() as it is called from places that are unlikely to reach (however, still possible). Let the compiler decide itself whether and where it wants to inline this function.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-11-22 09:58:26 +01:00
DL6ER faac7005d1 Improve performance significantly. We store if (and if: why) a certain domain was blocked for any requesting client and can immediately reply similarly if the same client requests the same domain again. This reduces the O(N^3) problem (number of queries * number of domains * number of clients) to a O(N^2) problem (domains * clients). Note that this state of the code still lacks a possibility to reset when entries in the database have changed. For this, we still have to send either SIGHUP (drawback: clears the cache) or define a new signal for it.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-11-22 09:42:06 +01:00
DL6ER 7fd801dbc2 Add pure attribute to vGet() to signal that this function might be eliminated without consequences in static data flow analysis.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-11-21 12:18:53 +01:00
DL6ER 0baa56c3c3 Add a generic dynamic vector implementation. I tested my implementation using gdb and also against valgrind to ensure there are no memory leaks.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-11-21 12:12:26 +01:00
DL6ER bb8eef38ed Add more checks for the subroutines added in this branch.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-11-12 07:14:26 +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 e588138f72 Merge pull request #635 from pi-hole/fix/check_pointers
Check pointers before accessing content
2019-11-12 06:58:32 +01:00
Mark Drobnak dcafd2e21b Merge pull request #656 from pi-hole/tweak/getDatabaseHostname_malloc
Add malloc attribute to getDatabaseHostname()
2019-10-20 16:22:37 -04: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 1559ce6a0c Merge pull request #653 from pi-hole/tweak/remove-unused-var
Remove unused variable from counters struct
2019-10-20 15:52:11 -04: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 8b0da22ca4 Ensure print_flags() cannot overflow.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-10-15 20:04:15 +02:00
DL6ER 6c5171cc53 Remove unused variable from counters struct
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-10-14 11:18:03 +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
Mark Drobnak 39317c7466 Merge pull request #647 from pi-hole/fix/database_upgrade_DELETE_in_TRANSACTION
Restructure network table upgrade procedure
2019-10-10 12:45:48 -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