Skip to content

Commit

Permalink
Skip queries with domain "pi.hole" during log parsing
Browse files Browse the repository at this point in the history
Signed-off-by: DL6ER <dl6er@dl6er.de>
  • Loading branch information
DL6ER committed Jul 20, 2017
1 parent f8cd0ff commit c8314de
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,22 +288,35 @@ void process_pihole_log(int file)
strncat(domain,domainstart+2,domainlen);
sprintf(domainwithspaces," %s ",domain);

if(strcmp(domain, "pi.hole") == 0)
{
// domain is "pi.hole", skip this query
// free memory already allocated here
free(domain);
free(domainwithspaces);
continue;
}

// Get client
// domainend+6 = pointer to | in "query[AAAA] host.name from |ww.xx.yy.zz\n"
const char *clientend = strstr(domainend+6, "\n");
// Check if buffer pointer is valid
if(clientend == NULL)
{
logg("Notice: Skipping malformated log line (client end missing): %s", readbuffer);
// Skip this line
// Skip this line, free memory already allocated here
free(domain);
free(domainwithspaces);
continue;
}

size_t clientlen = (clientend-domainend)-6;
if(clientlen < 1)
{
logg("Notice: Skipping malformated log line (client length < 1): %s", readbuffer);
// Skip this line
// Skip this line, free memory already allocated here
free(domain);
free(domainwithspaces);
continue;
}

Expand Down

0 comments on commit c8314de

Please sign in to comment.