mirror of https://github.com/getdnsapi/getdns.git
GETDNS_RESPSTATUS_NO_NAME only with none NOERROR
So you can have zero answers and a GETDNS_RESPSTATUS_GOOD return status.
This commit is contained in:
parent
6beb98db62
commit
758b6279b2
|
@ -360,7 +360,7 @@ add_only_addresses(struct getdns_list * addrs, ldns_rr_list * rr_list)
|
||||||
|
|
||||||
static struct getdns_dict *
|
static struct getdns_dict *
|
||||||
create_reply_dict(struct getdns_context *context, getdns_network_req * req,
|
create_reply_dict(struct getdns_context *context, getdns_network_req * req,
|
||||||
struct getdns_list * just_addrs, int *nanswers)
|
struct getdns_list * just_addrs)
|
||||||
{
|
{
|
||||||
/* turn a packet into this glorious structure
|
/* turn a packet into this glorious structure
|
||||||
*
|
*
|
||||||
|
@ -423,7 +423,6 @@ create_reply_dict(struct getdns_context *context, getdns_network_req * req,
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
assert(nanswers);
|
|
||||||
|
|
||||||
dnssec_return_status = is_extension_set(req->owner->extensions,
|
dnssec_return_status = is_extension_set(req->owner->extensions,
|
||||||
"dnssec_return_status");
|
"dnssec_return_status");
|
||||||
|
@ -431,8 +430,8 @@ create_reply_dict(struct getdns_context *context, getdns_network_req * req,
|
||||||
"dnssec_return_only_secure");
|
"dnssec_return_only_secure");
|
||||||
do_dnssec = ( dnssec_return_status || dnssec_return_only_secure ) &&
|
do_dnssec = ( dnssec_return_status || dnssec_return_only_secure ) &&
|
||||||
context->has_ta;
|
context->has_ta;
|
||||||
dnssec_return_status = dnssec_return_status || dnssec_return_only_secure ||
|
dnssec_return_status = dnssec_return_status || dnssec_return_only_secure
|
||||||
is_extension_set(req->owner->extensions,
|
|| is_extension_set(req->owner->extensions,
|
||||||
"dnssec_return_validation_chain");
|
"dnssec_return_validation_chain");
|
||||||
|
|
||||||
include_answers = ! do_dnssec /* No DNSSEC, include answer.*/
|
include_answers = ! do_dnssec /* No DNSSEC, include answer.*/
|
||||||
|
@ -469,10 +468,8 @@ create_reply_dict(struct getdns_context *context, getdns_network_req * req,
|
||||||
rrsig_in_answer = 1;
|
rrsig_in_answer = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (include_answers) {
|
if (include_answers)
|
||||||
*nanswers += ldns_rr_list_rr_count(rr_list);
|
|
||||||
sublist = create_list_from_rr_list(context, rr_list);
|
sublist = create_list_from_rr_list(context, rr_list);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
sublist = getdns_list_create_with_context(context);
|
sublist = getdns_list_create_with_context(context);
|
||||||
|
|
||||||
|
@ -575,6 +572,18 @@ create_getdns_response(struct getdns_dns_req * completed_request)
|
||||||
getdns_return_t r = 0;
|
getdns_return_t r = 0;
|
||||||
int nanswers = 0, all_secure = 1;
|
int nanswers = 0, all_secure = 1;
|
||||||
|
|
||||||
|
/* info (bools) about dns_req */
|
||||||
|
int dnssec_return_status;
|
||||||
|
int dnssec_return_only_secure;
|
||||||
|
int do_dnssec;
|
||||||
|
|
||||||
|
dnssec_return_status = is_extension_set(
|
||||||
|
completed_request->extensions, "dnssec_return_status");
|
||||||
|
dnssec_return_only_secure = is_extension_set(
|
||||||
|
completed_request->extensions, "dnssec_return_only_secure");
|
||||||
|
do_dnssec = ( dnssec_return_status || dnssec_return_only_secure ) &&
|
||||||
|
completed_request->context->has_ta;
|
||||||
|
|
||||||
if (completed_request->first_req->request_class == GETDNS_RRTYPE_A ||
|
if (completed_request->first_req->request_class == GETDNS_RRTYPE_A ||
|
||||||
completed_request->first_req->request_class ==
|
completed_request->first_req->request_class ==
|
||||||
GETDNS_RRTYPE_AAAA) {
|
GETDNS_RRTYPE_AAAA) {
|
||||||
|
@ -599,6 +608,9 @@ create_getdns_response(struct getdns_dns_req * completed_request)
|
||||||
while (netreq && r == GETDNS_RETURN_GOOD) {
|
while (netreq && r == GETDNS_RETURN_GOOD) {
|
||||||
|
|
||||||
all_secure = all_secure && netreq->secure;
|
all_secure = all_secure && netreq->secure;
|
||||||
|
if (ldns_pkt_get_rcode(netreq->result) == LDNS_RCODE_NOERROR &&
|
||||||
|
! (do_dnssec && netreq->bogus))
|
||||||
|
nanswers++;
|
||||||
|
|
||||||
struct getdns_bindata full_data;
|
struct getdns_bindata full_data;
|
||||||
full_data.data = NULL;
|
full_data.data = NULL;
|
||||||
|
@ -614,7 +626,7 @@ create_getdns_response(struct getdns_dns_req * completed_request)
|
||||||
size_t idx = 0;
|
size_t idx = 0;
|
||||||
/* reply tree */
|
/* reply tree */
|
||||||
struct getdns_dict *reply = create_reply_dict(
|
struct getdns_dict *reply = create_reply_dict(
|
||||||
completed_request->context, netreq, just_addrs, &nanswers);
|
completed_request->context, netreq, just_addrs);
|
||||||
r = getdns_list_add_item(replies_tree, &idx);
|
r = getdns_list_add_item(replies_tree, &idx);
|
||||||
if (r != GETDNS_RETURN_GOOD) {
|
if (r != GETDNS_RETURN_GOOD) {
|
||||||
getdns_dict_destroy(reply);
|
getdns_dict_destroy(reply);
|
||||||
|
@ -662,20 +674,15 @@ create_getdns_response(struct getdns_dns_req * completed_request)
|
||||||
if (just_addrs) {
|
if (just_addrs) {
|
||||||
r = getdns_dict_set_list(result, GETDNS_STR_KEY_JUST_ADDRS,
|
r = getdns_dict_set_list(result, GETDNS_STR_KEY_JUST_ADDRS,
|
||||||
just_addrs);
|
just_addrs);
|
||||||
|
if (r != GETDNS_RETURN_GOOD) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int dnssec_return_only_secure = is_extension_set(
|
|
||||||
completed_request->extensions, "dnssec_return_only_secure");
|
|
||||||
|
|
||||||
r = getdns_dict_set_int(result, GETDNS_STR_KEY_STATUS,
|
r = getdns_dict_set_int(result, GETDNS_STR_KEY_STATUS,
|
||||||
dnssec_return_only_secure
|
dnssec_return_only_secure
|
||||||
&& ! all_secure ? GETDNS_RESPSTATUS_NO_SECURE_ANSWERS
|
&& ! all_secure ? GETDNS_RESPSTATUS_NO_SECURE_ANSWERS
|
||||||
: nanswers == 0 ? GETDNS_RESPSTATUS_NO_NAME
|
: nanswers == 0 ? GETDNS_RESPSTATUS_NO_NAME
|
||||||
: GETDNS_RESPSTATUS_GOOD);
|
: GETDNS_RESPSTATUS_GOOD);
|
||||||
if (r != GETDNS_RETURN_GOOD) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
|
|
Loading…
Reference in New Issue