Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v5.22 #1542

Merged
merged 33 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6b2c02f
Merge pull request #1530 from pi-hole/master
DL6ER Feb 11, 2023
8794b16
Add ABP format blocking support for gravity. Note that the option nee…
DL6ER Feb 14, 2023
75cd691
Do not use a new option but instead automatically detect if ABP-style…
DL6ER Feb 15, 2023
80b5fa0
Fix handling of rare (but possible) gravity database issues such as "…
DL6ER Feb 15, 2023
d9c753b
Fix spellcheck to get things deployed
yubiuser Feb 15, 2023
6f8ba76
Update src/database/gravity-db.c
dschaper Feb 15, 2023
ec82cd3
Add timing for ABP style detection
DL6ER Feb 25, 2023
ab2f652
Use property "abp_domains" from info table to decide whether ABP bloc…
DL6ER Feb 25, 2023
ae9b291
Set abp_domains = 1 during the CI tests.
DL6ER Feb 26, 2023
06f0e03
Remove debugging timing output
DL6ER Feb 26, 2023
da118e8
Remove last traces of temporarily added benchmarking tools. Also remo…
DL6ER Mar 5, 2023
1fe7bb6
Update embedded SQLite3 engine to version 3.41.1
DL6ER Mar 11, 2023
62ebd05
Apply Pi-hole SQLite3 patches
DL6ER Mar 11, 2023
5a15f9b
Merge pull request #1537 from pi-hole/update/sqlite_3.41.1
DL6ER Mar 11, 2023
b87ef11
Merge pull request #1532 from pi-hole/new/adb_style_blocking
DL6ER Mar 11, 2023
f4cd2b4
Put version.ftl also behind new no-ident config option
DL6ER Mar 15, 2023
a9bede4
Merge pull request #1539 from pi-hole/tweak/no-ident
DL6ER Mar 15, 2023
e343086
Avoid undefined behaviour with the ctype(3) functions.
Feb 25, 2023
d7883c5
Fix --rev-server option. It was broken in 1db9943c6879c160a5fbef885d5…
DL6ER Mar 3, 2023
4f2fd40
Fix possible SEGV when no servers defined.
simonkelley Mar 6, 2023
e5c5a34
Set the default maximum DNS UDP packet size to 1232.
simonkelley Mar 7, 2023
16b711d
Generalise cached NXDOMAIN replies.
simonkelley Mar 7, 2023
e57b84b
Allow configuring filter-A/AAAA via dbus.
craftyguy Mar 8, 2023
8d13041
Fix DHCPv6 "use multicast" response which previously failed to set th…
simonkelley Mar 15, 2023
cf20043
Remove limitation on --dynamic-host.
simonkelley Mar 16, 2023
e08f118
Add .codespellignore file to fix spell-checker action
DL6ER Mar 19, 2023
017e086
Add RISC-V 64-bit support and builds
MichaIng Mar 5, 2023
5f91e61
Merge pull request #1541 from pi-hole/fix/spell-checker
DL6ER Mar 20, 2023
d35edd4
Merge pull request #1536 from MichaIng/development
DL6ER Mar 20, 2023
fe0339a
Update dnsmasq version to pi-hole-v2.89-9461807
DL6ER Mar 22, 2023
ddd56d7
Bump actions/checkout from 3.3.0 to 3.4.0
dependabot[bot] Mar 22, 2023
09faadb
Merge pull request #1540 from pi-hole/dependabot-github_actions-devel…
PromoFaux Mar 22, 2023
e408bd9
Merge pull request #1543 from pi-hole/update/dnsmasq
PromoFaux Mar 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .codespellignore

This file was deleted.

4 changes: 4 additions & 0 deletions .github/.codespellignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ssudo
tre
ede
nd
10 changes: 6 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
steps:
-
name: Checkout code
uses: actions/checkout@v3.3.0
uses: actions/checkout@v3.4.0
-
name: "Calculate required variables"
id: variables
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:

needs: smoke-tests

container: ghcr.io/pi-hole/ftl-build:v1.23-${{ matrix.arch }}
container: ghcr.io/pi-hole/ftl-build:v1.26-${{ matrix.arch }}

strategy:
fail-fast: false
Expand Down Expand Up @@ -81,14 +81,16 @@ jobs:
bin_name: pihole-FTL-armv8-linux-gnueabihf
- arch: aarch64
bin_name: pihole-FTL-aarch64-linux-gnu
- arch: riscv64
bin_name: pihole-FTL-riscv64-linux-gnu

env:
CI_ARCH: ${{ matrix.arch }}${{ matrix.arch_extra }}

steps:
-
name: Checkout code
uses: actions/checkout@v3.3.0
uses: actions/checkout@v3.4.0
-
name: "Fix ownership of repository"
run: chown -R root .
Expand Down Expand Up @@ -131,7 +133,7 @@ jobs:
steps:
-
name: Checkout code
uses: actions/checkout@v3.3.0
uses: actions/checkout@v3.4.0
-
name: Get Binaries built in previous jobs
uses: actions/download-artifact@v3.0.2
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
steps:
-
name: Checkout repository
uses: actions/checkout@v3.3.0
uses: actions/checkout@v3.4.0
-
name: Spell-Checking
uses: codespell-project/actions-codespell@master
with:
ignore_words_file: .codespellignore
skip: ./src/database/sqlite3.c,./src/database/sqlite3.h,./src/database/shell.c,./src/lua,./src/dnsmasq,./src/tre-regex
ignore_words_file: .github/.codespellignore
skip: ./src/database/sqlite3.c,./src/database/sqlite3.h,./src/database/shell.c,./src/lua,./src/dnsmasq,./src/tre-regex,./.git,./test/libs
2 changes: 1 addition & 1 deletion .github/workflows/sync-back-to-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Syncing branches
steps:
- name: Checkout
uses: actions/checkout@v3.3.0
uses: actions/checkout@v3.4.0
- name: Opening pull request
run: gh pr create -B development -H master --title 'Sync master back into development' --body 'Created by Github action' --label 'internal'
env:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
cmake_minimum_required(VERSION 2.8.12)
project(PIHOLE_FTL C)

set(DNSMASQ_VERSION pi-hole-v2.89)
set(DNSMASQ_VERSION pi-hole-v2.89-9461807)

add_subdirectory(src)
136 changes: 135 additions & 1 deletion src/database/gravity-db.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static sqlite3 *gravity_db = NULL;
static sqlite3_stmt* table_stmt = NULL;
static sqlite3_stmt* auditlist_stmt = NULL;
bool gravityDB_opened = false;
static bool gravity_abp_format = false;

// Table names corresponding to the enum defined in gravity-db.h
static const char* tablename[] = { "vw_gravity", "vw_blacklist", "vw_whitelist", "vw_regex_blacklist", "vw_regex_whitelist" , "" };
Expand Down Expand Up @@ -95,6 +96,40 @@ void gravityDB_forked(void)
gravityDB_open();
}

static void gravity_check_ABP_format(void)
{
// Check if we have a valid ABP format
// We do this by checking the "abp_domains" property in the "info" table

// Prepare statement
sqlite3_stmt *stmt = NULL;
int rc = sqlite3_prepare_v2(gravity_db,
"SELECT value FROM info WHERE property = 'abp_domains';",
-1, &stmt, NULL);

if( rc != SQLITE_OK )
{
logg("gravity_check_ABP_format() - SQL error prepare: %s", sqlite3_errstr(rc));
return;
}

// Execute statement
rc = sqlite3_step(stmt);
if( rc != SQLITE_ROW )
{
// No result
gravity_abp_format = false;
sqlite3_finalize(stmt);
return;
}

// Get result (SQLite3 stores 1 for TRUE, 0 for FALSE)
gravity_abp_format = sqlite3_column_int(stmt, 0) != 0;

// Finalize statement
sqlite3_finalize(stmt);
}

// Open gravity database
bool gravityDB_open(void)
{
Expand Down Expand Up @@ -194,6 +229,10 @@ bool gravityDB_open(void)
logg("gravityDB_open() - Cannot set busy handler: %s", sqlite3_errstr(rc));
}

