cURL / Mailing Lists / curl-library / Single Mail

curl-library

[PATCH] Add support for setting name servers

From: Jason Glasgow <jglasgow_at_chromium.org>
Date: Tue, 12 Apr 2011 11:34:28 -0400

---
 docs/libcurl/curl_easy_setopt.3 |   12 ++++++++++++
 include/curl/curl.h             |    3 +++
 lib/url.c                       |   24 ++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/docs/libcurl/curl_easy_setopt.3 b/docs/libcurl/curl_easy_setopt.3
index 31464bf..e072f51 100644
--- a/docs/libcurl/curl_easy_setopt.3
+++ b/docs/libcurl/curl_easy_setopt.3
@@ -2045,6 +2045,18 @@ resolves, by including a string in the linked
list that uses the format
 and port number must exactly match what was already added previously.
 (Added in 7.21.3)
+.IP CURLOPT_DNS_SERVERS
+
+Set the list of DNS servers to be used instead of the system default.
+The format of the dns servers option is:
+
+host[:port][,host[:port]]...
+
+For example:
+
+192.168.1.100,192.168.1.101,3.4.5.6
+
+(Added in 7.22.1)
 .SH SSL and SECURITY OPTIONS
 .IP CURLOPT_SSLCERT
 Pass a pointer to a zero terminated string as parameter. The string should be
diff --git a/include/curl/curl.h b/include/curl/curl.h
index f4aa17f..8f82348 100644
--- a/include/curl/curl.h
+++ b/include/curl/curl.h
@@ -1486,6 +1486,9 @@ typedef enum {
   /* allow GSSAPI credential delegation */
   CINIT(GSSAPI_DELEGATION, LONG, 210),
+  /* Set the name servers to use for DNS resolution */
+  CINIT(DNS_SERVERS, OBJECTPOINT, 211),
+
   CURLOPT_LASTENTRY /* the last unused */
 } CURLoption;
diff --git a/lib/url.c b/lib/url.c
index 4bc82a6..4d15139 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -2531,6 +2531,30 @@ CURLcode Curl_setopt(struct SessionHandle
*data, CURLoption option,
       data->set.ssl.authtype = CURL_TLSAUTH_NONE;
     break;
 #endif
+  case CURLOPT_DNS_SERVERS:
+#if defined(USE_ARES) && (ARES_VERSION >= 0x010704)
+    {
+      int ares_result;
+      ares_result = ares_set_servers_csv(data->state.resolver,
+                                         va_arg(param, char *));
+      switch(ares_result) {
+        case ARES_SUCCESS:
+          break;
+        case ARES_ENOMEM:
+          result = CURLE_OUT_OF_MEMORY;
+          break;
+        case ARES_ENOTINITIALIZED:
+        case ARES_ENODATA:
+        case ARES_EBADSTR:
+        default:
+          result = CURLE_BAD_FUNCTION_ARGUMENT;
+          break;
+      }
+#else
+    result = CURLE_NOT_BUILT_IN;
+#endif
+    break;
+
   default:
     /* unknown tag and its companion, just ignore: */
     result = CURLE_UNKNOWN_OPTION;
-- 
1.7.3.1
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2001-09-17