Browse Source

Adapt CNAME handler to handle more CNAMEs

A CNAME record can point to another name that is a CNAME, and so on.
This prepares the CNAME resolver to deal with this. It now properly
records clockworkpi.com, which is a CNAME -> WIX -> Fastly.
master
Jon Foster 2 years ago
parent
commit
ddca2693c4
2 changed files with 36 additions and 9 deletions
  1. +17
    -0
      TODO
  2. +19
    -9
      data.cpp

+ 17
- 0
TODO View File

@@ -0,0 +1,17 @@
BUGS
====

- The wild card blocks don't seem to be automatically moving DNS
entries into the block list.


IDEAS
=====

- what about drilling down on domains: domain.tld, then expand up
levels if there are more than a couple of entries.
- Some way to browse by workstation traffic
- See hosts that accessed a domain in the lists.

+ 19
- 9
data.cpp View File

@@ -217,30 +217,39 @@ bool LogAnalyzer::line(const std::string &in) {
address = ln[8]; address = ln[8];


/* NOTE: CNAME resolution seems to follow this order in logs: /* NOTE: CNAME resolution seems to follow this order in logs:

1. A result line (reply/cached) with an address of <CNAME> 1. A result line (reply/cached) with an address of <CNAME>
2. One or more consecutive result lines for the canonical name 2. One or more consecutive result lines for the canonical name

Looking over the logs it doesn't appear that dnsmasq will log Looking over the logs it doesn't appear that dnsmasq will log
anything between the original and CNAME resolutions. The exception anything between the original and CNAME resolutions. The exception
is if a CNAME record is cached and it has to resolve what it is if a CNAME record is cached and it has to resolve what it
points to. In this case there would be a "cached" and then a points to. In this case there would be a "cached" and then a
"forwarded" record eventually followed by "reply ... <CNAME>". "forwarded" record eventually followed by "reply ... <CNAME>".
In that case we want to operate on the reply. In that case we want to operate on the reply.

I just saw that CNAME log entries can be chained. It looks like
they are an "is <CNAME>" entry followed by another. We want to
keep the original name (alias).
*/ */
/* record we're handling a CNAME cycle */
// we're handling a CNAME entry
if(address=="<CNAME>") { if(address=="<CNAME>") {
alias = name;
cname = "";
// If we don't have a cname yet then this is a CNAME to a CNAME.
if(alias=="" || cname!="") {
alias = name;
cname = "";
}
return 0; return 0;
} }
/* If in cname _mode_: */
// If in cname _mode_:
if(alias!="") { if(alias!="") {
if(cname=="") { if(cname=="") {
cname = name; /* This is our target name */
name = alias; /* substitute the alias */
cname = name; // This is our target name
name = alias; // substitute the alias
} else if(cname==name) { } else if(cname==name) {
name = alias; /* substitute the alias */
name = alias; // substitute the alias
} else { } else {
cname = ""; /* These are different records reset */
cname = ""; // These are different records reset
name = ""; name = "";
} }
} }
@@ -256,7 +265,8 @@ bool LogAnalyzer::line(const std::string &in) {
//dlog("Added "+address+" = "+name); //dlog("Added "+address+" = "+name);
return 0; return 0;
} else if(alias!="") { } else if(alias!="") {
alias = ""; /* we've fallen out of CNAME resolution. */
// we've fallen out of CNAME resolution.
alias = "";
cname = ""; cname = "";
} }
} }


Loading…
Cancel
Save