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

Implement special domains whitelisting #1808

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Changes from all commits
Commits
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
36 changes: 19 additions & 17 deletions src/dnsmasq_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1392,23 +1392,6 @@ static bool _FTL_check_blocking(int queryID, int domainID, int clientID, const c
break;
}

// Not in FTL's cache. Check if this is a special domain
if(special_domain(query, domainstr))
{
// Set DNS cache properties
dns_cache->blocking_status = SPECIAL_DOMAIN;
dns_cache->force_reply = force_next_DNS_reply;

// Adjust counters
query_blocked(query, domain, client, QUERY_SPECIAL_DOMAIN);

// Debug output
if(config.debug & DEBUG_QUERIES)
logg("Special domain: %s is %s", domainstr, blockingreason);

return true;
}

// Skip all checks and continue if we hit already at least one whitelist in the chain
if(query->flags.whitelisted)
{
Expand All @@ -1419,6 +1402,8 @@ static bool _FTL_check_blocking(int queryID, int domainID, int clientID, const c
return false;
}

// when we reach this point: the query is not in FTL's cache (for this client)

// Make a local copy of the domain string. The string memory may get
// reorganized in the following. We cannot expect domainstr to remain
// valid for all time.
Expand All @@ -1432,6 +1417,23 @@ static bool _FTL_check_blocking(int queryID, int domainID, int clientID, const c
if(!query->flags.whitelisted)
query->flags.whitelisted = in_regex(domainstr, dns_cache, client->id, REGEX_WHITELIST);

// Check if this is a special domain
if(!query->flags.whitelisted && special_domain(query, domainstr))
{
// Set DNS cache properties
dns_cache->blocking_status = SPECIAL_DOMAIN;
dns_cache->force_reply = force_next_DNS_reply;

// Adjust counters
query_blocked(query, domain, client, QUERY_SPECIAL_DOMAIN);

// Debug output
if(config.debug & DEBUG_QUERIES)
logg("Special domain: %s is %s", domainstr, blockingreason);

return true;
}

// Check blacklist (exact + regex) and gravity for queried domain
unsigned char new_status = QUERY_UNKNOWN;
bool db_okay = true;
Expand Down