diff options
author | Joern Engel <joern@logfs.org> | 2015-09-15 12:49:05 -0700 |
---|---|---|
committer | Joern Engel <joern@logfs.org> | 2015-09-15 13:03:09 -0700 |
commit | 58295614033d1e0e24ee4a6b9c0690307e65d141 (patch) | |
tree | 6e69f9e1fb358995720c640882051731e0925633 | |
parent | 8ac093b09668a0b8e2d983d152caba39c3cfbcd3 (diff) | |
download | cancd-58295614033d1e0e24ee4a6b9c0690307e65d141.tar.gz |
ignore "eth0." dns prefixes
Some people use "eth0.machine.example.com" instead of
"machine.example.com" as reverse dns names.
Signed-off-by: Joern Engel <joern@logfs.org>
-rw-r--r-- | cancd.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -742,7 +742,7 @@ static void dns_visitor(void *_sip, long unused, u32 ip, size_t unused2) struct source_ip *sip = _sip; struct hostent *he; const char *old; - char *new, *c; + char *new, *c, *name; /* * Close idle logfiles. Maybe the machine no longer exists, @@ -755,7 +755,11 @@ static void dns_visitor(void *_sip, long unused, u32 ip, size_t unused2) he = gethostbyaddr(&ip, 4, AF_INET); if (!he) return; - new = strdup(he->h_name); + /* Ignore "eth0." prefix - some people use this */ + name = he->h_name; + if (!strncmp(name, "eth0.", strlen("eth0."))) + name += strlen("eth0."); + new = strdup(name); if (!new) return; for (c = new; c; c++) { @@ -769,12 +773,12 @@ static void dns_visitor(void *_sip, long unused, u32 ip, size_t unused2) old = sip->filename; sip->filename = new; if (!old || !new || strcmp(old, new)) - syslog(LOG_INFO, "resolved %u.%u.%u.%u to %s", + syslog(LOG_INFO, "resolved %u.%u.%u.%u to %s (%s)", (ip >> 0) & 0xff, (ip >> 8) & 0xff, (ip >> 16) & 0xff, (ip >> 24) & 0xff, - sip->filename); + sip->filename, he->h_name); free((void *)old); } |