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

Handle dnsmasq "extra" logging #174

Merged
merged 26 commits into from
Dec 28, 2017
Merged

Handle dnsmasq "extra" logging #174

merged 26 commits into from
Dec 28, 2017

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented Dec 21, 2017

By submitting this pull request, I confirm the following (please check boxes, eg [X]) Failure to fill the template will close your PR:

Please submit all pull requests against the development branch. Failure to do so will delay or deny your request

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • I have considered, and confirmed that this submission will be valuable to others.
  • I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • I give this submission freely, and claim no ownership to its content.

How familiar are you with the codebase?:

10


Complete re-write of FTL log file parser to use dnsmasq's UUIDs present in the log if option log-queries=extra is set. This will ensure 100% correctness of the interpreted log files.

One particular difficulty with dnsmasq's extra logging is that it resets the UUID counter to 0 when being restarted. This poisons the whole idea of having UUIDs. A proper failsafe condition (using the idea of UUID generations) has been implemented in the new parser.

Note that this is a breaking change as the "old" log format cannot be read anymore and as such will bump FTL's version to v3.0.

This template was created based on the work of udemy-dl.

Signed-off-by: DL6ER <dl6er@dl6er.de>
Signed-off-by: DL6ER <dl6er@dl6er.de>
…etection into its own subroutine to avoid large repitions of code.

Signed-off-by: DL6ER <dl6er@dl6er.de>
Signed-off-by: DL6ER <dl6er@dl6er.de>
Signed-off-by: DL6ER <dl6er@dl6er.de>
Signed-off-by: DL6ER <dl6er@dl6er.de>
…ave a path + removed some debugging output

Signed-off-by: DL6ER <dl6er@dl6er.de>
Signed-off-by: DL6ER <dl6er@dl6er.de>
Signed-off-by: DL6ER <dl6er@dl6er.de>
…IGHUP)

Signed-off-by: DL6ER <dl6er@dl6er.de>
Signed-off-by: DL6ER <dl6er@dl6er.de>
@DL6ER DL6ER added this to the v3.0 milestone Dec 21, 2017
@DL6ER DL6ER requested a review from a team December 21, 2017 15:13
Signed-off-by: DL6ER <dl6er@dl6er.de>
Signed-off-by: DL6ER <dl6er@dl6er.de>
…very unique

Signed-off-by: DL6ER <dl6er@dl6er.de>
@DL6ER DL6ER changed the title [WIP] Handle dnsmasq "extra" logging Handle dnsmasq "extra" logging Dec 21, 2017
@DL6ER
Copy link
Member Author

DL6ER commented Dec 27, 2017

Still working fine for me with no queries that cannot be determined (see Unknown DNS queries).

[2017-12-27 13:14:45.999]  -> Total DNS queries: 6689
[2017-12-27 13:14:45.999]  -> Cached DNS queries: 2348
[2017-12-27 13:14:45.999]  -> Forwarded DNS queries: 4278
[2017-12-27 13:14:45.999]  -> Exactly blocked DNS queries: 61
[2017-12-27 13:14:45.999]  -> Wildcard blocked DNS queries: 2
[2017-12-27 13:14:45.999]  -> Unknown DNS queries: 0
[2017-12-27 13:14:45.999]  -> Unique domains: 880
[2017-12-27 13:14:45.999]  -> Unique clients: 6
[2017-12-27 13:14:45.999]  -> Known forward destinations: 4

100% accuracy is verified via visual inspection in a few very busy regions.

This PR can be merged at any point to development as the release target v2.13.1 is already branched out. As soon as this PR is merged, I can open additional PRs, e.g. actually utilizing the new data we collect from the reply lines as well as advanced DNSSEC support (which is so far completely ignored by FTL) in smaller, much easier to review pull requests.

…rong but nobody noticed it)

Signed-off-by: DL6ER <dl6er@dl6er.de>
database.c Outdated
// Already in database
// logg("Skipping %i",i);
if(queries[i].timestamp <= lasttimestamp || queries[i].db || !queries[i].complete)
// Already in database or not yet complete
continue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we skip a query while it's still not yet complete and the one after is complete, we would lose the first query. Perhaps change this to a break so that we never add any queries after one which is not complete.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, not sure if that is a good solution - although it never happend to me so far, this could be a potential dead-lock assuming that dnsmasq didn't write out the result for one query so it would never be completed. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe bring back the 200 line check or convert it to a timestamp check. If the query hasn't completed after 2 seconds, assume it's a goner and continue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I will in addition compare the time stamp of the query with the current time and break if the query was from within the most recent two seconds. It will have a chance to get saved (or eventually ignored) on the next DB dumping time.

request.c Outdated

if(!debug)
{
sprintf(server_message,"For safety reasons, the command is only available in debugging mode!\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially this command was supposed to do something different, I will remove this statement here.

parser.c Outdated
if(dnsmasqID < 0)
continue;

// Save forwardID in corresponding query indentified by dnsmasq's ID
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment supposed to reference forwardID or status?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, will fix this

parser.c Outdated
int querytimestamp, overTimetimestamp, timeidx = -1, i;
extracttimestamp(readbuffer, &querytimestamp, &overTimetimestamp);

// Save forwardID in corresponding query indentified by dnsmasq's ID
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is where that comment came from (see above).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree :-)

parser.c Outdated
else if(strstr(readbuffer," config ") != NULL && strstr(readbuffer," is ") != NULL)
{
// Check query for invalid characters
if(!checkQuery(readbuffer, "gravity.list"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the correct type for wildcards?

Signed-off-by: DL6ER <dl6er@dl6er.de>
… a query more time to get completed

Signed-off-by: DL6ER <dl6er@dl6er.de>
@DL6ER DL6ER merged commit 21e60e3 into development Dec 28, 2017
@DL6ER DL6ER deleted the new/extra-logging branch December 28, 2017 21:44
@pralor-bot
Copy link

This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/cache-server-statistics/6092/1

@pralor-bot
Copy link

This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/tracking-request-status-unambiguously/6091/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants