Commit Graph

52 Commits

Author SHA1 Message Date
DL6ER c4b5b80570 Print size of database / count of removed rows only in debug mode
Signed-off-by: DL6ER <dl6er@dl6er.de>
2024-10-10 19:56:52 +02:00
DL6ER a04303ae23 Ensure NTP servers are properly terminated when FTL is shutting down and remove obsolete variable thread_running[] (it is only ever set but never read)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2024-07-01 16:22:18 +02:00
DL6ER 90ba90a0c7 Pre-define thread names so they can always be shown during shutdown, even if a thread was never started, remove unused CONF_READER thread slot
Signed-off-by: DL6ER <dl6er@dl6er.de>
2024-06-11 04:20:04 +02:00
DL6ER 2269caeb9a Make NTP sync thread cancelable
Signed-off-by: DL6ER <dl6er@dl6er.de>
2024-06-04 23:56:11 +02:00
DL6ER 74eba5f605 Remove config option database.DBexport. Its implementation was broken by design as its value was always overwritten by the condition (database.maxDBdays > 0). Replace it with exactly this condition and document the behavior in the config file
Signed-off-by: DL6ER <dl6er@dl6er.de>
2024-03-16 08:34:19 +01:00
DL6ER d77547d4d7 Ensure database analysis / MAC vendor update is running also when FTL is frequently restarted (e.g. during development or for users joining a special branch, e.g. during extended bug fixing or a beta release period)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2024-01-06 09:13:29 +01:00
DL6ER da7c3a7735 Run ANALYZE instead of PRAMGA optimize after some discussion with the SQlite3 developers. Also ensure notices and mere messages are not always logged as errors in FTL's log. Furhtermore, reduce the frequency of running ANALYZE from once per day to once per week.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2024-01-04 23:30:14 +01:00
DL6ER 975c46817b Optimize database on close (gravity) or frequently (queries)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2024-01-01 08:41:37 +01:00
DL6ER 44e7007378 Fix warnings shown when compiling with musl-gcc for 32bit targets
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-05-31 02:01:15 +02:00
DL6ER 7281da34b4 Add /api/clients/_suggestions
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-05-06 07:31:21 +02:00
DL6ER b3ef031a22 Various memory improvements to (a) avoid crash during the final cleanup (don't allow reusing of pointer to memory that may already have been munmapped) , and (b) ensure we have release all memory after exporting to the on-disk database (finalize all prepared statements in queries_to_database())
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-04-18 21:13:48 +02:00
DL6ER fba171f151 Delete only up to 1% of the queries in the database in one go to avoid long blocking times with many queries to be deleted.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-03-13 11:41:14 +01:00
DL6ER d0e3500c4e Even when database.network.parseARPcache is set to false, FTL should be cleaning the network table, adding in clients from its own knowledge (those that sent queries), and add local interfaces
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-03-13 11:10:40 +01:00
DL6ER 9833fe1af0 Reload gravity database when 'updated' property in table 'info' has changed
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-02-05 16:44:14 +01:00
DL6ER 48fc06d46b Add POST /api/teleporter to upload and install backed up configuration
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-01-25 21:51:12 +01:00
DL6ER f199ac2f08 Automatically migrate the API password hash and the lists of clients and domains to be excluded from setupVars.conf
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-01-08 21:21:38 +01:00
DL6ER e145d20d28 Rewrite the entire config-related code to allow for changing data without having to restart. Hereby, we greatly reduce code duplication in the TOML routines so we won't have to touch tme in the future when adding additional options.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-01-07 18:06:41 +01:00
DL6ER 3389b1f0c2 Add /api/ftl/config which can be used to retrieve the entire configuration of FTL. This endpoint only supports GET so far, however, we will add POST in the future so that configuration values can be changed through the API
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-01-01 18:19:36 +01:00
DL6ER 848613488b Re-read blocking mode from pihole-FTL.toml on receipt of SIGHUP
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-07-17 13:28:22 +02:00
DL6ER fd12962f60 Lock shared memory before storing queries to database
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-07-17 12:34:24 +02:00
DL6ER 8437519c24 Remove newdb and directly store in memdb to avoid database complexity and unnecessary in-memory data duplication
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-06-28 21:10:05 +02:00
DL6ER 26ccee3f4c Merge branch 'development' into new/http
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-06-29 11:12:59 +02:00
DL6ER 7f7dc2e9fa Reload blocking mode independently of incoming queries
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-03-01 04:27:40 +01:00
DL6ER 118e3ee280 Open database only if we are going to perform actions
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-01-15 15:39:05 +01:00
DL6ER c0570c51c2 Merge branch 'development' into new/http
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-11-02 09:53:13 +01: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 6e1cdaec85 Only open database when really necessary. This may reduce disk activity slightly and save a bit of CPU time.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-09-03 12:52:30 +02:00
DL6ER 69e43735c9 Tests: Cannot change niceness of pihole-FTL on CircleCI
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-06-10 12:35:49 +02:00
DL6ER 55bf825a81 Implement TOML config file reader/writer and a converter of the pre-v6.0 config file format.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-06-10 12:11:25 +02:00
DL6ER d057c1e9fc Use specific log routines in database/database-thread.c
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-05-27 12:27:15 +02:00
DL6ER 45faefa786 Merge branch 'development' into new/http
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-04-26 14:09:50 +02:00
DL6ER f72962c1f6 Give threads a bit more time to reach a point where cancellation is safe. We cannot give them too much time because, otherwise, the proces trying to TERMinate FTL may decide to KILL it instead. We should avoid this to be able to properly cleanup.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-04-18 11:09:52 +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 0fa1def3bb Add a second in-memory database to ensure non-blocking operation at all times
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-02-28 11:51:41 +01:00
DL6ER f78b15f131 Add in-memory database for queries
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-02-26 18:26:07 +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 ca36f2de8d Add MAXDBDAYS=-1 to disable auto-cleaning and ensure overflow cannot happen (we just enforce the maximum in this case)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-01-18 19:41:02 +01:00
DL6ER 9751ae9efc Do not try to resolve IPs for records without hostnames in the network_addresses table.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-12-01 14:09:50 +01:00
DL6ER 056a70c931 Clarify that disabling the database only disables storing queries in the database. We still use the database for storing messages (such as regex syntax warnings) and alias-clients.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-11-25 19:53:39 +01:00
DL6ER 99a07ba57a Rename super-clients ---> alias-clients
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-11-15 19:09:48 +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 5341aefcae Move call to resolveNetworkTableNames() from resolver into database thread
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-10-19 08:32:10 +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 489b6f08f5 Merge branch 'development' into new/super-clients
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-09-27 22:04:59 +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 2ee26e0811 Reset actions after the threads picked up the new real-time signals
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-09-21 23:06:25 +02:00
DL6ER 46ac93353e Add explicit event queue to avoid possible race collisions when many signals arrive at the same time (or very very close to each other)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-09-03 20:45:59 +02:00
DL6ER 70bc176770 Ensure we cannot end up in a self-locking state when opening the database.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-12 20:05:54 +02:00
DL6ER 9f16b901dc Move signal handling into a thread to avoid possible lock race-collisions
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-12 19:34:58 +02:00
DL6ER 73473ac464 Update MAC vendor strings once a month (the MAC vendor database is not updated very often)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-06-24 20:44:04 +02:00