ipfs: add options to disable

- CPPFLAGS: `-DCURL_DISABLE_IPFS`
- configure: `--disable-ipfs`
- cmake: `-DCURL_DISABLE_IPFS=ON`

Fixes #14824
Closes #14827
This commit is contained in:
Viktor Szakats 2024-09-08 12:26:45 +02:00
parent 8b42df3eb1
commit ce7d0d4137
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
12 changed files with 71 additions and 4 deletions

View file

@ -110,7 +110,9 @@ static void free_config_fields(struct OperationConfig *config)
config->url_get = NULL;
config->url_out = NULL;
#ifndef CURL_DISABLE_IPFS
Curl_safefree(config->ipfs_gateway);
#endif /* !CURL_DISABLE_IPFS */
Curl_safefree(config->doh_url);
Curl_safefree(config->cipher_list);
Curl_safefree(config->proxy_cipher_list);

View file

@ -130,7 +130,9 @@ struct OperationConfig {
struct getout *url_get; /* point to the node to fill in URL */
struct getout *url_out; /* point to the node to fill in outfile */
struct getout *url_ul; /* point to the node to fill in upload */
#ifndef CURL_DISABLE_IPFS
char *ipfs_gateway;
#endif /* !CURL_DISABLE_IPFS */
char *doh_url;
char *cipher_list;
char *proxy_cipher_list;

View file

@ -171,7 +171,9 @@ static const struct LongShort aliases[]= {
{"insecure", ARG_BOOL, 'k', C_INSECURE},
{"interface", ARG_STRG, ' ', C_INTERFACE},
{"ip-tos", ARG_STRG, ' ', C_IP_TOS},
#ifndef CURL_DISABLE_IPFS
{"ipfs-gateway", ARG_STRG, ' ', C_IPFS_GATEWAY},
#endif /* !CURL_DISABLE_IPFS */
{"ipv4", ARG_NONE, '4', C_IPV4},
{"ipv6", ARG_NONE, '6', C_IPV6},
{"json", ARG_STRG, ' ', C_JSON},
@ -1321,9 +1323,11 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
if(!err && (config->maxredirs < -1))
err = PARAM_BAD_NUMERIC;
break;
#ifndef CURL_DISABLE_IPFS
case C_IPFS_GATEWAY: /* --ipfs-gateway */
err = getstr(&config->ipfs_gateway, nextarg, DENY_BLANK);
break;
#endif /* !CURL_DISABLE_IPFS */
case C_PROXY_NTLM: /* --proxy-ntlm */
if(!feature_ntlm)
err = PARAM_LIBCURL_DOESNT_SUPPORT;

View file

@ -331,6 +331,7 @@ void tool_version_info(void)
printf("Release-Date: %s\n", LIBCURL_TIMESTAMP);
#endif
if(built_in_protos[0]) {
#ifndef CURL_DISABLE_IPFS
const char *insert = NULL;
/* we have ipfs and ipns support if libcurl has http support */
for(builtin = built_in_protos; *builtin; ++builtin) {
@ -345,16 +346,19 @@ void tool_version_info(void)
insert = *builtin;
}
}
#endif /* !CURL_DISABLE_IPFS */
printf("Protocols:");
for(builtin = built_in_protos; *builtin; ++builtin) {
/* Special case: do not list rtmp?* protocols.
They may only appear together with "rtmp" */
if(!curl_strnequal(*builtin, "rtmp", 4) || !builtin[0][4])
printf(" %s", *builtin);
#ifndef CURL_DISABLE_IPFS
if(insert && insert == *builtin) {
printf(" ipfs ipns");
insert = NULL;
}
#endif /* !CURL_DISABLE_IPFS */
}
puts(""); /* newline */
}

View file

@ -23,6 +23,7 @@
***************************************************************************/
#include "tool_setup.h"
#ifndef CURL_DISABLE_IPFS
#include "curlx.h"
#include "dynbuf.h"
@ -287,3 +288,4 @@ clean:
}
return result;
}
#endif /* !CURL_DISABLE_IPFS */

View file

@ -25,9 +25,11 @@
***************************************************************************/
#include "tool_setup.h"
#ifndef CURL_DISABLE_IPFS
#define MAX_GATEWAY_URL_LEN 10000
CURLcode ipfs_url_rewrite(CURLU *uh, const char *protocol, char **url,
struct OperationConfig *config);
#endif /* HEADER_CURL_TOOL_IPFS_H */
#endif /* !CURL_DISABLE_IPFS */

View file

@ -49,8 +49,10 @@ const char *proto_rtsp = NULL;
const char *proto_scp = NULL;
const char *proto_sftp = NULL;
const char *proto_tftp = NULL;
#ifndef CURL_DISABLE_IPFS
const char *proto_ipfs = "ipfs";
const char *proto_ipns = "ipns";
#endif /* !CURL_DISABLE_IPFS */
static struct proto_name_tokenp {
const char *proto_name;

View file

@ -793,6 +793,9 @@ static CURLcode url_proto(char **url,
CURLU_GUESS_SCHEME | CURLU_NON_SUPPORT_SCHEME) &&
!curl_url_get(uh, CURLUPART_SCHEME, &schemep,
CURLU_DEFAULT_SCHEME)) {
#ifdef CURL_DISABLE_IPFS
(void)config;
#else
if(curl_strequal(schemep, proto_ipfs) ||
curl_strequal(schemep, proto_ipns)) {
result = ipfs_url_rewrite(uh, schemep, url, config);
@ -805,6 +808,7 @@ static CURLcode url_proto(char **url,
config->synthetic_error = TRUE;
}
else
#endif /* !CURL_DISABLE_IPFS */
proto = proto_token(schemep);
curl_free(schemep);