]> granicus.if.org Git - libevent/commitdiff
dns-example: add CNAME support
authorAzat Khuzhin <azat@libevent.org>
Mon, 24 May 2021 18:03:58 +0000 (21:03 +0300)
committerAzat Khuzhin <azat@libevent.org>
Mon, 24 May 2021 18:03:58 +0000 (21:03 +0300)
sample/dns-example.c

index 2d07c3874bcaada1b376e74bc10ad5f4f10857a9..87221fdccaa7e25148aa28effb33acb442313741 100644 (file)
@@ -60,6 +60,11 @@ main_callback(int result, char type, int count, int ttl,
                          void *addrs, void *orig) {
        char *n = (char*)orig;
        int i;
+
+       if (type == DNS_CNAME) {
+               printf("%s: %s (CNAME)\n", n, (char*)addrs);
+       }
+
        for (i = 0; i < count; ++i) {
                if (type == DNS_IPv4_A) {
                        printf("%s: %s\n", n, debug_ntoa(((u32*)addrs)[i]));
@@ -252,7 +257,7 @@ main(int c, char **v) {
                            gai_callback, v[optind]);
                } else {
                        fprintf(stderr, "resolving (fwd) %s...\n",v[optind]);
-                       evdns_base_resolve_ipv4(evdns_base, v[optind], 0, main_callback, v[optind]);
+                       evdns_base_resolve_ipv4(evdns_base, v[optind], DNS_CNAME_CALLBACK, main_callback, v[optind]);
                }
        }
        fflush(stdout);