mirror of
https://github.com/curl/curl.git
synced 2026-08-25 02:03:36 +03:00
lib: provide a getaddrinfo wrapper
This uses c-ares under the hood and supports the CURL_DNS_SERVER environment variable - for debug builds only. The getaddrinfo() replacement function is only used if CURL_DNS_SERVER is set to make a debug build work more like a release version without the variable set. 'override-dns' is a new feature for the test suite when curl can be told to use a dedicated DNS server, and test 2102 is the first to require this. Requires c-ares 1.26.0 or later. Closes #17134
This commit is contained in:
parent
da33c1e349
commit
e0ebc3ff13
8 changed files with 335 additions and 11 deletions
|
|
@ -50,6 +50,7 @@
|
|||
#include <stddef.h>
|
||||
|
||||
#include "curl_addrinfo.h"
|
||||
#include "fake_addrinfo.h"
|
||||
#include "inet_pton.h"
|
||||
#include "warnless.h"
|
||||
/* The last 3 #include files should be in this order */
|
||||
|
|
@ -508,6 +509,14 @@ curl_dbg_freeaddrinfo(struct addrinfo *freethis,
|
|||
source, line, (void *)freethis);
|
||||
#ifdef USE_LWIPSOCK
|
||||
lwip_freeaddrinfo(freethis);
|
||||
#elif defined(USE_FAKE_GETADDRINFO)
|
||||
{
|
||||
const char *env = getenv("CURL_DNS_SERVER");
|
||||
if(env)
|
||||
r_freeaddrinfo(freethis);
|
||||
else
|
||||
freeaddrinfo(freethis);
|
||||
}
|
||||
#else
|
||||
freeaddrinfo(freethis);
|
||||
#endif
|
||||
|
|
@ -526,13 +535,20 @@ curl_dbg_freeaddrinfo(struct addrinfo *freethis,
|
|||
|
||||
int
|
||||
curl_dbg_getaddrinfo(const char *hostname,
|
||||
const char *service,
|
||||
const struct addrinfo *hints,
|
||||
struct addrinfo **result,
|
||||
int line, const char *source)
|
||||
const char *service,
|
||||
const struct addrinfo *hints,
|
||||
struct addrinfo **result,
|
||||
int line, const char *source)
|
||||
{
|
||||
#ifdef USE_LWIPSOCK
|
||||
int res = lwip_getaddrinfo(hostname, service, hints, result);
|
||||
#elif defined(USE_FAKE_GETADDRINFO)
|
||||
int res;
|
||||
const char *env = getenv("CURL_DNS_SERVER");
|
||||
if(env)
|
||||
res = r_getaddrinfo(hostname, service, hints, result);
|
||||
else
|
||||
res = getaddrinfo(hostname, service, hints, result);
|
||||
#else
|
||||
int res = getaddrinfo(hostname, service, hints, result);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue