From 8106050f24d1552f9fe9f0f1521eb3068de08ea4 Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Tue, 29 Mar 2016 20:35:35 +0200 Subject: Read root hints from file "root.txt". Facilitating querying a local nameserver. --- tools/dnssec/net2wire.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tools/dnssec/net2wire.c b/tools/dnssec/net2wire.c index fb4620b..f97483f 100644 --- a/tools/dnssec/net2wire.c +++ b/tools/dnssec/net2wire.c @@ -247,6 +247,21 @@ send_query(getdns_context *context, return r; } +#define OWN_ROOT + +#ifdef OWN_ROOT +getdns_list * +read_own_rootfile() +{ + FILE *fp = fopen("root.txt", "r"); + getdns_list *list = NULL; + + if (fp && !getdns_fp2rr_list(fp, &list, ".", 0)) + return list; + return NULL; +} +#endif + int main(int argc, char *argv[]) { getdns_return_t r; /* Holder for all function returns */ @@ -256,6 +271,7 @@ int main(int argc, char *argv[]) uint16_t query_type = 0; getdns_transaction_t transaction_id; getdns_list *trust_anchors; + getdns_list *root_servers = NULL; if (argc > 1) @@ -263,9 +279,18 @@ int main(int argc, char *argv[]) if (argc > 2) query_type = (uint16_t) atoi(argv[2]); - if ((r = getdns_context_create(&context, 1))) + if ((r = getdns_context_create(&context, 0))) fprintf(stderr, "Trying to create the context failed"); +#ifdef OWN_ROOT + else if (!(root_servers = read_own_rootfile())) + fprintf(stderr, "Reading root hints file failed.\n"); +#endif + + else if ((r = getdns_context_set_dns_root_servers(context, + root_servers))) + fprintf(stderr, "Setting root name servers failed.\n"); + else if ((r = getdns_context_get_dnssec_trust_anchors( context, &trust_anchors)) || trust_anchors == NULL) -- cgit v1.1