patch works against 1.4.2-rc source tree as well. regress tests come up OK
patch submitted to sourceforge libevent project
this patch was diffed against libevent 1.4.1-beta.
applying the patch: cd libevent-1.4.1-beta/ && wget -O - http://pub.mud.ro/~cia/files/libevent-1.4.1-beta-dns_mx.patch | patch -p1
make the source tree as usual
run the regress tests:
...
...
Simple DNS resolve: type: 1, count: 1, ttl: 300: 152.160.49.201 OK
IPv6 DNS resolve: type: 3, count: 1, ttl: 7200: 2610:a0:c779:b::d1ad:35b4 OK
Simple reverse DNS resolve: type: 2, count: 1, ttl: 10000: localhost.localdomain OK
MX DNS resolve: type: 4, count: 4, ttl: 2289: test_domain=aol.com,rr_count=4, first rr: pri=15,mxhost=mailin-01.mx.aol.com OK
...
...
...
...
evdns_resolve_mx(domain,DNS_QUERY_NO_SEARCH,process_mx2,(void *)domain);
...
...
/* your callback: */
static void process_mx2 (int result, char type, int count, int ttl, void *addresses, void *arg)
{
struct mx_rr *records = (struct mx_rr *)addresses;
int i = 0;
for (i = 0; i < count; i++) {
printf("%d %d %s\n", i, records[i].pri, records[i].host);
}
}
/* struct mx_rr is defined in evdns.h: */
struct mx_rr {
uint16_t pri;
char host[255];
};