Commit Graph

45 Commits

Author SHA1 Message Date
DL6ER c02dfddebc Add quiet regex test mode for inclusion in pihole -q
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-10 23:27:04 +02:00
DL6ER dde020ea54 Modify regex-test mode for better batch-processing capabilities
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-10 23:27:04 +02:00
DL6ER d51224cb57 Mark get_regex_from_rowid as pure.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-10 23:25:49 +02:00
DL6ER ce84f6d56a Adjust empty lines
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-10 23:25:49 +02:00
DL6ER 094b1ed828 Use info box for step reporting
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-10 23:25:49 +02:00
DL6ER 89960e3698 Make regex-text output more user-friendly
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-10 23:25:49 +02:00
DL6ER c4689c158f Reduce overall costs by not always calling the approximate matching algorithm.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-10 23:25:49 +02:00
DL6ER 22c8ccefd5 Allow test-regex mode to be started without log ans shared memory (alleviates write permission issues when running pihole-FTL as a different user)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-10 23:24:30 +02:00
DL6ER 87b2b42e44 Add regex-test mode
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-10 23:24:30 +02:00
DL6ER 2144857d93 Improve regex engine. This adds new features such as in-code comments, approximate matching (fuzzy matching)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-10 23:19:04 +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 5f9a590e00 Be explicit about if we count or query the number of domains. This simplifes the logic and makes it more readable.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-07-06 16:36:26 +02:00
DL6ER 3e82970c27 Create "message" table and log regex errors in there.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-06 21:23:50 +02:00
DL6ER bcb4789538 Make regex matching case-insensitive by default and remove config option to control this.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-04-20 09:40:29 +02:00
DL6ER 06b5f3ca6f Merge branch 'release/v5.0' into new/CNAME_inspection_details
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-02-11 10:17:44 +01:00
DL6ER 0d9b301733 Ensure we group domains read from the views by their ID to avoid importing identical regex filters multiple times.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-02-06 17:45:42 +01:00
DL6ER 66f061265b Special debug logging.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-02-05 23:41:40 +01:00
DL6ER 5c08c56d35 Store ID of matching blacklist regex if this is the blocking reason.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-02-04 08:34:01 +01:00
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 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 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 3a11628c3b Display rowid in regex debugging mode as this is more useful when trying to find the respective line in the database.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-19 15:56:37 +02:00
DL6ER 0b7d9c7a29 Do not import untagged domains for a tagged client.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-18 20:15:24 +02:00
DL6ER a6c9fdbdc1 Ensure regex compatibility with MUSL
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-11 10:25:22 +02:00
DL6ER 395cc371ff Add missing evaluation of groups for the regex whitelist
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-11 09:59:21 +02:00
DL6ER 8e7b31713f Implement per-client regular expressions.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-11 09:14:21 +02:00
DL6ER 8c3ff39510 Implement client-specific gravity, white- and blacklist database statements.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-07 11:48:32 +02:00
DL6ER f3e8d23baf Merge branch 'development' into new/whitelist-regex-support
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-08-17 15:01:32 +02:00
DL6ER efbdff9ee6 Add new config flag REGEX_IGNORECASE that can be enabled to make FTL's regex case insensitive. It defaults to false (legacy behavior).
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-16 22:52:40 +02:00
DL6ER 369a056379 Simplify log_regex_error().
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-16 22:32:04 +02:00
DL6ER 8c6736a55f Fix minor typo.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-16 18:49:51 +02:00
DL6ER fe23292434 regexec() can only return zero or NOMATCH according to its man page. This allows us to remove the error handler as it could never be executed.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-16 12:31:05 +02:00
DL6ER e3fc3a78fb Clarify that the shown number is the error code.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-16 12:28:39 +02:00
DL6ER dd8af36613 Add debugging output for gravity table if requested via DEBUG_DATABASE option. We might want to separate this into DEBUG_GRAVITY_DATABASE in the future.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-16 12:25:42 +02:00
DL6ER eaf3d23744 Print failed regex line instead of its ID when reporting an error.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-16 12:16:37 +02:00
DL6ER caf18e1370 Improve difference between between REGEX and TABLE constants by renaming the latter to always end in _TABLE. Also remove code duplication by using a lookup array for the table names instead of using multiple select labels.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-16 11:55:34 +02:00
DL6ER e14322b5db Declare free_regex() static as we do not need to make it globally available. Remove log_regex() as it can easily be inlined.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-09 18:03:56 +02:00
DL6ER cb293058a2 Declare free_regex() and log_regex() static as we do not need to make them globally available.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-09 18:00:35 +02:00
DL6ER 8294f7527d Rename init_regex() to compile_regex() as this describes better what this routine is doing.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-09 17:56:05 +02:00
DL6ER fb46dcf2a7 Be more specific about how many of which kind of regex filters we compiled.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-08 21:45:49 +02:00
DL6ER b0838aaffa Temporarily disable regex debugging as it generated hundreds of thousands of messages during gravity import.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-07 22:59:51 +02:00
DL6ER fdff462fa4 Add support for regex filters for whitelisting.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-07 22:46:28 +02:00
DL6ER 5c75fc3e67 Move even more definitions from FTL.h into the respective headers.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-07 10:09:18 +02:00
DL6ER e365364f72 Move all source files into new subdirectory "src". Put compiled objects into new subdirectory "build".
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-02 00:18:56 +02:00