summaryrefslogtreecommitdiff
path: root/examples/ldns-keyfetcher.c
diff options
context:
space:
mode:
authorJelte Jansen <jeltejan@NLnetLabs.nl>2006-06-30 14:20:50 +0200
committerJelte Jansen <jeltejan@NLnetLabs.nl>2006-06-30 14:20:50 +0200
commita60c156389b0d70405e7b03f3fa2b517351f2b01 (patch)
tree7d5a87fffc95acfc70496e91a99fb1da8003a3b9 /examples/ldns-keyfetcher.c
parentb0143e5a8914bb8a4498eaf86d0e4990b703339c (diff)
downloadldns-a60c156389b0d70405e7b03f3fa2b517351f2b01.tar.gz
return correct error if reading of resolv.conf fails
keyfetcher defaults to 127.0.0.1 if resolv.conf cannot be read
Diffstat (limited to 'examples/ldns-keyfetcher.c')
-rw-r--r--examples/ldns-keyfetcher.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/examples/ldns-keyfetcher.c b/examples/ldns-keyfetcher.c
index f16c7128..0a5fca81 100644
--- a/examples/ldns-keyfetcher.c
+++ b/examples/ldns-keyfetcher.c
@@ -548,6 +548,7 @@ int
main(int argc, char *argv[])
{
ldns_resolver *res;
+ ldns_rdf *ns;
ldns_rdf *domain;
ldns_rr_list *l = NULL;
@@ -617,6 +618,9 @@ main(int argc, char *argv[])
}
domain = ldns_dname_new_frm_str(argv[i]);
+ printf("domain: ");
+ ldns_rdf_print(stdout, domain);
+ printf("\n");
}
}
@@ -634,10 +638,15 @@ main(int argc, char *argv[])
/* create a new resolver from /etc/resolv.conf */
status = ldns_resolver_new_frm_file(&res, NULL);
+
if (status != LDNS_STATUS_OK) {
- ldns_rdf_deep_free(domain);
- fprintf(stderr, "Error creating resolver: %s\n", ldns_get_errorstr_by_id(status));
- exit(EXIT_FAILURE);
+ fprintf(stderr, "Warning: Unable to create stub resolver from /etc/resolv.conf:\n");
+ fprintf("%s\n", ldns_get_errorstr_by_id(status));
+ fprintf(stderr, "defaulting to nameserver at 127.0.0.1 for separate nameserver name lookups\n");
+ res = ldns_resolver_new();
+ ns = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_A, "127.0.0.1");
+ ldns_resolver_push_nameserver(res, ns);
+ ldns_rdf_deep_free(ns);
}
ldns_resolver_set_ip6(res, address_family);
@@ -681,7 +690,8 @@ main(int argc, char *argv[])
ldns_rr_list_print(stdout, l);
}
} else {
- printf("no packet?!?\n");
+ printf("no answer packet received, stub resolver config:\n");
+ ldns_resolver_print(stdout, res);
}
printf("\n");