Commit Graph

238 Commits

Author SHA1 Message Date
DL6ER 44d57e5b37 Add checking of return status of sqlite3_open_v2 to ensure we are not trying to use the database when it failed to open
Signed-off-by: DL6ER <dl6er@dl6er.de>
2024-06-06 16:17:01 +02:00
DL6ER dc204a41b0 Use v2.6 CI containers and nightly for the devcontainer
Signed-off-by: DL6ER <dl6er@dl6er.de>
2024-05-25 09:54:37 +02:00
DL6ER 7a919cbf59 Allow narrowing down the (ad)list type using the (optional) query parameter ?type={allow,block}
Signed-off-by: DL6ER <dl6er@dl6er.de>
2024-02-13 08:42:08 +01:00
Dominik 276ba4210f Merge pull request #1841 from pi-hole/tweak/list_id
Make adlist ID available, rename queries.regex_id -> queries.list_id
2024-02-09 20:52:35 +01:00
DL6ER e5e9d11211 Fix DELETE API endpoints. They should return 204 when something was deleted and 404 is nothing was found at this resource
Signed-off-by: DL6ER <dl6er@dl6er.de>
2024-01-07 09:04:20 +01:00
DL6ER 83dfd6250c Merge branch 'development-v6' into tweak/list_id
Signed-off-by: DL6ER <dl6er@dl6er.de>
2024-01-01 20:43:44 +01:00
DL6ER 3d41513121 Use IN where = was used but a multi-value result may occur
Signed-off-by: DL6ER <dl6er@dl6er.de>
2024-01-01 08:59:33 +01:00
DL6ER e022600fef Recheck statements in forks to avoid edge-case collisions possibly leading to a crash in heavy TCP worker activity
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-12-27 19:08:36 +01:00
DL6ER d92e1a056c Do not check errors on ROLLBACK TRANSACTION when gravityDB_delFromTable() fails. We remove this to avoid overwriting the initial cause of the error.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-12-25 22:19:03 +01:00
DL6ER 7c29048009 Translate anti-/gravity list IDs to negative numbers so they can be distinguish from domains rather easily. Users are free to foil this method when they force negative IDs into the database but they will never be automatically created
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-12-25 06:10:01 +01:00
DL6ER 1bc8e7fc06 Rename query_storage.regex_id to query_storage.list_id as it is already now used to also store exact matching domainlist entries by their ID. This commit further extends this to also store the (first) matching anti-/gravity list (if available)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-12-25 04:57:05 +01:00
Dominik 1a0921cd48 Merge pull request #1810 from pi-hole/new/batchDelete
Implement special POST :batchDelete callbacks
2023-12-15 20:19:09 +01:00
DL6ER 34cfc9c465 Remove undocumented audit feature
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-12-08 07:53:49 +01:00
DL6ER 835fcde327 Condition 'hwaddr!=NULL' is always true and reduce amount of allocated memory for synthesized MAC addresses from 324 to 18 bytes
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-12-08 07:53:49 +01:00
DL6ER 0ef89ab3eb Implement special POST :batchDelete callbacks for /api/groups, /api/domains/, /api/clients, and /api/lists
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-12-06 23:27:20 +01:00
DL6ER b2884505ab Merge branch 'development-v6' into new/recycle 2023-11-26 10:41:42 +01:00
DL6ER d6f30b3931 Install safe-guards for string-related functions to not crash when accidentially supplied with a NULL pointer
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-11-20 22:38:33 +01:00
DL6ER ad5d078193 The group table's column is called "description" but we expose it in the API as "comment". Adjust internally used SQL to translate between them (this was already implemented and working for comment editing)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-11-19 07:46:58 +01:00
DL6ER ec064d9c6e Use correct type when manipulating domainlist entries
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-11-10 20:47:33 +01:00
DL6ER c450d488a4 Fix domain modification. The UNIQUE key in the domainlist table is the combination of domain+type, not domain alone so you can add the same domain, e.g. once as allowed and once as denied entries and assign them to different clients using appropriate groups
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-11-05 20:59:55 +02:00
DL6ER 9345841b10 Fix error message shown when gravityDB_addToTable() fails
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-11-05 20:58:19 +02:00
DL6ER 91b0c23f84 Merge branch 'development-v6' into new/recycle 2023-11-04 08:05:03 +01:00
DL6ER 87272c2178 Use UPSERT instead of special REPLACE INTO statements to update existing group, adlist, domainlist, and client rows in the gravity database
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-10-23 22:35:14 +02:00
DL6ER 2aff05c78a Reuse existing shared clients, domains, and cache memory slots which are not referenced by any active query within the past 24 hours. Furthermore, always scan the shared strings and reuse them before allocating new memory with the same content
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-10-23 18:13:12 +02:00
DL6ER 71c0d66338 Remove semicolon actually preventing the correct filtering on regex IDs
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-10-15 11:31:25 +02:00
DL6ER 71f384f999 Fix domain type and kind not being added for certain /api/domains calls
This is a regression of https://github.com/pi-hole/FTL/pull/1649

Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-10-12 18:12:27 +02:00
DL6ER 88e7b1e5dc Add ABP-support for /api/search and add new optional debug parameter
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-10-07 21:52:39 +02:00
DL6ER 590c1214a9 Optimize ABP comparator generation
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-09-29 18:42:50 +02:00
DL6ER 667a98230f Use @@||xyz^ instead of ||xyz^ for antigravity list entries
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-09-26 22:46:20 +02:00
DL6ER 4abc11afb3 Satisfy foreign key constraints when removing subscribed allowlists by deleting related domains in antigravity
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-09-15 21:39:04 +02:00
DL6ER 444fd4c5c9 Ensure subscribed list type is (re)stored to/from database table
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-09-15 21:39:04 +02:00
DL6ER f8b8e63044 Add antigravity (subscribed allowlists with wildcard support)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-09-15 21:39:04 +02:00
DL6ER 2dbfc2b481 Fix SQL used to update existing adlists via the API
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-07-08 13:26:30 +02:00
DL6ER 9f808b94ad Pass new abp_entries number to API
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-06-15 10:00:43 +02:00
Christian König 62cfc25b95 Fix spelling in v6
Signed-off-by: Christian König <ckoenig@posteo.de>
2023-05-30 22:42:13 +02:00
DL6ER 0564d7d385 Preserve gravity-specific quantities when updating lists via the API
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-05-07 13:14:16 +02:00
DL6ER d4f30e4f3d Send more gravity-specific quantities in /search/{domain}
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-05-07 13:10:24 +02:00
DL6ER 7f0bd7481e Ensure both type and enabled are returned when requesting domains through the API
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-05-06 20:08:07 +02:00
DL6ER 7281da34b4 Add /api/clients/_suggestions
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-05-06 07:31:21 +02:00
DL6ER 44c3fe4ef4 Merge remote-tracking branch 'origin/development' into new/http
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-03-13 10:30:39 +01:00
DL6ER da118e87ce Remove last traces of temporarily added benchmarking tools. Also remove the hint about ABP domains, this can easily be checked in gravity
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-03-05 13:56:55 +01:00
DL6ER 06f0e0340e Remove debugging timing output
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-02-26 16:52:23 +01:00
DL6ER ae9b291082 Set abp_domains = 1 during the CI tests.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-02-26 07:19:48 +01:00
DL6ER ab2f652e22 Use property "abp_domains" from info table to decide whether ABP blocking is to be used or not. Also log when FTL enabled ABP-style blocking
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-02-25 22:29:17 +01:00
DL6ER ec82cd3dd4 Add timing for ABP style detection
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-02-25 18:37:40 +01:00
Dan Schaper 6f8ba76077 Update src/database/gravity-db.c
Spespellingllling

Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>
2023-02-15 14:01:37 -08:00
Christian König d9c753be27 Fix spellcheck to get things deployed
Signed-off-by: Christian König <ckoenig@posteo.de>
2023-02-15 21:55:47 +01:00
DL6ER 80b5fa008c Fix handling of rare (but possible) gravity database issues such as "list not available"
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-02-15 21:27:12 +01:00
DL6ER 75cd6913ee Do not use a new option but instead automatically detect if ABP-style domains are present in the database. This ensures that this addition comes at no extra costs to any installs using pure HOSTS-style adlists.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-02-15 21:19:31 +01:00
DL6ER 8794b1684d Add ABP format blocking support for gravity. Note that the option needs to be switched on by setting GRAVITY_ABP_STYLE=true in pihole-FTL.conf to avoid running this computationally expensive task on the vast majority of user databases only fed from properly formatted HOSTS lists. Gravity can enable the setting when it detects ABP format automatically.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2023-02-15 19:48:19 +01:00