Commit Graph

89 Commits

Author SHA1 Message Date
DL6ER 608458edfd Only include sqlite3.h in those files that need it. This should improve the compiling time slightly
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-01-22 17:26:25 +01:00
DL6ER 9d0346a424 Ensure lastdbindex in properly set after reading in queries from the database
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-01-22 17:23:34 +01:00
DL6ER 2c41ae7b73 Offer fine grained debugging options through independentally configurable debug flags. The debugging output of FTL gre considerable over the last year and became overwhelming for users that are not used to it. With this addition, users will be able to switch on only what they want to see.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-01-16 09:14:35 +01:00
DL6ER 486e497d8a Review comments
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-01-07 02:17:22 +01:00
DL6ER d8fdf76ceb Store number of queries per client in the database
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-12-28 12:18:35 +01:00
DL6ER ac6ee9e1ef Add config option to disable ARP cache parsing
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-12-26 11:29:28 +01:00
DL6ER 3a8c87907a Initialize new devices with lastQuery property if available
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-12-26 11:14:25 +01:00
DL6ER 68a584ad8b Reduce code duplication
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-12-26 01:21:00 +01:00
DL6ER 95d3c02c5f Store lastQuery property for known clients
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-12-25 22:35:16 +01:00
DL6ER 82b43c332b Parse ARP cache after storing queries into long-term database(usen the dedicated database thread)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-12-25 17:56:44 +01:00
DL6ER c7bdf9bd60 Update if device uses Pi-hole and store host name if available
Print executed SQL statements when in debug mode

Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-12-25 13:45:34 +01:00
DL6ER 40fd4d317e Add / update rows in table network depending on what we see in the ARP cache
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-12-24 13:19:18 +01:00
DL6ER 36d1499804 Add network table. This will update the database to version 3. Furthermore, we make some database routines globally (add prototypes to routines.h) and mark some internal database variables as static. This commit also improves on the speed of the database routines as the main loop is changed to run from the last saved query to the most recent one instead of looping over all queries in memory. This ID is corrected when queries are removed in gc.c
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-12-23 12:51:03 +01:00
Mcat12 ff4d985f9d Merge branch 'new/shmem' into feature/shm-lock
# Conflicts:
#	database.c
#	request.c
2018-11-21 14:56:15 -05:00
DL6ER 85290bb73e Merge branch 'development' into new/shmem
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-11-21 20:44:37 +01:00
DL6ER 8de30790f8 Review comments
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-11-10 08:16:36 +01:00
DL6ER eeae592c58 Ensure regex validation is working as expected if privacylevel > 0. This required a certain rearrangement of how we handle domains and clients internally.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-11-09 19:02:06 +01:00
DL6ER f8ba1739b3 Remove unused variable queryID
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-10-25 21:33:55 +02:00
DL6ER 100d92bbd9 Set queryID to zero for queries imported from the database on startup
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-10-25 21:29:16 +02:00
DL6ER f2f3566980 Move resolution of client and upstream host names to a dedicated thread. Fixes #404
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-10-25 19:53:29 +02:00
Mcat12 d7b4ce8a5f Remove read lock and simplify lock names
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2018-10-11 15:59:52 -04:00
DL6ER 601722d441 Obtain ID before insertion transaction and store IDs only when a query has actually been saved instead of trying to do this in a post-processing step
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-10-11 06:10:18 +02:00
DL6ER 1279b93294 Store database ID in queries struct. This information will be availabe through shmem to the API to support transparent overlap with the SQlite3 database
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-10-07 20:50:21 +02:00
Mcat12 8c68aac456 Add shared memory lock
This replaces the previous mutex managed by threads.c. The lock is
stored in shared memory with the name "/FTL-lock", and any clients
connecting to the shared memory are expected to use the lock when
accessing memory.

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2018-10-05 01:18:40 -04:00
Mcat12 cd41aaeab4 Put overTime data into shared memory
The array of overTime structs is separate from the client data, because
the client data is dynamically sized. Each client has a separate shared
memory block named `/FTL-client-ID` where `ID` is the numerical ID of
the client. The client data is an array of ints, which is indexed using
the overTime time indexes.

Before, the code referenced the client data via
`overTime[timeIndex].clientdata[clientID]`
Now, the code references the data via
`overTimeClientData[clientID][timeIndex]`

