aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Greear <greearb@candelatech.com>2013-02-09 13:18:02 -0800
committerDaniel Stenberg <daniel@haxx.se>2013-09-12 21:11:47 +0200
commit32352ed6adddcb9275eb6f19f8aaeadf9476b0fd (patch)
treea1add10a47b3540bc1400d05e46b6b5eb5f13a9a
parentdf69440d05f1133a9053e19a9bf576c8b13514b9 (diff)
curl: Add support for various DNS binding options.
(Passed on to c-ares.) Allows something like this: curl --dns-interface sta8 --dns-ipv4-addr 8.8.1.111 --interface sta8 \ --localaddr 8.8.1.111 --dns-servers 8.8.8.1 www.google.com Signed-off-by: Ben Greear <greearb@candelatech.com>
-rw-r--r--src/tool_cfgable.c6
-rw-r--r--src/tool_cfgable.h5
-rw-r--r--src/tool_getparam.c21
-rw-r--r--src/tool_help.c5
-rw-r--r--src/tool_operate.c7
5 files changed, 39 insertions, 5 deletions
diff --git a/src/tool_cfgable.c b/src/tool_cfgable.c
index 1c55c296f..f9fd55283 100644
--- a/src/tool_cfgable.c
+++ b/src/tool_cfgable.c
@@ -57,6 +57,11 @@ void free_config_fields(struct Configurable *config)
Curl_safefree(config->proxyuserpwd);
Curl_safefree(config->proxy);
+ Curl_safefree(config->dns_ipv6_addr);
+ Curl_safefree(config->dns_ipv4_addr);
+ Curl_safefree(config->dns_interface);
+ Curl_safefree(config->dns_servers);
+
Curl_safefree(config->noproxy);
Curl_safefree(config->mail_from);
@@ -127,4 +132,3 @@ void free_config_fields(struct Configurable *config)
Curl_safefree(config->libcurl);
}
-
diff --git a/src/tool_cfgable.h b/src/tool_cfgable.h
index a12bdcd32..07355b8f4 100644
--- a/src/tool_cfgable.h
+++ b/src/tool_cfgable.h
@@ -66,6 +66,10 @@ struct Configurable {
char *range;
long low_speed_limit;
long low_speed_time;
+ 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 */
@@ -214,4 +218,3 @@ struct Configurable {
void free_config_fields(struct Configurable *config);
#endif /* HEADER_CURL_TOOL_CFGABLE_H */
-
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
index a6a14c0d5..d23084f57 100644
--- a/src/tool_getparam.c
+++ b/src/tool_getparam.c
@@ -73,11 +73,14 @@ static const struct LongShort aliases[]= {
/* all these ones, starting with "*" or "$" as a short-option have *no*
short option to mention. */
{"*", "url", TRUE},
+ {"*4", "dns-ipv4-addr", TRUE},
+ {"*6", "dns-ipv6-addr", TRUE},
{"*a", "random-file", TRUE},
{"*b", "egd-file", TRUE},
{"*B", "bearer", TRUE},
{"*c", "connect-timeout", TRUE},
{"*d", "ciphers", TRUE},
+ {"*D", "dns-interface", TRUE},
{"*e", "disable-epsv", FALSE},
{"*E", "epsv", FALSE},
/* 'epsv' made like this to make --no-epsv and --epsv to work
@@ -85,6 +88,7 @@ static const struct LongShort aliases[]= {
#ifdef USE_ENVIRONMENT
{"*f", "environment", FALSE},
#endif
+ {"*F", "dns-servers", TRUE},
{"*g", "trace", TRUE},
{"*h", "trace-ascii", TRUE},
{"*i", "limit-rate", TRUE},
@@ -496,6 +500,14 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
switch(letter) {
case '*': /* options without a short option */
switch(subletter) {
+ case '4': /* --dns-ipv4-addr */
+ /* addr in dot notation */
+ GetStr(&config->dns_ipv4_addr, nextarg);
+ break;
+ case '6': /* --dns-ipv6-addr */
+ /* addr in dot notation */
+ GetStr(&config->dns_ipv6_addr, nextarg);
+ break;
case 'a': /* random-file */
GetStr(&config->random_file, nextarg);
break;
@@ -513,6 +525,10 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
case 'd': /* ciphers */
GetStr(&config->cipher_list, nextarg);
break;
+ case 'D': /* --dns-interface */
+ /* interface name */
+ GetStr(&config->dns_interface, nextarg);
+ break;
case 'e': /* --disable-epsv */
config->disable_epsv = toggle;
break;
@@ -524,6 +540,10 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
config->writeenv = toggle;
break;
#endif
+ case 'F': /* --dns-servers */
+ /* IP addrs of DNS servers */
+ GetStr(&config->dns_servers, nextarg);
+ break;
case 'g': /* --trace */
GetStr(&config->trace_dump, nextarg);
if(config->tracetype && (config->tracetype != TRACE_BIN))
@@ -1802,4 +1822,3 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
return PARAM_OK;
}
-
diff --git a/src/tool_help.c b/src/tool_help.c
index 5ae39af77..81ac89726 100644
--- a/src/tool_help.c
+++ b/src/tool_help.c
@@ -70,6 +70,10 @@ static const char *const helptext[] = {
" --digest Use HTTP Digest Authentication (H)",
" --disable-eprt Inhibit using EPRT or LPRT (F)",
" --disable-epsv Inhibit using EPSV (F)",
+ " --dns-servers DNS server addrs to use: 1.1.1.1;2.2.2.2",
+ " --dns-interface Interface to use for DNS requests",
+ " --dns-ipv4-addr IPv4 address to use for DNS requests, dot notation",
+ " --dns-ipv6-addr IPv6 address to use for DNS requests, dot notation",
" -D, --dump-header FILE Write the headers to this file",
" --egd-file FILE EGD socket path for random data (SSL)",
" --engine ENGINE Crypto engine (SSL). \"--engine list\" for list",
@@ -246,4 +250,3 @@ void tool_help(void)
#endif
}
}
-
diff --git a/src/tool_operate.c b/src/tool_operate.c
index aa5fc6908..ba077973e 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -1239,6 +1239,12 @@ 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.33.0: */
+ my_setopt_str(curl, CURLOPT_DNS_INTERFACE, config->dns_interface);
+ my_setopt_str(curl, CURLOPT_DNS_LOCAL_IP4, config->dns_ipv4_addr);
+ my_setopt_str(curl, CURLOPT_DNS_LOCAL_IP6, config->dns_ipv6_addr);
+
/* new in libcurl 7.6.2: */
my_setopt_slist(curl, CURLOPT_TELNETOPTIONS, config->telnet_options);
@@ -1899,4 +1905,3 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
return res;
}
-