Menu

#6 dns mx query support

feature
open
nobody
General (31)
5
2008-03-21
2008-03-21
No

originally implemented for 1.4.1-beta, applies and works ok for 1.4.2 as well, being used in production environments.

few libevent users asked when it will be included in distro so im posting the patch here

---------

clean patch against 1.4.2-rc src tree:
sv-fe41s:~/build/levent/d/libevent-1.4.2-rc# patch -p1 < ../libevent-1.4.2-rc_dnsmx.diff
patching file evdns.c
patching file evdns.h
patching file test/regress_dns.c

------------------

regress tests grepped output:

sv-fe41s:~/build/levent/d/libevent-1.4.2-rc# ./test/regress 2>&1 | grep MX
MX DNS resolve: type: 4, count: 4, ttl: 1745: test_domain=aol.com,rr_count=4, first rr: pri=15,mxhost=mailin-02.mx.aol.com OK
sv-fe41s:~/build/levent/d/libevent-1.4.2-rc#

-------------------

howto use it:
..
...
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];
};

Discussion

  • adrian ilarion ciobanu

    diff output against 1.4.2-rc src tree

     
  • Nick Mathewson

    Nick Mathewson - 2008-04-28

    Logged In: YES
    user_id=499
    Originator: NO

    I'd be interested in doing this in the context of a more general approach that allows arbitrary DNS queries to be generated. I worry that if we do a MX-query function, we'll soon have queries for all the other possible query types, and then feel stupid that we didn't provide functions for queries with *multiple* questions, and so on.

     
  • Nick Mathewson

    Nick Mathewson - 2010-01-15

    I should be more constructive than that:

    There are lots of DNS record types. We should be able to query arbitrary records, not just have one function for every kind of record we can think of.

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.