diff options
author | Linus Nordberg <linus@nordu.net> | 2016-03-29 20:35:35 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2016-03-29 20:35:49 +0200 |
commit | 8106050f24d1552f9fe9f0f1521eb3068de08ea4 (patch) | |
tree | 77aa60e9bbd8c7efad5e5a786ed07b6ba92d2bf2 /tools | |
parent | 46a9ea323cc28100988db8762303be853bf40e98 (diff) |
Read root hints from file "root.txt".
Facilitating querying a local nameserver.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/dnssec/net2wire.c | 27 |
1 files changed, 26 insertions, 1 deletions
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) |