You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
3.9 KiB
114 lines
3.9 KiB
1 year ago
|
From 55e55ea986ef5fed595bb5a4203e8734d79f1474 Mon Sep 17 00:00:00 2001
|
||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||
|
Date: Tue, 25 Jul 2023 17:36:31 +0100
|
||
|
Subject: [PATCH] curl: Add resolve option
|
||
|
|
||
|
This allows you to force a particular IP address for the URL host
|
||
|
name.
|
||
|
|
||
|
(cherry picked from commit 4f0989cbf0e9eeb959879b1c82b52940f6c5c3cc)
|
||
|
---
|
||
|
plugins/curl/curl.c | 12 ++++++++++++
|
||
|
plugins/curl/curldefs.h | 1 +
|
||
|
plugins/curl/nbdkit-curl-plugin.pod | 7 +++++++
|
||
|
plugins/curl/pool.c | 2 ++
|
||
|
4 files changed, 22 insertions(+)
|
||
|
|
||
|
diff --git a/plugins/curl/curl.c b/plugins/curl/curl.c
|
||
|
index 91fa65fb..381433fd 100644
|
||
|
--- a/plugins/curl/curl.c
|
||
|
+++ b/plugins/curl/curl.c
|
||
|
@@ -78,6 +78,7 @@ const char *protocols = NULL;
|
||
|
const char *proxy = NULL;
|
||
|
char *proxy_password = NULL;
|
||
|
const char *proxy_user = NULL;
|
||
|
+struct curl_slist *resolves = NULL;
|
||
|
bool sslverify = true;
|
||
|
const char *ssl_cipher_list = NULL;
|
||
|
long ssl_version = CURL_SSLVERSION_DEFAULT;
|
||
|
@@ -112,6 +113,8 @@ curl_unload (void)
|
||
|
curl_slist_free_all (headers);
|
||
|
free (password);
|
||
|
free (proxy_password);
|
||
|
+ if (resolves)
|
||
|
+ curl_slist_free_all (resolves);
|
||
|
scripts_unload ();
|
||
|
free_all_handles ();
|
||
|
curl_global_cleanup ();
|
||
|
@@ -356,6 +359,14 @@ curl_config (const char *key, const char *value)
|
||
|
else if (strcmp (key, "proxy-user") == 0)
|
||
|
proxy_user = value;
|
||
|
|
||
|
+ else if (strcmp (key, "resolve") == 0) {
|
||
|
+ resolves = curl_slist_append (headers, value);
|
||
|
+ if (resolves == NULL) {
|
||
|
+ nbdkit_error ("curl_slist_append: %m");
|
||
|
+ return -1;
|
||
|
+ }
|
||
|
+ }
|
||
|
+
|
||
|
else if (strcmp (key, "sslverify") == 0) {
|
||
|
r = nbdkit_parse_bool (value);
|
||
|
if (r == -1)
|
||
|
@@ -515,6 +526,7 @@ curl_config_complete (void)
|
||
|
"proxy=<PROXY> Set proxy URL.\n" \
|
||
|
"proxy-password=<PASSWORD> The proxy password.\n" \
|
||
|
"proxy-user=<USER> The proxy user.\n" \
|
||
|
+ "resolve=<HOST>:<PORT>:<ADDR> Custom host to IP address resolution.\n" \
|
||
|
"sslverify=false Do not verify SSL certificate of remote host.\n" \
|
||
|
"ssl-cipher-list=C1:C2:.. Specify TLS/SSL cipher suites to be used.\n" \
|
||
|
"ssl-version=<VERSION> Specify preferred TLS/SSL version.\n" \
|
||
|
diff --git a/plugins/curl/curldefs.h b/plugins/curl/curldefs.h
|
||
|
index 815be2e1..613cfed7 100644
|
||
|
--- a/plugins/curl/curldefs.h
|
||
|
+++ b/plugins/curl/curldefs.h
|
||
|
@@ -74,6 +74,7 @@ extern const char *proxy_user;
|
||
|
extern bool sslverify;
|
||
|
extern const char *ssl_cipher_list;
|
||
|
extern long ssl_version;
|
||
|
+extern struct curl_slist *resolves;
|
||
|
extern const char *tls13_ciphers;
|
||
|
extern bool tcp_keepalive;
|
||
|
extern bool tcp_nodelay;
|
||
|
diff --git a/plugins/curl/nbdkit-curl-plugin.pod b/plugins/curl/nbdkit-curl-plugin.pod
|
||
|
index e12ca197..a7315047 100644
|
||
|
--- a/plugins/curl/nbdkit-curl-plugin.pod
|
||
|
+++ b/plugins/curl/nbdkit-curl-plugin.pod
|
||
|
@@ -289,6 +289,12 @@ Set the proxy. See L<CURLOPT_PROXY(3)>.
|
||
|
|
||
|
Set the proxy username and password.
|
||
|
|
||
|
+=item B<resolve=>HOSTB<:>PORTB<:>ADDRESS
|
||
|
+
|
||
|
+Provide custom host name to IP address resolution. You can supply
|
||
|
+this option as many times as needed. See L<CURLOPT_RESOLVE(3)> for
|
||
|
+the full details of this option.
|
||
|
+
|
||
|
=item B<sslverify=false>
|
||
|
|
||
|
Don't verify the SSL certificate of the remote host.
|
||
|
@@ -574,6 +580,7 @@ L<CURLOPT_FOLLOWLOCATION(3)>,
|
||
|
L<CURLOPT_HTTPHEADER(3)>,
|
||
|
L<CURLOPT_IPRESOLVE(3)>,
|
||
|
L<CURLOPT_PROXY(3)>,
|
||
|
+L<CURLOPT_RESOLVE(3)>,
|
||
|
L<CURLOPT_SSL_CIPHER_LIST(3)>,
|
||
|
L<CURLOPT_SSLVERSION(3)>,
|
||
|
L<CURLOPT_TCP_KEEPALIVE(3)>,
|
||
|
diff --git a/plugins/curl/pool.c b/plugins/curl/pool.c
|
||
|
index f0c3cb4f..a6e2f9f5 100644
|
||
|
--- a/plugins/curl/pool.c
|
||
|
+++ b/plugins/curl/pool.c
|
||
|
@@ -283,6 +283,8 @@ allocate_handle (void)
|
||
|
curl_easy_setopt (ch->c, CURLOPT_SSL_VERIFYPEER, 0L);
|
||
|
curl_easy_setopt (ch->c, CURLOPT_SSL_VERIFYHOST, 0L);
|
||
|
}
|
||
|
+ if (resolves)
|
||
|
+ curl_easy_setopt (ch->c, CURLOPT_RESOLVE, resolves);
|
||
|
if (ssl_version != CURL_SSLVERSION_DEFAULT)
|
||
|
curl_easy_setopt (ch->c, CURLOPT_SSLVERSION, (long) ssl_version);
|
||
|
if (ssl_cipher_list)
|
||
|
--
|
||
|
2.39.3
|
||
|
|