The client data is updated whenever a new client or overTime slot is
added, so referencing the client data should always be valid.

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2018-09-19 13:00:50 -04:00
Mcat12 e1c8ccc975 Use negative query IDs for queries loaded from the database
This is necessary for all queries to have unique IDs. Previously,
all queries loaded from the database had an ID of zero.

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2018-09-18 11:40:44 -04:00
Mcat12 ae1bb5b71a Move counters to shared memory
This requires that it be accessed through a pointer, so most of the
changes are just changing `counters.` to `counters->`

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2018-09-03 14:25:16 -04:00
Mcat12 bbfe186dd8 Merge branch 'development' into new/shmem
# Conflicts:
#	api.c
#	dnsmasq_interface.c
2018-09-01 22:34:39 -04:00
DL6ER dfe27e7c3b Add PRIVACY_NOSTATS mode that skips all (!) analysis. We furthermore don't even try to import or save anything to the database.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-08-19 14:14:06 +02:00
DL6ER 79b2865bab Add new query type QUERY_EXTERNAL_BLOCKED triggered by an NXDOMAIN response with set AD bit (this is how Quad9 signals a blocked domain)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-08-15 23:45:27 +02:00
DL6ER 64a895d720 Allow all query types (not only A and AAAA) during database import
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-08-09 11:57:41 +02:00
DL6ER 96928c73ef Use strbuffer also for domains
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-08-01 19:04:02 +02:00
DL6ER b7da12b600 Use strbuffer also for client IPs and host names
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-08-01 18:37:48 +02:00
DL6ER 3e8849049e Store forward destination IP address and host name in contiguous string buffer
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-08-01 18:04:43 +02:00
DL6ER 9b5eb62263 Don't set regex status for domains read from database as we don't add them to the resolvers cache here (performance reasons)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-05-19 17:40:34 +02:00
DL6ER b6dd8ec47f Implement reading regex from file
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-05-19 17:21:56 +02:00
DL6ER db7dbda9da Use status == QUERY_WILDCARD to identify regex blocked queries
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-05-19 16:37:25 +02:00
DL6ER decef2e5fd Remove special support for old type of wildcard lists as dnsmasq config file
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-05-19 14:46:21 +02:00
DL6ER 24b98093e8 Merge branch 'development' into ftldns/remove_old_debug_options
Signed-off-by: DL6ER <dl6er@dl6er.de>

Conflicts:
	args.c
2018-05-12 13:38:36 +02:00
DL6ER 5d2ed0a5a6 Remove database debug callback
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-05-12 13:07:03 +02:00
DL6ER c606ad75ab Remove undocumented, old, and unused debug commands
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-05-10 19:24:02 +02:00
DL6ER f6e4ec4230 Add blocked domains counter for individual clients
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-05-10 14:22:58 +02:00
DL6ER c7453d5343 Call memory_check() only when needed (before creating a new domain/client record)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-04-29 11:05:20 +02:00
DL6ER 2e24b81557 Merge pull request #254 from pi-hole/FTLDNS-IGNORE_LOCALHOST
Add IGNORE_LOCALHOST config option
2018-04-14 11:44:51 +02:00
DL6ER efbe8025d0 Implement IGNORE_LOCALHOST config option
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-04-11 18:50:36 +02:00
DL6ER e2d0529993 Implement name resolving power back for FTLDNS. This re-implements lots of already extensively tested code that was present in pre-FTLDNS for over a year. This implementation is only slightly different by ensuring that name resolution is done in a specific non-blocking way.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-04-11 18:20:06 +02:00
DL6ER 9f940d82e0 Reduce memory footprint by removing unnecessry TTL value
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-04-06 23:52:07 +02:00
DL6ER 003371fcd3 Don't import AAAA queries from database if config flag AAAA_QUERY_ANALYSIS is set to No
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-04-05 19:41:02 +02:00
DL6ER a686cb2792 Ensure that we do not import queries logged in the future
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-03-08 22:08:01 +01:00
DL6ER e8c1df643d Merge branch 'development' into FTLDNS
Signed-off-by: DL6ER <dl6er@dl6er.de>

Conflicts:
	database.c
2018-03-02 22:48:13 +01:00