mirror of
https://github.com/moparisthebest/curl
synced 2024-12-23 00:28:48 -05:00
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>
This commit is contained in:
parent
df69440d05
commit
32352ed6ad
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user