Commit Diff
Diff:
d37bff46280e4d98228f6f069fb2ab46188b2b6c
0390ce1fc63210dc5d04b21e51227b405301eaf3
Commit:
0390ce1fc63210dc5d04b21e51227b405301eaf3
Tree:
8c9adb21d115c6fe9a9c69be8ec9b593a05d86ae
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Tue Aug 30 00:12:12 2016 UTC
Message:
modify get_dns_type() a little to have it output jsut the RR and move it to util.c work on making some values in dump_db() more presentable add #include to ddd-include.h create timethuman() to display humanreadable timestamps
blob - 203fdbfe624dc576bd747ec2e86c02257b9d9c05
blob + 69e7644bd7ff998b56d8682e88eb024696358426
--- dd-convert.c
+++ dd-convert.c
@@ -53,6 +53,7 @@ void pack32(char *, u_int32_t);
void pack16(char *, u_int16_t);
void pack8(char *, u_int8_t);
RSA * read_private_key(char *, int, int);
+u_int64_t timethuman(time_t);
@@ -97,6 +98,7 @@ extern struct question *build_fake_question(ch
extern char * dns_label(char *, int *);
extern void * find_substruct(struct domain *, u_int16_t);
extern int label_count(char *);
+extern char *get_dns_type(int, int);
@@ -573,12 +575,15 @@ dump_db(DB *db)
buf[len] = '\0';
}
- printf("%s,rrsig,%d,%d,%d,%d,%d,%d,%d,%d,%s,%s\n",
+ printf("%s,rrsig,%d,%s,%d,%d,%d,%llu,%llu,%d,%s,%s\n",
sdomain->zonename,
sdomain->ttl[INTERNAL_TYPE_RRSIG],
- rss->type_covered, rss->algorithm, rss->labels,
- rss->original_ttl, rss->signature_expiration,
- rss->signature_inception, rss->key_tag,
+ get_dns_type(rss->type_covered, 0),
+ rss->algorithm, rss->labels,
+ rss->original_ttl,
+ timethuman(rss->signature_expiration),
+ timethuman(rss->signature_inception),
+ rss->key_tag,
sdomain->zonename,
buf);
@@ -1252,4 +1257,18 @@ read_private_key(char *zonename, int keyid, int algori
fclose(f);
return (rsa);
+}
+
+u_int64_t
+timethuman(time_t timet)
+{
+ char timebuf[512];
+ struct tm *tm;
+ u_int64_t retbuf;
+
+ tm = gmtime((time_t *)&timet);
+ strftime(timebuf, sizeof(timebuf), "%Y%m%d%H%M%S", tm);
+ retbuf = atoll(timebuf);
+
+ return(retbuf);
}
blob - a4032690a166804e442af0d4c42adf28ff67d569
blob + eb1da0ad0da138f71316f4b5331d00728e58f9d0
--- ddd-include.h
+++ ddd-include.h
@@ -65,6 +65,7 @@
#include <ifaddrs.h>
#include <dirent.h>
#include <signal.h>
+#include <time.h>
#ifdef __linux__
#include <grp.h>
blob - 2eaac6caeeca605b92e43da2d7e4037ca05cf5ee
blob + 9c0215403fbd62c865d63dbd26644377fad844de
--- delphinusdnsd.c
+++ delphinusdnsd.c
@@ -43,6 +43,7 @@ extern int find_filter(struct sockaddr_storage *, int
extern int find_recurse(struct sockaddr_storage *, int);
extern u_int8_t find_region(struct sockaddr_storage *, int);
extern int find_whitelist(struct sockaddr_storage *, int);
+extern char * get_dns_type(int, int);
extern void init_dnssec(void);
extern void init_recurse(void);
extern void init_region(void);
@@ -90,7 +91,6 @@ struct question *build_question(char *, int, int);
void build_reply(struct sreply *, int, char *, int, struct question *, struct sockaddr *, socklen_t, struct domain *, struct domain *, u_int8_t, int, int, struct recurses *, char *);
int compress_label(u_char *, u_int16_t, int);
int free_question(struct question *);
-char *get_dns_type(int dnstype);
struct domain * get_soa(DB *, struct question *);
int lookup_type(int);
void mainloop(struct cfg *);
@@ -110,35 +110,6 @@ void slave_signal(int);
#define PIDFILE "/var/run/delphinusdnsd.pid"
#define MYDB_PATH "/var/db/delphinusdns"
-
-struct typetable {
- char *type;
- int number;
-} TT[] = {
- { "A", DNS_TYPE_A},
- { "NS", DNS_TYPE_NS},
- { "CNAME", DNS_TYPE_CNAME},
- { "SOA", DNS_TYPE_SOA},
- { "PTR", DNS_TYPE_PTR},
- { "MX", DNS_TYPE_MX},
- { "TXT", DNS_TYPE_TXT},
- { "AAAA", DNS_TYPE_AAAA},
- { "ANY", DNS_TYPE_ANY },
- { "SRV", DNS_TYPE_SRV },
- { "SPF", DNS_TYPE_SPF },
- { "SSHFP", DNS_TYPE_SSHFP },
- { "NAPTR", DNS_TYPE_NAPTR },
- { "RRSIG", DNS_TYPE_RRSIG },
- { "DNSKEY", DNS_TYPE_DNSKEY },
- { "NSEC", DNS_TYPE_NSEC },
- { "DS", DNS_TYPE_DS },
- { "NSEC3", DNS_TYPE_NSEC3 },
- { "NSEC3PARAM", DNS_TYPE_NSEC3PARAM },
- { "TLSA", DNS_TYPE_TLSA },
- { NULL, 0}
-};
-
-
/* global variables */
extern char *__progname;
@@ -190,7 +161,7 @@ static struct tcps {
} *tn1, *tnp, *tntmp;
-static const char rcsid[] = "$Id: delphinusdnsd.c,v 1.4 2016/07/21 18:43:54 pjp Exp $";
+static const char rcsid[] = "$Id: delphinusdnsd.c,v 1.5 2016/08/30 00:12:12 pjp Exp $";
/*
* MAIN - set up arguments, set up database, set up sockets, call mainloop
@@ -1573,34 +1544,6 @@ get_soa(DB *db, struct question *question)
}
/*
- * GET_DNS_TYPE - take integer and compare to table, then spit back a static
- * string with the result. This function can't fail.
- */
-
-char *
-get_dns_type(int dnstype)
-{
- static char type[128];
- struct typetable *t;
-
- t = TT;
-
- while (t->type != NULL) {
- if (dnstype == t->number)
- break;
-
- t = (t + 1);
- }
-
- if (t->type == NULL) {
- snprintf(type, sizeof(type) - 1, "%u", dnstype);
- } else
- snprintf(type, sizeof(type) - 1, "%s(%u)", t->type, dnstype);
-
- return (type);
-}
-
-/*
* MAINLOOP - does the polling of tcp & udp descriptors and if ready receives the
* requests, builds the question and calls for replies, loops
*
@@ -2377,7 +2320,7 @@ tcpnxdomain:
tcpout:
if (lflag)
- dolog(LOG_INFO, "request on descriptor %u interface \"%s\" from %s (ttl=TCP, region=%d) for \"%s\" type=%s class=%u, %s%s answering \"%s\" (%d/%d)\n", tnp->so, tnp->ident, tnp->address, tnp->region, question->converted_name, get_dns_type(ntohs(question->hdr->qtype)), ntohs(question->hdr->qclass), (question->edns0len) ? "edns0, " : "", (question->dnssecok) ? "dnssecok, " : "", replystring, len, slen);
+ dolog(LOG_INFO, "request on descriptor %u interface \"%s\" from %s (ttl=TCP, region=%d) for \"%s\" type=%s class=%u, %s%s answering \"%s\" (%d/%d)\n", tnp->so, tnp->ident, tnp->address, tnp->region, question->converted_name, get_dns_type(ntohs(question->hdr->qtype), 1), ntohs(question->hdr->qclass), (question->edns0len) ? "edns0, " : "", (question->dnssecok) ? "dnssecok, " : "", replystring, len, slen);
if (fakequestion != NULL) {
@@ -3020,12 +2963,12 @@ udpnxdomain:
udpout:
if (lflag) {
- dolog(LOG_INFO, "request on descriptor %u interface \"%s\" from %s (ttl=%u, region=%d) for \"%s\" type=%s class=%u, %s%sanswering \"%s\" (%d/%d)\n", so, cfg->ident[i], address, received_ttl, aregion, question->converted_name, get_dns_type(ntohs(question->hdr->qtype)), ntohs(question->hdr->qclass), (question->edns0len ? "edns0, " : ""), (question->dnssecok ? "dnssecok, " : "") , replystring, len, slen);
+ dolog(LOG_INFO, "request on descriptor %u interface \"%s\" from %s (ttl=%u, region=%d) for \"%s\" type=%s class=%u, %s%sanswering \"%s\" (%d/%d)\n", so, cfg->ident[i], address, received_ttl, aregion, question->converted_name, get_dns_type(ntohs(question->hdr->qtype), 1), ntohs(question->hdr->qclass), (question->edns0len ? "edns0, " : ""), (question->dnssecok ? "dnssecok, " : "") , replystring, len, slen);
}
if (logging.active == 1 && logging.bind == 0) {
- remotelog(lfd, "request on descriptor %u interface \"%s\" from %s (ttl=%u, region=%d) for \"%s\" type=%s class=%u, %s%sanswering \"%s\" (%d/%d)", so, cfg->ident[i], address, received_ttl, aregion, question->converted_name, get_dns_type(ntohs(question->hdr->qtype)), ntohs(question->hdr->qclass), (question->edns0len ? "edns0, ": ""), (question->dnssecok ? "dnssecok" : ""), replystring, len, slen);
+ remotelog(lfd, "request on descriptor %u interface \"%s\" from %s (ttl=%u, region=%d) for \"%s\" type=%s class=%u, %s%sanswering \"%s\" (%d/%d)", so, cfg->ident[i], address, received_ttl, aregion, question->converted_name, get_dns_type(ntohs(question->hdr->qtype), 1), ntohs(question->hdr->qclass), (question->edns0len ? "edns0, ": ""), (question->dnssecok ? "dnssecok" : ""), replystring, len, slen);
}
if (fakequestion != NULL) {
blob - b462b02385dd9b2a8f5e219ad56dbd8b24f0bb4f
blob + 0b73efcb25eb3f9510a4646065c3eb37e48309f7
--- util.c
+++ util.c
@@ -43,12 +43,41 @@ u_int16_t check_qtype(struct domain *, u_int16_t, int,
struct question *build_fake_question(char *, int, u_int16_t);
extern void dolog(int, char *, ...);
+char *get_dns_type(int, int);
/* externs */
extern int debug;
extern int *ptr;
+/* internals */
+struct typetable {
+ char *type;
+ int number;
+} TT[] = {
+ { "A", DNS_TYPE_A},
+ { "NS", DNS_TYPE_NS},
+ { "CNAME", DNS_TYPE_CNAME},
+ { "SOA", DNS_TYPE_SOA},
+ { "PTR", DNS_TYPE_PTR},
+ { "MX", DNS_TYPE_MX},
+ { "TXT", DNS_TYPE_TXT},
+ { "AAAA", DNS_TYPE_AAAA},
+ { "ANY", DNS_TYPE_ANY },
+ { "SRV", DNS_TYPE_SRV },
+ { "SPF", DNS_TYPE_SPF },
+ { "SSHFP", DNS_TYPE_SSHFP },
+ { "NAPTR", DNS_TYPE_NAPTR },
+ { "RRSIG", DNS_TYPE_RRSIG },
+ { "DNSKEY", DNS_TYPE_DNSKEY },
+ { "NSEC", DNS_TYPE_NSEC },
+ { "DS", DNS_TYPE_DS },
+ { "NSEC3", DNS_TYPE_NSEC3 },
+ { "NSEC3PARAM", DNS_TYPE_NSEC3PARAM },
+ { "TLSA", DNS_TYPE_TLSA },
+ { NULL, 0}
+};
+
/*
* LABEL_COUNT - count the labels and return that number, based on dns_label()
*/
@@ -698,3 +727,36 @@ build_fake_question(char *name, int namelen, u_int16_t
return (q);
}
+
+/*
+ * GET_DNS_TYPE - take integer and compare to table, then spit back a static
+ * string with the result. This function can't fail.
+ */
+
+char *
+get_dns_type(int dnstype, int withbracket)
+{
+ static char type[128];
+ struct typetable *t;
+
+ t = TT;
+
+ while (t->type != NULL) {
+ if (dnstype == t->number)
+ break;
+
+ t = (t + 1);
+ }
+
+ if (t->type == NULL) {
+ snprintf(type, sizeof(type) - 1, "%u", dnstype);
+ } else {
+ if (withbracket)
+ snprintf(type, sizeof(type) - 1, "%s(%u)", t->type, dnstype);
+ else
+ snprintf(type, sizeof(type) - 1, "%s", t->type);
+ }
+
+ return (type);
+}
+
repomaster@centroid.eu