]> granicus.if.org Git - curl/commitdiff
curl: Fixed usage of DNS options when not using c-ares resolver
authorSteve Holme <steve_holme@hotmail.com>
Fri, 13 Sep 2013 17:50:11 +0000 (18:50 +0100)
committerSteve Holme <steve_holme@hotmail.com>
Fri, 13 Sep 2013 17:50:11 +0000 (18:50 +0100)
Commit 32352ed6adddcb introduced various DNS options, however, these
would cause curl to exit with CURLE_NOT_BUILT_IN when c-ares wasn't
being used as the backend resolver even if the options weren't set
by the user.

Additionally corrected some minor coding style errors from the same
commit.

src/tool_cfgable.h
src/tool_getparam.c
src/tool_operate.c

index 07355b8f4cfe1aecbe5f14e9d7c553efb112f2f0..2f9cd5afb73084be1346712dd66c1318ec692b14 100644 (file)
@@ -66,10 +66,10 @@ struct Configurable {
   char *range;
   long low_speed_limit;
   long low_speed_time;
-  chardns_servers;   /* dot notation: 1.1.1.1;2.2.2.2 */
-  chardns_interface; /* interface name */
-  chardns_ipv4_addr; /* dot notation */
-  chardns_ipv6_addr; /* dot notation */
+  char *dns_servers;   /* dot notation: 1.1.1.1;2.2.2.2 */
+  char *dns_interface; /* interface name */
+  char *dns_ipv4_addr; /* dot notation */
+  char *dns_ipv6_addr; /* dot notation */
   int showerror; /* -1 == unset, default => show errors
                     0 => -s is used to NOT show errors
                     1 => -S has been used to show errors */
index d23084f57a80cb865a95166715d4ff153cb7d565..583a8416277a980933273cf6f5c72265aa80338a 100644 (file)
@@ -80,7 +80,7 @@ static const struct LongShort aliases[]= {
   {"*B", "bearer",                   TRUE},
   {"*c", "connect-timeout",          TRUE},
   {"*d", "ciphers",                  TRUE},
-  {"*D", "dns-interface",                TRUE},
+  {"*D", "dns-interface",            TRUE},
   {"*e", "disable-epsv",             FALSE},
   {"*E", "epsv",                     FALSE},
          /* 'epsv' made like this to make --no-epsv and --epsv to work
index ba077973e2ae9a9856ec8f85691c6dd4b7156c4a..6615270e03f8725df6112ccf832001524be46dd7 100644 (file)
@@ -1239,10 +1239,16 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
           my_setopt(curl, CURLOPT_PROGRESSDATA, &progressbar);
         }
 
-        my_setopt_str(curl, CURLOPT_DNS_SERVERS, config->dns_servers);
+        /* new in libcurl 7.24.0: */
+        if(config->dns_servers)
+          my_setopt_str(curl, CURLOPT_DNS_SERVERS, config->dns_servers);
+
         /* new in libcurl 7.33.0: */
-        my_setopt_str(curl, CURLOPT_DNS_INTERFACE, config->dns_interface);
-        my_setopt_str(curl, CURLOPT_DNS_LOCAL_IP4, config->dns_ipv4_addr);
+        if(config->dns_interface)
+          my_setopt_str(curl, CURLOPT_DNS_INTERFACE, config->dns_interface);
+        if(config->dns_ipv4_addr)
+          my_setopt_str(curl, CURLOPT_DNS_LOCAL_IP4, config->dns_ipv4_addr);
+        if(config->dns_ipv6_addr)
         my_setopt_str(curl, CURLOPT_DNS_LOCAL_IP6, config->dns_ipv6_addr);
 
         /* new in libcurl 7.6.2: */