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

Add user-defined wildcard blocking support #348

Merged
merged 1 commit into from Aug 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 17 additions & 9 deletions dnsmasq_interface.c
Expand Up @@ -376,16 +376,18 @@ void FTL_reply(unsigned short flags, char *name, struct all_addr *addr, int id)
inet_ntop((flags & F_IPV4) ? AF_INET : AF_INET6, addr, dest, ADDRSTRLEN);
}

// Extract answer (used e.g. for detecting if a local config is a user-defined
// wildcard blocking entry in form "server=/tobeblocked.com/")
char *answer = dest;
if(flags & F_CNAME)
answer = "(CNAME)";
else if((flags & F_NEG) && (flags & F_NXDOMAIN))
answer = "(NXDOMAIN)";
else if(flags & F_NEG)
answer = "(NODATA)";

if(debug)
{
char *answer = dest;
if(flags & F_CNAME)
answer = "(CNAME)";
else if((flags & F_NEG) && (flags & F_NXDOMAIN))
answer = "(NXDOMAIN)";
else if(flags & F_NEG)
answer = "(NODATA)";

logg("**** got reply %s is %s (ID %i)", name, answer, id);
print_flags(flags);
}
Expand Down Expand Up @@ -429,7 +431,13 @@ void FTL_reply(unsigned short flags, char *name, struct all_addr *addr, int id)
counters.unknown--;
// Answered from a custom (user provided) cache file
counters.cached++;
queries[i].status = QUERY_CACHE;

if(strcmp(answer, "(NXDOMAIN)") == 0 ||
strcmp(answer, "0.0.0.0") == 0 ||
strcmp(answer, "::") == 0)
queries[i].status = QUERY_WILDCARD;
else
queries[i].status = QUERY_CACHE;

// Get time index
int querytimestamp, overTimetimestamp;
Expand Down