These patches have been in my tree for a long time...I'm hoping to
get them cleaned up properly and pushed upstream.

I know that the numbers need to change to be consecutive with the
current upstream code.

Aside from that, what sorts of changes are needed?  I'll send
as a real git patch when it is closer to right.

Thanks,
Ben

diff --git a/include/curl/curl.h b/include/curl/curl.h
index 5b39a24..bdcc745 100644
--- a/include/curl/curl.h
+++ b/include/curl/curl.h
@@ -1536,7 +1536,23 @@ typedef enum {
   /* set the SMTP auth originator */
   CINIT(MAIL_AUTH, OBJECTPOINT, 217),

+  /* Set the interface string for c-ares (DNS)
+   * to use as outgoing network interface */
+  CINIT(DNS_INTERFACE, OBJECTPOINT, 2011),
+
+  /* Set the local IPv4 address for c-ares (DNS)
+   * to use for outgoing connections.
+   * Host-byte-order.
+   */
+  CINIT(DNS_LOCAL_IP4, LONG, 2012),
+
+  /* Set the local IPv6 address for c-ares (DNS)
+   * to use for outgoing connections.
+   * 16-byte unsigned char*
+   */
+  CINIT(DNS_LOCAL_IP6, OBJECTPOINT, 2013),
+
   CURLOPT_LASTENTRY /* the last unused */
 } CURLoption;

diff --git a/lib/url.c b/lib/url.c
index a781798..0fa965f 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -80,6 +80,10 @@ void idn_free (void *ptr);
 int curl_win32_idn_to_ascii(const char *in, char **out);
 #endif  /* USE_LIBIDN */

+#ifdef USE_ARES
+#include "ares.h"
+#endif
+
 #include "urldata.h"
 #include "netrc.h"

@@ -854,6 +858,39 @@ CURLcode Curl_setopt(struct SessionHandle *data, 
CURLoption option,
     arg = va_arg(param, long);
     data->set.global_dns_cache = (0 != arg)?TRUE:FALSE;
     break;
+
+#ifdef USE_ARES
+  case CURLOPT_DNS_INTERFACE:
+    /*
+     * Set what interface or address/hostname to bind the socket to when
+     * performing DNS operations.
+     */
+    ares_set_local_dev((ares_channel)data->state.resolver,
+                       va_arg(param, char *));
+    break;
+  case CURLOPT_DNS_LOCAL_IP4:
+    /*
+     * Set the IPv4 source address for DNS operations.
+     */
+    ares_set_local_ip4((ares_channel)data->state.resolver,
+                       va_arg(param, uint32_t));
+    break;
+  case CURLOPT_DNS_LOCAL_IP6:
+    /*
+     * Set the IPv6 source address for DNS operations.
+     */
+    ares_set_local_ip6((ares_channel)data->state.resolver,
+                       va_arg(param, unsigned char*));
+    break;
+#else
+  case CURLOPT_DNS_INTERFACE:
+  case CURLOPT_DNS_LOCAL_IP4:
+  case CURLOPT_DNS_LOCAL_IP6:
+    /* TODO:  Should we return an error here, or just silently do nothing? */
+    result = CURLE_FAILED_INIT;
+    break;
+#endif
+
   case CURLOPT_SSL_CIPHER_LIST:
     /* set a list of cipher we want to use in the SSL connection */
     result = setstropt(&data->set.str[STRING_SSL_CIPHER_LIST],


--
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to