From a5f1e659d52872a499a5744870cb3e6ff382642f Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 25 Jul 2023 16:57:41 +0100 Subject: [PATCH] curl: Add ipresolve option Allows you to force IPv4 or IPv6. (cherry picked from commit d1b27c97f7fac00ee452a1d1b05805ee7145a49c) --- plugins/curl/curl.c | 15 +++++++++++++++ plugins/curl/curldefs.h | 1 + plugins/curl/nbdkit-curl-plugin.pod | 14 ++++++++++++++ plugins/curl/pool.c | 2 ++ 4 files changed, 32 insertions(+) diff --git a/plugins/curl/curl.c b/plugins/curl/curl.c index 425f1d90..91fa65fb 100644 --- a/plugins/curl/curl.c +++ b/plugins/curl/curl.c @@ -68,6 +68,7 @@ struct curl_slist *headers = NULL; const char *header_script = NULL; unsigned header_script_renew = 0; long http_version = CURL_HTTP_VERSION_NONE; +long ipresolve = CURL_IPRESOLVE_WHATEVER; char *password = NULL; #ifndef HAVE_CURLOPT_PROTOCOLS_STR long protocols = CURLPROTO_ALL; @@ -314,6 +315,19 @@ curl_config (const char *key, const char *value) } } + else if (strcmp (key, "ipresolve") == 0) { + if (strcmp (value, "any") == 0 || strcmp (value, "whatever") == 0) + ipresolve = CURL_IPRESOLVE_WHATEVER; + else if (strcmp (value, "v4") == 0 || strcmp (value, "4") == 0) + ipresolve = CURL_IPRESOLVE_V4; + else if (strcmp (value, "v6") == 0 || strcmp (value, "6") == 0) + ipresolve = CURL_IPRESOLVE_V6; + else { + nbdkit_error ("unknown ipresolve: %s", value); + return -1; + } + } + else if (strcmp (key, "password") == 0) { free (password); if (nbdkit_read_password (value, &password) == -1) @@ -495,6 +509,7 @@ curl_config_complete (void) "header-script=