// Check (and remember in global variable) if there are any ABP-style
// entries in the database
gravity_check_ABP_format();

if(config.debug & DEBUG_DATABASE)
logg("gravityDB_open(): Successfully opened gravity.db");
return true;
Expand Down Expand Up @@ -1290,7 +1329,102 @@ enum db_result in_gravity(const char *domain, clientsData *client)
if(stmt == NULL)
stmt = gravity_stmt->get(gravity_stmt, client->id);

return domain_in_list(domain, stmt, "gravity", NULL);
// Check if domain is exactly in gravity list
const enum db_result exact_match = domain_in_list(domain, stmt, "gravity", NULL);
if(config.debug & DEBUG_QUERIES)
logg("Checking if \"%s\" is in gravity: %s",
domain, exact_match == FOUND ? "yes" : "no");
// Return for anything else than "not found" (e.g. "found" or "list not available")
if(exact_match != NOT_FOUND)
return exact_match;

// Return early if we are not supposed to check for ABP-style regex
// matches. This needs to be enabled in the config file as it is
// computationally expensive and not needed in most cases (HOSTS lists).
if(!gravity_abp_format)
return NOT_FOUND;

// Make a copy of the domain we will slowly truncate
// while extracting the individual components below
char *domainBuf = strdup(domain);

// Buffer to hold the constructed (sub)domain in ABP format
char *abpDomain = calloc(strlen(domain) + 4, sizeof(char));
// Prime abp matcher with minimal content
strcpy(abpDomain, "||^");

// Get number of domain parts (equals the number of dots + 1)
unsigned int N = 1u;
for(const char *p = domain; *p != '\0'; p++)
if(*p == '.')
N++;

// Loop over domain parts, building matcher from the TLD
// going down into domain and subdomains one by one
while(N-- > 0)
{
// Get domain to the *last* occurrence of '.'
char *ptr = strrchr(domainBuf, '.');

// If there are no '.' left in the domain buffer, we use the
// remainder which is the left-most domain component
if(ptr == NULL)
ptr = domainBuf;

// Get size of this component...
const size_t component_size = strlen(ptr);
// ... and use it to create a "gap" of the right size in our ABP
// format buffer
// Insert the domain component into the gap
if(ptr[0] == '.')
{
// If the component starts with a dot, we need
// to skip it when copying it into the ABP buffer
// Move excluding initial "||" but including final \0 (strlen-2+1 = strlen-1)
memmove(abpDomain+2+component_size-1, abpDomain+2, strlen(abpDomain)-1);
// Copy component bytes (excl. trailing null-byte)
memcpy(abpDomain+2, ptr+1, component_size-1);
}
else
{
// Otherwise, we copy the component as-is
memmove(abpDomain+2+component_size, abpDomain+2, strlen(abpDomain)-1);
// Copy component bytes (excl. trailing null-byte)
memcpy(abpDomain+2, ptr, component_size);
}
// Check if the constructed ABP-style domain is in the gravity list
const enum db_result abp_match = domain_in_list(abpDomain, stmt, "gravity", NULL);
if(config.debug & DEBUG_QUERIES)
logg("Checking if \"%s\" is in gravity: %s",
abpDomain, abp_match == FOUND ? "yes" : "no");
// Return for anything else than "not found" (e.g. "found" or "list not available")
if(abp_match != NOT_FOUND)
{
free(domainBuf);
free(abpDomain);
return abp_match;
}
// Truncate the domain buffer to the left of the
// last dot, effectively removing the last component
const ssize_t truncate_pos = strlen(domainBuf)-component_size;
if(truncate_pos < 1)
// This was already the last iteration
break;

// Put a null-byte at the truncation position
domainBuf[truncate_pos] = '\0';

// Move the ABP buffer to the right by one byte ...
memmove(abpDomain+3, abpDomain+2, strlen(abpDomain));
// ... and insert '.' for the next iteration
abpDomain[2] = '.';
}

free(domainBuf);
free(abpDomain);

// Domain not found in gravity list
return NOT_FOUND;
}

enum db_result in_blacklist(const char *domain, DNSCacheData *dns_cache, clientsData *client)
Expand Down
Loading