Search code examples
cdnslibevent

libevent sent DNS request with mixed cases


Making a connection using libevent, the strange thing is that DNS request sent was for host "WWw.yahoo.COM". Here is the code snippet that caused it.

struct evhttp_connection * evcon = evhttp_connection_base_bufferevent_new(
        base, dns_base, bev,    "www.yahoo.com", port);

It doesn't seem to cause any problems on my application, just wonder if there is a reason why libevent needs to mix up the cases.

Thanks.


Solution

  • It's a security feature.

    randomize-case:INT If nonzero, we randomize the case on outgoing DNS requests and make sure that replies have the same case as our requests. This so-called "0x20 hack" can help prevent some otherwise simple active events against DNS. Defaults to 1.

    http://www.wangafu.net/~nickm/libevent-book/Ref9_dns.html

    If you would want to you can disable it using:

    evdns_base_set_option(base, "randomize-case", "0");