mirror of https://github.com/getdnsapi/getdns.git
Merge pull request #75 from saradickinson/tcp_testing
Crude changes to stub test scripts to allow testing of all transport and...
This commit is contained in:
commit
d583766a03
|
@ -41,6 +41,12 @@
|
|||
#include "getdns/getdns_extra.h"
|
||||
#include <sys/time.h>
|
||||
|
||||
#define TRANSPORT_UDP "udp"
|
||||
#define TRANSPORT_TCP "tcp"
|
||||
#define TRANSPORT_PIPELINE "pipeline"
|
||||
#define RESOLUTION_STUB "stub"
|
||||
#define RESOLUTION_REC "rec"
|
||||
|
||||
/* Set up the callback function, which will also do the processing of the results */
|
||||
void
|
||||
this_callbackfn(struct getdns_context *this_context,
|
||||
|
@ -55,11 +61,11 @@ this_callbackfn(struct getdns_context *this_context,
|
|||
|
||||
} else if (this_callback_type == GETDNS_CALLBACK_CANCEL)
|
||||
fprintf(stderr,
|
||||
"The callback with ID %llu was cancelled. Exiting.",
|
||||
"The callback with ID %llu was cancelled. Exiting.\n",
|
||||
(unsigned long long)this_transaction_id);
|
||||
else
|
||||
fprintf(stderr,
|
||||
"The callback got a callback_type of %d. Exiting.",
|
||||
"The callback got a callback_type of %d. Exiting.\n",
|
||||
this_callback_type);
|
||||
getdns_dict_destroy(this_response);
|
||||
}
|
||||
|
@ -67,6 +73,10 @@ this_callbackfn(struct getdns_context *this_context,
|
|||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
|
||||
const char *transport = argc > 2 ? argv[2] : "udp";
|
||||
const char *resolution = argc > 3 ? argv[3] : "stub";
|
||||
|
||||
/* Create the DNS context for this call */
|
||||
struct getdns_context *this_context = NULL;
|
||||
getdns_return_t context_create_return =
|
||||
|
@ -76,7 +86,22 @@ main(int argc, char** argv)
|
|||
context_create_return);
|
||||
return (GETDNS_RETURN_GENERIC_ERROR);
|
||||
}
|
||||
getdns_context_set_resolution_type(this_context, GETDNS_RESOLUTION_STUB);
|
||||
|
||||
if (strncmp(resolution, RESOLUTION_STUB, 4) == 0)
|
||||
getdns_context_set_resolution_type(this_context, GETDNS_RESOLUTION_STUB);
|
||||
else if (strncmp(resolution, RESOLUTION_REC, 4) != 0) {
|
||||
fprintf(stderr, "Invalid resolution %s, must be one of stub or rec\n", transport);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (strncmp(transport, TRANSPORT_TCP, 3) == 0)
|
||||
getdns_context_set_dns_transport(this_context, GETDNS_TRANSPORT_TCP_ONLY);
|
||||
else if (strncmp(transport, TRANSPORT_PIPELINE, 8) == 0)
|
||||
getdns_context_set_dns_transport(this_context, GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN);
|
||||
else if (strncmp(transport, TRANSPORT_UDP, 3) != 0) {
|
||||
fprintf(stderr, "Invalid transport %s, must be one of udp, tcp or pipeline\n", transport);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
getdns_context_set_timeout(this_context, 5000);
|
||||
/* Create an event base and put it in the context using the unknown function name */
|
||||
|
@ -87,7 +112,7 @@ main(int argc, char** argv)
|
|||
|
||||
/* Make the call */
|
||||
getdns_return_t dns_request_return =
|
||||
getdns_general(this_context, this_name, GETDNS_RRTYPE_A,
|
||||
getdns_address(this_context, this_name,
|
||||
NULL, this_userarg, &this_transaction_id, this_callbackfn);
|
||||
if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME) {
|
||||
fprintf(stderr, "A bad domain name was used: %s. Exiting.",
|
||||
|
@ -96,19 +121,7 @@ main(int argc, char** argv)
|
|||
return (GETDNS_RETURN_GENERIC_ERROR);
|
||||
}
|
||||
else {
|
||||
/* Call the event loop */
|
||||
struct timeval tv;
|
||||
while (getdns_context_get_num_pending_requests(this_context, &tv) > 0) {
|
||||
int fd = getdns_context_fd(this_context);
|
||||
fd_set read_fds;
|
||||
FD_ZERO(&read_fds);
|
||||
FD_SET(fd, &read_fds);
|
||||
select(fd + 1, &read_fds, NULL, NULL, &tv);
|
||||
if (getdns_context_process_async(this_context) != GETDNS_RETURN_GOOD) {
|
||||
// context destroyed
|
||||
break;
|
||||
}
|
||||
}
|
||||
getdns_context_run(this_context);
|
||||
}
|
||||
/* Clean up */
|
||||
getdns_context_destroy(this_context);
|
||||
|
|
|
@ -1,187 +1,322 @@
|
|||
{
|
||||
"answer_type": 800,
|
||||
"canonical_name": <bindata of "www.google.com.">,
|
||||
"answer_type": GETDNS_NAMETYPE_DNS,
|
||||
"canonical_name": <bindata of "getdnsapi.net.">,
|
||||
"just_address_answers":
|
||||
[
|
||||
{
|
||||
"address_data": <bindata of 0x4a7d8369>,
|
||||
"address_data": <bindata for 185.49.141.37>,
|
||||
"address_type": <bindata of "IPv4">
|
||||
},
|
||||
{
|
||||
"address_data": <bindata of 0x4a7d8367>,
|
||||
"address_type": <bindata of "IPv4">
|
||||
},
|
||||
{
|
||||
"address_data": <bindata of 0x4a7d8368>,
|
||||
"address_type": <bindata of "IPv4">
|
||||
},
|
||||
{
|
||||
"address_data": <bindata of 0x4a7d8393>,
|
||||
"address_type": <bindata of "IPv4">
|
||||
},
|
||||
{
|
||||
"address_data": <bindata of 0x4a7d836a>,
|
||||
"address_type": <bindata of "IPv4">
|
||||
},
|
||||
{
|
||||
"address_data": <bindata of 0x4a7d8363>,
|
||||
"address_type": <bindata of "IPv4">
|
||||
},
|
||||
{
|
||||
"address_data": <bindata of 0x2607f8b0400c0c030000000000000067>,
|
||||
"address_data": <bindata for 2a04:b900:0:100::37>,
|
||||
"address_type": <bindata of "IPv6">
|
||||
}
|
||||
],
|
||||
"replies_full":
|
||||
[
|
||||
<bindata of 0x00008180000100060000000103777777...>,
|
||||
<bindata of 0x00008180000100010000000103777777...>
|
||||
<bindata of 0x705f8180000100020004000309676574...>,
|
||||
<bindata of 0x5fb58180000100020004000309676574...>
|
||||
],
|
||||
"replies_tree":
|
||||
[
|
||||
{
|
||||
"additional": [],
|
||||
"additional":
|
||||
[
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for getdnsapi.net.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv6_address": <bindata for 2a04:b900:0:100::37>,
|
||||
"rdata_raw": <bindata of 0x2a04b900000001000000000000000037>
|
||||
},
|
||||
"ttl": 376,
|
||||
"type": GETDNS_RRTYPE_AAAA
|
||||
},
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for getdnsapi.net.>,
|
||||
"rdata":
|
||||
{
|
||||
"algorithm": 7,
|
||||
"key_tag": 50394,
|
||||
"labels": 2,
|
||||
"original_ttl": 450,
|
||||
"rdata_raw": <bindata of 0x001c0702000001c25462c1ca54465e04...>,
|
||||
"signature": <bindata of 0x997567f31b90d7edb2500dcc5c6f6ee3...>,
|
||||
"signature_expiration": 1415758282,
|
||||
"signature_inception": 1413897732,
|
||||
"signers_name": <bindata for getdnsapi.net.>,
|
||||
"type_covered": GETDNS_RRTYPE_AAAA
|
||||
},
|
||||
"ttl": 376,
|
||||
"type": GETDNS_RRTYPE_RRSIG
|
||||
}
|
||||
],
|
||||
"answer":
|
||||
[
|
||||
{
|
||||
"class": 1,
|
||||
"name": <bindata for www.google.com.>,
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for getdnsapi.net.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv4_address": <bindata of 0x4a7d8369>,
|
||||
"rdata_raw": <bindata of 0x4a7d8369>
|
||||
"ipv4_address": <bindata for 185.49.141.37>,
|
||||
"rdata_raw": <bindata of 0xb9318d25>
|
||||
},
|
||||
"ttl": 227,
|
||||
"ttl": 376,
|
||||
"type": GETDNS_RRTYPE_A
|
||||
},
|
||||
{
|
||||
"class": 1,
|
||||
"name": <bindata for www.google.com.>,
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for getdnsapi.net.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv4_address": <bindata of 0x4a7d8367>,
|
||||
"rdata_raw": <bindata of 0x4a7d8367>
|
||||
"algorithm": 7,
|
||||
"key_tag": 50394,
|
||||
"labels": 2,
|
||||
"original_ttl": 450,
|
||||
"rdata_raw": <bindata of 0x00010702000001c254616f025445ed84...>,
|
||||
"signature": <bindata of 0x6b0f75546e89e16a45d6ffec4dcb9bb0...>,
|
||||
"signature_expiration": 1415671554,
|
||||
"signature_inception": 1413868932,
|
||||
"signers_name": <bindata for getdnsapi.net.>,
|
||||
"type_covered": GETDNS_RRTYPE_A
|
||||
},
|
||||
"ttl": 227,
|
||||
"type": GETDNS_RRTYPE_A
|
||||
},
|
||||
{
|
||||
"class": 1,
|
||||
"name": <bindata for www.google.com.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv4_address": <bindata of 0x4a7d8368>,
|
||||
"rdata_raw": <bindata of 0x4a7d8368>
|
||||
},
|
||||
"ttl": 227,
|
||||
"type": GETDNS_RRTYPE_A
|
||||
},
|
||||
{
|
||||
"class": 1,
|
||||
"name": <bindata for www.google.com.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv4_address": <bindata of 0x4a7d8393>,
|
||||
"rdata_raw": <bindata of 0x4a7d8393>
|
||||
},
|
||||
"ttl": 227,
|
||||
"type": GETDNS_RRTYPE_A
|
||||
},
|
||||
{
|
||||
"class": 1,
|
||||
"name": <bindata for www.google.com.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv4_address": <bindata of 0x4a7d836a>,
|
||||
"rdata_raw": <bindata of 0x4a7d836a>
|
||||
},
|
||||
"ttl": 227,
|
||||
"type": GETDNS_RRTYPE_A
|
||||
},
|
||||
{
|
||||
"class": 1,
|
||||
"name": <bindata for www.google.com.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv4_address": <bindata of 0x4a7d8363>,
|
||||
"rdata_raw": <bindata of 0x4a7d8363>
|
||||
},
|
||||
"ttl": 227,
|
||||
"type": GETDNS_RRTYPE_A
|
||||
"ttl": 376,
|
||||
"type": GETDNS_RRTYPE_RRSIG
|
||||
}
|
||||
],
|
||||
"answer_type": 800,
|
||||
"authority": [],
|
||||
"canonical_name": <bindata of "www.google.com.">,
|
||||
"answer_type": GETDNS_NAMETYPE_DNS,
|
||||
"authority":
|
||||
[
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for getdnsapi.net.>,
|
||||
"rdata":
|
||||
{
|
||||
"nsdname": <bindata for getdnsapi.net.>,
|
||||
"rdata_raw": <bindata for getdnsapi.net.>
|
||||
},
|
||||
"ttl": 376,
|
||||
"type": GETDNS_RRTYPE_NS
|
||||
},
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for getdnsapi.net.>,
|
||||
"rdata":
|
||||
{
|
||||
"nsdname": <bindata for mcvax.nlnet.nl.>,
|
||||
"rdata_raw": <bindata for mcvax.nlnet.nl.>
|
||||
},
|
||||
"ttl": 376,
|
||||
"type": GETDNS_RRTYPE_NS
|
||||
},
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for getdnsapi.net.>,
|
||||
"rdata":
|
||||
{
|
||||
"nsdname": <bindata for dicht.nlnetlabs.nl.>,
|
||||
"rdata_raw": <bindata for dicht.nlnetlabs.nl.>
|
||||
},
|
||||
"ttl": 376,
|
||||
"type": GETDNS_RRTYPE_NS
|
||||
},
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for getdnsapi.net.>,
|
||||
"rdata":
|
||||
{
|
||||
"algorithm": 7,
|
||||
"key_tag": 50394,
|
||||
"labels": 2,
|
||||
"original_ttl": 450,
|
||||
"rdata_raw": <bindata of 0x00020702000001c254606b0054450c84...>,
|
||||
"signature": <bindata of 0x103f5f653c8eca57c2544af8afe62158...>,
|
||||
"signature_expiration": 1415604992,
|
||||
"signature_inception": 1413811332,
|
||||
"signers_name": <bindata for getdnsapi.net.>,
|
||||
"type_covered": GETDNS_RRTYPE_NS
|
||||
},
|
||||
"ttl": 376,
|
||||
"type": GETDNS_RRTYPE_RRSIG
|
||||
}
|
||||
],
|
||||
"canonical_name": <bindata of "getdnsapi.net.">,
|
||||
"header":
|
||||
{
|
||||
"aa": 0,
|
||||
"ad": 0,
|
||||
"ancount": 6,
|
||||
"arcount": 0,
|
||||
"ancount": 2,
|
||||
"arcount": 2,
|
||||
"cd": 0,
|
||||
"id": 0,
|
||||
"nscount": 0,
|
||||
"opcode": 0,
|
||||
"id": 28767,
|
||||
"nscount": 4,
|
||||
"opcode": GETDNS_OPCODE_QUERY,
|
||||
"qdcount": 1,
|
||||
"qr": 1,
|
||||
"ra": 1,
|
||||
"rcode": 0,
|
||||
"rcode": GETDNS_RCODE_NOERROR,
|
||||
"rd": 1,
|
||||
"tc": 0,
|
||||
"z": 0
|
||||
},
|
||||
"question":
|
||||
{
|
||||
"qclass": 1,
|
||||
"qname": <bindata for www.google.com.>,
|
||||
"qtype": 1
|
||||
"qclass": GETDNS_RRCLASS_IN,
|
||||
"qname": <bindata for getdnsapi.net.>,
|
||||
"qtype": GETDNS_RRTYPE_A
|
||||
}
|
||||
},
|
||||
{
|
||||
"additional": [],
|
||||
"additional":
|
||||
[
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for getdnsapi.net.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv4_address": <bindata for 185.49.141.37>,
|
||||
"rdata_raw": <bindata of 0xb9318d25>
|
||||
},
|
||||
"ttl": 376,
|
||||
"type": GETDNS_RRTYPE_A
|
||||
},
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for getdnsapi.net.>,
|
||||
"rdata":
|
||||
{
|
||||
"algorithm": 7,
|
||||
"key_tag": 50394,
|
||||
"labels": 2,
|
||||
"original_ttl": 450,
|
||||
"rdata_raw": <bindata of 0x00010702000001c254616f025445ed84...>,
|
||||
"signature": <bindata of 0x6b0f75546e89e16a45d6ffec4dcb9bb0...>,
|
||||
"signature_expiration": 1415671554,
|
||||
"signature_inception": 1413868932,
|
||||
"signers_name": <bindata for getdnsapi.net.>,
|
||||
"type_covered": GETDNS_RRTYPE_A
|
||||
},
|
||||
"ttl": 376,
|
||||
"type": GETDNS_RRTYPE_RRSIG
|
||||
}
|
||||
],
|
||||
"answer":
|
||||
[
|
||||
{
|
||||
"class": 1,
|
||||
"name": <bindata for www.google.com.>,
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for getdnsapi.net.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv6_address": <bindata of 0x2607f8b0400c0c030000000000000067>,
|
||||
"rdata_raw": <bindata of 0x2607f8b0400c0c030000000000000067>
|
||||
"ipv6_address": <bindata for 2a04:b900:0:100::37>,
|
||||
"rdata_raw": <bindata of 0x2a04b900000001000000000000000037>
|
||||
},
|
||||
"ttl": 136,
|
||||
"ttl": 376,
|
||||
"type": GETDNS_RRTYPE_AAAA
|
||||
},
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for getdnsapi.net.>,
|
||||
"rdata":
|
||||
{
|
||||
"algorithm": 7,
|
||||
"key_tag": 50394,
|
||||
"labels": 2,
|
||||
"original_ttl": 450,
|
||||
"rdata_raw": <bindata of 0x001c0702000001c25462c1ca54465e04...>,
|
||||
"signature": <bindata of 0x997567f31b90d7edb2500dcc5c6f6ee3...>,
|
||||
"signature_expiration": 1415758282,
|
||||
"signature_inception": 1413897732,
|
||||
"signers_name": <bindata for getdnsapi.net.>,
|
||||
"type_covered": GETDNS_RRTYPE_AAAA
|
||||
},
|
||||
"ttl": 376,
|
||||
"type": GETDNS_RRTYPE_RRSIG
|
||||
}
|
||||
],
|
||||
"answer_type": 800,
|
||||
"authority": [],
|
||||
"canonical_name": <bindata of "www.google.com.">,
|
||||
"answer_type": GETDNS_NAMETYPE_DNS,
|
||||
"authority":
|
||||
[
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for getdnsapi.net.>,
|
||||
"rdata":
|
||||
{
|
||||
"nsdname": <bindata for getdnsapi.net.>,
|
||||
"rdata_raw": <bindata for getdnsapi.net.>
|
||||
},
|
||||
"ttl": 376,
|
||||
"type": GETDNS_RRTYPE_NS
|
||||
},
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for getdnsapi.net.>,
|
||||
"rdata":
|
||||
{
|
||||
"nsdname": <bindata for mcvax.nlnet.nl.>,
|
||||
"rdata_raw": <bindata for mcvax.nlnet.nl.>
|
||||
},
|
||||
"ttl": 376,
|
||||
"type": GETDNS_RRTYPE_NS
|
||||
},
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for getdnsapi.net.>,
|
||||
"rdata":
|
||||
{
|
||||
"nsdname": <bindata for dicht.nlnetlabs.nl.>,
|
||||
"rdata_raw": <bindata for dicht.nlnetlabs.nl.>
|
||||
},
|
||||
"ttl": 376,
|
||||
"type": GETDNS_RRTYPE_NS
|
||||
},
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for getdnsapi.net.>,
|
||||
"rdata":
|
||||
{
|
||||
"algorithm": 7,
|
||||
"key_tag": 50394,
|
||||
"labels": 2,
|
||||
"original_ttl": 450,
|
||||
"rdata_raw": <bindata of 0x00020702000001c254606b0054450c84...>,
|
||||
"signature": <bindata of 0x103f5f653c8eca57c2544af8afe62158...>,
|
||||
"signature_expiration": 1415604992,
|
||||
"signature_inception": 1413811332,
|
||||
"signers_name": <bindata for getdnsapi.net.>,
|
||||
"type_covered": GETDNS_RRTYPE_NS
|
||||
},
|
||||
"ttl": 376,
|
||||
"type": GETDNS_RRTYPE_RRSIG
|
||||
}
|
||||
],
|
||||
"canonical_name": <bindata of "getdnsapi.net.">,
|
||||
"header":
|
||||
{
|
||||
"aa": 0,
|
||||
"ad": 0,
|
||||
"ancount": 1,
|
||||
"arcount": 0,
|
||||
"ancount": 2,
|
||||
"arcount": 2,
|
||||
"cd": 0,
|
||||
"id": 0,
|
||||
"nscount": 0,
|
||||
"opcode": 0,
|
||||
"id": 24501,
|
||||
"nscount": 4,
|
||||
"opcode": GETDNS_OPCODE_QUERY,
|
||||
"qdcount": 1,
|
||||
"qr": 1,
|
||||
"ra": 1,
|
||||
"rcode": 0,
|
||||
"rcode": GETDNS_RCODE_NOERROR,
|
||||
"rd": 1,
|
||||
"tc": 0,
|
||||
"z": 0
|
||||
},
|
||||
"question":
|
||||
{
|
||||
"qclass": 1,
|
||||
"qname": <bindata for www.google.com.>,
|
||||
"qtype": 28
|
||||
"qclass": GETDNS_RRCLASS_IN,
|
||||
"qname": <bindata for getdnsapi.net.>,
|
||||
"qtype": GETDNS_RRTYPE_AAAA
|
||||
}
|
||||
}
|
||||
],
|
||||
"status": 900
|
||||
"status": GETDNS_RESPSTATUS_GOOD
|
||||
}
|
||||
|
|
|
@ -38,6 +38,12 @@
|
|||
#include "testmessages.h"
|
||||
#include "getdns/getdns.h"
|
||||
|
||||
#define TRANSPORT_UDP "udp"
|
||||
#define TRANSPORT_TCP "tcp"
|
||||
#define TRANSPORT_PIPELINE "pipeline"
|
||||
#define RESOLUTION_STUB "stub"
|
||||
#define RESOLUTION_REC "rec"
|
||||
|
||||
static void
|
||||
print_response(struct getdns_dict * response)
|
||||
{
|
||||
|
@ -49,8 +55,12 @@ print_response(struct getdns_dict * response)
|
|||
}
|
||||
|
||||
int
|
||||
main()
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
|
||||
const char *transport = argc > 1 ? argv[1] : "udp";
|
||||
const char *resolution = argc > 2 ? argv[2] : "stub";
|
||||
|
||||
/* Create the DNS context for this call */
|
||||
struct getdns_context *this_context = NULL;
|
||||
getdns_return_t context_create_return =
|
||||
|
@ -60,7 +70,22 @@ main()
|
|||
context_create_return);
|
||||
return (GETDNS_RETURN_GENERIC_ERROR);
|
||||
}
|
||||
getdns_context_set_resolution_type(this_context, GETDNS_RESOLUTION_STUB);
|
||||
|
||||
if (strncmp(resolution, RESOLUTION_STUB, 4) == 0)
|
||||
getdns_context_set_resolution_type(this_context, GETDNS_RESOLUTION_STUB);
|
||||
else if (strncmp(resolution, RESOLUTION_REC, 4) != 0) {
|
||||
fprintf(stderr, "Invalid resolution %s, must be one of stub or rec\n", transport);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (strncmp(transport, TRANSPORT_TCP, 3) == 0)
|
||||
getdns_context_set_dns_transport(this_context, GETDNS_TRANSPORT_TCP_ONLY);
|
||||
else if (strncmp(transport, TRANSPORT_PIPELINE, 8) == 0)
|
||||
getdns_context_set_dns_transport(this_context, GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN);
|
||||
else if (strncmp(transport, TRANSPORT_UDP, 3) != 0) {
|
||||
fprintf(stderr, "Invalid transport %s, must be one of udp, tcp or pipeline\n", transport);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
struct getdns_dict *response = NULL;
|
||||
getdns_return_t ret =
|
||||
|
@ -74,17 +99,14 @@ main()
|
|||
getdns_dict_destroy(response);
|
||||
|
||||
ret =
|
||||
getdns_service_sync(this_context, "www.google.com", NULL, &response);
|
||||
getdns_service_sync(this_context, "_xmpp-client._tcp.jabber.com.", NULL, &response);
|
||||
if (ret != GETDNS_RETURN_GOOD || response == NULL) {
|
||||
fprintf(stderr, "Service sync returned error.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
print_response(response);
|
||||
getdns_dict_destroy(response);
|
||||
|
||||
/* Now switch to TCP and make sure everything works */
|
||||
getdns_context_set_dns_transport(this_context, GETDNS_TRANSPORT_TCP_ONLY);
|
||||
|
||||
|
||||
ret = getdns_general_sync(this_context, "www.google.com", GETDNS_RRTYPE_A,
|
||||
NULL, &response);
|
||||
if (ret != GETDNS_RETURN_GOOD || response == NULL) {
|
||||
|
@ -93,7 +115,7 @@ main()
|
|||
}
|
||||
print_response(response);
|
||||
getdns_dict_destroy(response);
|
||||
|
||||
|
||||
/* Clean up */
|
||||
getdns_context_destroy(this_context);
|
||||
/* Assuming we get here, leave gracefully */
|
||||
|
|
|
@ -1,41 +1,37 @@
|
|||
The packet {
|
||||
"answer_type": 800,
|
||||
"answer_type": GETDNS_NAMETYPE_DNS,
|
||||
"canonical_name": <bindata of "www.google.com.">,
|
||||
"just_address_answers":
|
||||
[
|
||||
{
|
||||
"address_data": <bindata of 0x4a7d8393>,
|
||||
"address_data": <bindata for 74.125.230.81>,
|
||||
"address_type": <bindata of "IPv4">
|
||||
},
|
||||
{
|
||||
"address_data": <bindata of 0x4a7d8368>,
|
||||
"address_data": <bindata for 74.125.230.80>,
|
||||
"address_type": <bindata of "IPv4">
|
||||
},
|
||||
{
|
||||
"address_data": <bindata of 0x4a7d8363>,
|
||||
"address_data": <bindata for 74.125.230.82>,
|
||||
"address_type": <bindata of "IPv4">
|
||||
},
|
||||
{
|
||||
"address_data": <bindata of 0x4a7d8367>,
|
||||
"address_data": <bindata for 74.125.230.83>,
|
||||
"address_type": <bindata of "IPv4">
|
||||
},
|
||||
{
|
||||
"address_data": <bindata of 0x4a7d836a>,
|
||||
"address_data": <bindata for 74.125.230.84>,
|
||||
"address_type": <bindata of "IPv4">
|
||||
},
|
||||
{
|
||||
"address_data": <bindata of 0x4a7d8369>,
|
||||
"address_type": <bindata of "IPv4">
|
||||
},
|
||||
{
|
||||
"address_data": <bindata of 0x2607f8b0400c0c030000000000000068>,
|
||||
"address_data": <bindata for 2a00:1450:4009:800::1014>,
|
||||
"address_type": <bindata of "IPv6">
|
||||
}
|
||||
],
|
||||
"replies_full":
|
||||
[
|
||||
<bindata of 0x00008180000100060000000103777777...>,
|
||||
<bindata of 0x00008180000100010000000103777777...>
|
||||
<bindata of 0xb1808180000100050000000103777777...>,
|
||||
<bindata of 0xeba08180000100010000000103777777...>
|
||||
],
|
||||
"replies_tree":
|
||||
[
|
||||
|
@ -44,98 +40,87 @@ The packet {
|
|||
"answer":
|
||||
[
|
||||
{
|
||||
"class": 1,
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for www.google.com.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv4_address": <bindata of 0x4a7d8393>,
|
||||
"rdata_raw": <bindata of 0x4a7d8393>
|
||||
"ipv4_address": <bindata for 74.125.230.81>,
|
||||
"rdata_raw": <bindata of 0x4a7de651>
|
||||
},
|
||||
"ttl": 300,
|
||||
"type": GETDNS_RRTYPE_A
|
||||
},
|
||||
{
|
||||
"class": 1,
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for www.google.com.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv4_address": <bindata of 0x4a7d8368>,
|
||||
"rdata_raw": <bindata of 0x4a7d8368>
|
||||
"ipv4_address": <bindata for 74.125.230.80>,
|
||||
"rdata_raw": <bindata of 0x4a7de650>
|
||||
},
|
||||
"ttl": 300,
|
||||
"type": GETDNS_RRTYPE_A
|
||||
},
|
||||
{
|
||||
"class": 1,
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for www.google.com.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv4_address": <bindata of 0x4a7d8363>,
|
||||
"rdata_raw": <bindata of 0x4a7d8363>
|
||||
"ipv4_address": <bindata for 74.125.230.82>,
|
||||
"rdata_raw": <bindata of 0x4a7de652>
|
||||
},
|
||||
"ttl": 300,
|
||||
"type": GETDNS_RRTYPE_A
|
||||
},
|
||||
{
|
||||
"class": 1,
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for www.google.com.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv4_address": <bindata of 0x4a7d8367>,
|
||||
"rdata_raw": <bindata of 0x4a7d8367>
|
||||
"ipv4_address": <bindata for 74.125.230.83>,
|
||||
"rdata_raw": <bindata of 0x4a7de653>
|
||||
},
|
||||
"ttl": 300,
|
||||
"type": GETDNS_RRTYPE_A
|
||||
},
|
||||
{
|
||||
"class": 1,
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for www.google.com.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv4_address": <bindata of 0x4a7d836a>,
|
||||
"rdata_raw": <bindata of 0x4a7d836a>
|
||||
},
|
||||
"ttl": 300,
|
||||
"type": GETDNS_RRTYPE_A
|
||||
},
|
||||
{
|
||||
"class": 1,
|
||||
"name": <bindata for www.google.com.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv4_address": <bindata of 0x4a7d8369>,
|
||||
"rdata_raw": <bindata of 0x4a7d8369>
|
||||
"ipv4_address": <bindata for 74.125.230.84>,
|
||||
"rdata_raw": <bindata of 0x4a7de654>
|
||||
},
|
||||
"ttl": 300,
|
||||
"type": GETDNS_RRTYPE_A
|
||||
}
|
||||
],
|
||||
"answer_type": 800,
|
||||
"answer_type": GETDNS_NAMETYPE_DNS,
|
||||
"authority": [],
|
||||
"canonical_name": <bindata of "www.google.com.">,
|
||||
"header":
|
||||
{
|
||||
"aa": 0,
|
||||
"ad": 0,
|
||||
"ancount": 6,
|
||||
"ancount": 5,
|
||||
"arcount": 0,
|
||||
"cd": 0,
|
||||
"id": 0,
|
||||
"id": 45440,
|
||||
"nscount": 0,
|
||||
"opcode": 0,
|
||||
"opcode": GETDNS_OPCODE_QUERY,
|
||||
"qdcount": 1,
|
||||
"qr": 1,
|
||||
"ra": 1,
|
||||
"rcode": 0,
|
||||
"rcode": GETDNS_RCODE_NOERROR,
|
||||
"rd": 1,
|
||||
"tc": 0,
|
||||
"z": 0
|
||||
},
|
||||
"question":
|
||||
{
|
||||
"qclass": 1,
|
||||
"qclass": GETDNS_RRCLASS_IN,
|
||||
"qname": <bindata for www.google.com.>,
|
||||
"qtype": 1
|
||||
"qtype": GETDNS_RRTYPE_A
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -143,18 +128,18 @@ The packet {
|
|||
"answer":
|
||||
[
|
||||
{
|
||||
"class": 1,
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for www.google.com.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv6_address": <bindata of 0x2607f8b0400c0c030000000000000068>,
|
||||
"rdata_raw": <bindata of 0x2607f8b0400c0c030000000000000068>
|
||||
"ipv6_address": <bindata for 2a00:1450:4009:800::1014>,
|
||||
"rdata_raw": <bindata of 0x2a001450400908000000000000001014>
|
||||
},
|
||||
"ttl": 300,
|
||||
"type": GETDNS_RRTYPE_AAAA
|
||||
}
|
||||
],
|
||||
"answer_type": 800,
|
||||
"answer_type": GETDNS_NAMETYPE_DNS,
|
||||
"authority": [],
|
||||
"canonical_name": <bindata of "www.google.com.">,
|
||||
"header":
|
||||
|
@ -164,86 +149,244 @@ The packet {
|
|||
"ancount": 1,
|
||||
"arcount": 0,
|
||||
"cd": 0,
|
||||
"id": 0,
|
||||
"id": 60320,
|
||||
"nscount": 0,
|
||||
"opcode": 0,
|
||||
"opcode": GETDNS_OPCODE_QUERY,
|
||||
"qdcount": 1,
|
||||
"qr": 1,
|
||||
"ra": 1,
|
||||
"rcode": 0,
|
||||
"rcode": GETDNS_RCODE_NOERROR,
|
||||
"rd": 1,
|
||||
"tc": 0,
|
||||
"z": 0
|
||||
},
|
||||
"question":
|
||||
{
|
||||
"qclass": 1,
|
||||
"qclass": GETDNS_RRCLASS_IN,
|
||||
"qname": <bindata for www.google.com.>,
|
||||
"qtype": 28
|
||||
"qtype": GETDNS_RRTYPE_AAAA
|
||||
}
|
||||
}
|
||||
],
|
||||
"status": 900
|
||||
"status": GETDNS_RESPSTATUS_GOOD
|
||||
}
|
||||
The packet {
|
||||
"answer_type": 800,
|
||||
"canonical_name": <bindata of "www.google.com.">,
|
||||
"answer_type": GETDNS_NAMETYPE_DNS,
|
||||
"canonical_name": <bindata of "_xmpp-client._tcp.jabber.com.">,
|
||||
"just_address_answers": [],
|
||||
"replies_full":
|
||||
[
|
||||
<bindata of 0x00008180000100000001000103777777...>
|
||||
<bindata of 0xad6f818000010001000200020c5f786d...>
|
||||
],
|
||||
"replies_tree":
|
||||
[
|
||||
{
|
||||
"additional":
|
||||
[
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for denjab2.jabber.com.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv4_address": <bindata for 216.24.133.14>,
|
||||
"rdata_raw": <bindata of 0xd818850e>
|
||||
},
|
||||
"ttl": 85567,
|
||||
"type": GETDNS_RRTYPE_A
|
||||
}
|
||||
],
|
||||
"answer":
|
||||
[
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for _xmpp-client._tcp.jabber.com.>,
|
||||
"rdata":
|
||||
{
|
||||
"port": 5222,
|
||||
"priority": 10,
|
||||
"rdata_raw": <bindata of 0x000a000014660764656e6a616232066a...>,
|
||||
"target": <bindata for denjab2.jabber.com.>,
|
||||
"weight": 0
|
||||
},
|
||||
"ttl": 6367,
|
||||
"type": GETDNS_RRTYPE_SRV
|
||||
}
|
||||
],
|
||||
"answer_type": GETDNS_NAMETYPE_DNS,
|
||||
"authority":
|
||||
[
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for jabber.com.>,
|
||||
"rdata":
|
||||
{
|
||||
"nsdname": <bindata for ns1.as13445.net.>,
|
||||
"rdata_raw": <bindata for ns1.as13445.net.>
|
||||
},
|
||||
"ttl": 85567,
|
||||
"type": GETDNS_RRTYPE_NS
|
||||
},
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for jabber.com.>,
|
||||
"rdata":
|
||||
{
|
||||
"nsdname": <bindata for ns2.as13445.net.>,
|
||||
"rdata_raw": <bindata for ns2.as13445.net.>
|
||||
},
|
||||
"ttl": 85567,
|
||||
"type": GETDNS_RRTYPE_NS
|
||||
}
|
||||
],
|
||||
"canonical_name": <bindata of "_xmpp-client._tcp.jabber.com.">,
|
||||
"header":
|
||||
{
|
||||
"aa": 0,
|
||||
"ad": 0,
|
||||
"ancount": 1,
|
||||
"arcount": 1,
|
||||
"cd": 0,
|
||||
"id": 44399,
|
||||
"nscount": 2,
|
||||
"opcode": GETDNS_OPCODE_QUERY,
|
||||
"qdcount": 1,
|
||||
"qr": 1,
|
||||
"ra": 1,
|
||||
"rcode": GETDNS_RCODE_NOERROR,
|
||||
"rd": 1,
|
||||
"tc": 0,
|
||||
"z": 0
|
||||
},
|
||||
"question":
|
||||
{
|
||||
"qclass": GETDNS_RRCLASS_IN,
|
||||
"qname": <bindata for _xmpp-client._tcp.jabber.com.>,
|
||||
"qtype": GETDNS_RRTYPE_SRV
|
||||
}
|
||||
}
|
||||
],
|
||||
"status": GETDNS_RESPSTATUS_GOOD
|
||||
}
|
||||
The packet {
|
||||
"answer_type": GETDNS_NAMETYPE_DNS,
|
||||
"canonical_name": <bindata of "www.google.com.">,
|
||||
"just_address_answers":
|
||||
[
|
||||
{
|
||||
"address_data": <bindata for 74.125.230.81>,
|
||||
"address_type": <bindata of "IPv4">
|
||||
},
|
||||
{
|
||||
"address_data": <bindata for 74.125.230.80>,
|
||||
"address_type": <bindata of "IPv4">
|
||||
},
|
||||
{
|
||||
"address_data": <bindata for 74.125.230.82>,
|
||||
"address_type": <bindata of "IPv4">
|
||||
},
|
||||
{
|
||||
"address_data": <bindata for 74.125.230.83>,
|
||||
"address_type": <bindata of "IPv4">
|
||||
},
|
||||
{
|
||||
"address_data": <bindata for 74.125.230.84>,
|
||||
"address_type": <bindata of "IPv4">
|
||||
}
|
||||
],
|
||||
"replies_full":
|
||||
[
|
||||
<bindata of 0x6f2c8180000100050000000103777777...>
|
||||
],
|
||||
"replies_tree":
|
||||
[
|
||||
{
|
||||
"additional": [],
|
||||
"answer": [],
|
||||
"answer_type": 800,
|
||||
"authority":
|
||||
"answer":
|
||||
[
|
||||
{
|
||||
"class": 1,
|
||||
"name": <bindata for google.com.>,
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for www.google.com.>,
|
||||
"rdata":
|
||||
{
|
||||
"expire": 300,
|
||||
"mname": <bindata for ns1.google.com.>,
|
||||
"rdata_raw": <bindata of 0x036e733106676f6f676c6503636f6d00...>,
|
||||
"refresh": 1800,
|
||||
"retry": 1209600,
|
||||
"rname": <bindata for dns-admin.google.com.>,
|
||||
"serial": 1546121
|
||||
"ipv4_address": <bindata for 74.125.230.81>,
|
||||
"rdata_raw": <bindata of 0x4a7de651>
|
||||
},
|
||||
"ttl": 60,
|
||||
"type": GETDNS_RRTYPE_SOA
|
||||
"ttl": 300,
|
||||
"type": GETDNS_RRTYPE_A
|
||||
},
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for www.google.com.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv4_address": <bindata for 74.125.230.80>,
|
||||
"rdata_raw": <bindata of 0x4a7de650>
|
||||
},
|
||||
"ttl": 300,
|
||||
"type": GETDNS_RRTYPE_A
|
||||
},
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for www.google.com.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv4_address": <bindata for 74.125.230.82>,
|
||||
"rdata_raw": <bindata of 0x4a7de652>
|
||||
},
|
||||
"ttl": 300,
|
||||
"type": GETDNS_RRTYPE_A
|
||||
},
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for www.google.com.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv4_address": <bindata for 74.125.230.83>,
|
||||
"rdata_raw": <bindata of 0x4a7de653>
|
||||
},
|
||||
"ttl": 300,
|
||||
"type": GETDNS_RRTYPE_A
|
||||
},
|
||||
{
|
||||
"class": GETDNS_RRCLASS_IN,
|
||||
"name": <bindata for www.google.com.>,
|
||||
"rdata":
|
||||
{
|
||||
"ipv4_address": <bindata for 74.125.230.84>,
|
||||
"rdata_raw": <bindata of 0x4a7de654>
|
||||
},
|
||||
"ttl": 300,
|
||||
"type": GETDNS_RRTYPE_A
|
||||
}
|
||||
],
|
||||
"answer_type": GETDNS_NAMETYPE_DNS,
|
||||
"authority": [],
|
||||
"canonical_name": <bindata of "www.google.com.">,
|
||||
"header":
|
||||
{
|
||||
"aa": 0,
|
||||
"ad": 0,
|
||||
"ancount": 0,
|
||||
"ancount": 5,
|
||||
"arcount": 0,
|
||||
"cd": 0,
|
||||
"id": 0,
|
||||
"nscount": 1,
|
||||
"opcode": 0,
|
||||
"id": 28460,
|
||||
"nscount": 0,
|
||||
"opcode": GETDNS_OPCODE_QUERY,
|
||||
"qdcount": 1,
|
||||
"qr": 1,
|
||||
"ra": 1,
|
||||
"rcode": 0,
|
||||
"rcode": GETDNS_RCODE_NOERROR,
|
||||
"rd": 1,
|
||||
"tc": 0,
|
||||
"z": 0
|
||||
},
|
||||
"question":
|
||||
{
|
||||
"qclass": 1,
|
||||
"qclass": GETDNS_RRCLASS_IN,
|
||||
"qname": <bindata for www.google.com.>,
|
||||
"qtype": 33
|
||||
"qtype": GETDNS_RRTYPE_A
|
||||
}
|
||||
}
|
||||
],
|
||||
"status": 900
|
||||
"status": GETDNS_RESPSTATUS_GOOD
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue