2014-09-07 15:08:27 +00:00
|
|
|
/*
|
|
|
|
* s3fs - FUSE-based file system backed by Amazon S3
|
|
|
|
*
|
2017-05-07 11:24:17 +00:00
|
|
|
* Copyright(C) 2007 Randy Rizun <rrizun@gmail.com>
|
2014-09-07 15:08:27 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
2016-02-07 05:41:56 +00:00
|
|
|
|
2011-03-01 19:35:55 +00:00
|
|
|
#ifndef S3FS_CURL_H_
|
|
|
|
#define S3FS_CURL_H_
|
|
|
|
|
2020-08-22 12:40:53 +00:00
|
|
|
#include <curl/curl.h>
|
2021-08-03 22:36:32 +00:00
|
|
|
#include <map>
|
2023-07-27 00:12:28 +00:00
|
|
|
#include <memory>
|
2021-08-03 22:36:32 +00:00
|
|
|
#include <vector>
|
2016-04-22 06:57:31 +00:00
|
|
|
|
2022-07-30 03:06:47 +00:00
|
|
|
#include "autolock.h"
|
2020-08-22 12:40:53 +00:00
|
|
|
#include "metaheader.h"
|
|
|
|
#include "fdcache_page.h"
|
2018-11-15 00:48:57 +00:00
|
|
|
|
2019-03-22 10:47:42 +00:00
|
|
|
//----------------------------------------------
|
|
|
|
// Avoid dependency on libcurl version
|
|
|
|
//----------------------------------------------
|
|
|
|
// [NOTE]
|
|
|
|
// The following symbols (enum) depend on the version of libcurl.
|
|
|
|
// CURLOPT_TCP_KEEPALIVE 7.25.0 and later
|
|
|
|
// CURLOPT_SSL_ENABLE_ALPN 7.36.0 and later
|
|
|
|
// CURLOPT_KEEP_SENDING_ON_ERROR 7.51.0 and later
|
|
|
|
//
|
2021-11-02 12:16:48 +00:00
|
|
|
// s3fs uses these, if you build s3fs with the old libcurl,
|
2019-03-22 10:47:42 +00:00
|
|
|
// substitute the following symbols to avoid errors.
|
|
|
|
// If the version of libcurl linked at runtime is old,
|
|
|
|
// curl_easy_setopt results in an error(CURLE_UNKNOWN_OPTION) and
|
|
|
|
// a message is output.
|
|
|
|
//
|
|
|
|
#if defined(HAVE_CURLOPT_TCP_KEEPALIVE) && (HAVE_CURLOPT_TCP_KEEPALIVE == 1)
|
2020-08-22 12:40:53 +00:00
|
|
|
#define S3FS_CURLOPT_TCP_KEEPALIVE CURLOPT_TCP_KEEPALIVE
|
2019-03-22 10:47:42 +00:00
|
|
|
#else
|
2020-08-22 12:40:53 +00:00
|
|
|
#define S3FS_CURLOPT_TCP_KEEPALIVE static_cast<CURLoption>(213)
|
2019-03-22 10:47:42 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_CURLOPT_SSL_ENABLE_ALPN) && (HAVE_CURLOPT_SSL_ENABLE_ALPN == 1)
|
2020-08-22 12:40:53 +00:00
|
|
|
#define S3FS_CURLOPT_SSL_ENABLE_ALPN CURLOPT_SSL_ENABLE_ALPN
|
2019-03-22 10:47:42 +00:00
|
|
|
#else
|
2020-08-22 12:40:53 +00:00
|
|
|
#define S3FS_CURLOPT_SSL_ENABLE_ALPN static_cast<CURLoption>(226)
|
2019-03-22 10:47:42 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_CURLOPT_KEEP_SENDING_ON_ERROR) && (HAVE_CURLOPT_KEEP_SENDING_ON_ERROR == 1)
|
2020-08-22 12:40:53 +00:00
|
|
|
#define S3FS_CURLOPT_KEEP_SENDING_ON_ERROR CURLOPT_KEEP_SENDING_ON_ERROR
|
2019-03-22 10:47:42 +00:00
|
|
|
#else
|
2020-08-22 12:40:53 +00:00
|
|
|
#define S3FS_CURLOPT_KEEP_SENDING_ON_ERROR static_cast<CURLoption>(245)
|
2019-03-22 10:47:42 +00:00
|
|
|
#endif
|
|
|
|
|
2015-10-20 15:19:04 +00:00
|
|
|
//----------------------------------------------
|
2020-08-22 12:40:53 +00:00
|
|
|
// Structure / Typedefs
|
2015-10-20 15:19:04 +00:00
|
|
|
//----------------------------------------------
|
2013-07-05 02:28:31 +00:00
|
|
|
typedef std::pair<double, double> progress_t;
|
|
|
|
typedef std::map<CURL*, time_t> curltime_t;
|
|
|
|
typedef std::map<CURL*, progress_t> curlprogress_t;
|
2011-03-01 19:35:55 +00:00
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
//----------------------------------------------
|
|
|
|
// class S3fsCurl
|
|
|
|
//----------------------------------------------
|
2022-07-30 03:06:47 +00:00
|
|
|
class CurlHandlerPool;
|
|
|
|
class S3fsCred;
|
2019-02-25 12:47:10 +00:00
|
|
|
class S3fsCurl;
|
2022-07-28 14:38:38 +00:00
|
|
|
class Semaphore;
|
2019-02-25 12:47:10 +00:00
|
|
|
|
2019-03-09 08:45:10 +00:00
|
|
|
// Prototype function for lazy setup options for curl handle
|
|
|
|
typedef bool (*s3fscurl_lazy_setup)(S3fsCurl* s3fscurl);
|
2019-02-25 12:47:10 +00:00
|
|
|
|
2014-07-19 19:02:55 +00:00
|
|
|
typedef std::map<std::string, std::string> sseckeymap_t;
|
2023-08-05 01:05:32 +00:00
|
|
|
typedef std::vector<sseckeymap_t> sseckeylist_t;
|
2013-10-06 13:45:32 +00:00
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
// Class for lapping curl
|
|
|
|
//
|
|
|
|
class S3fsCurl
|
|
|
|
{
|
2020-08-22 12:40:53 +00:00
|
|
|
friend class S3fsMultiCurl;
|
|
|
|
|
|
|
|
private:
|
2023-07-30 13:53:17 +00:00
|
|
|
enum class REQTYPE {
|
|
|
|
UNSET = -1,
|
|
|
|
DELETE = 0,
|
|
|
|
HEAD,
|
|
|
|
PUTHEAD,
|
|
|
|
PUT,
|
|
|
|
GET,
|
|
|
|
CHKBUCKET,
|
|
|
|
LISTBUCKET,
|
|
|
|
PREMULTIPOST,
|
|
|
|
COMPLETEMULTIPOST,
|
|
|
|
UPLOADMULTIPOST,
|
|
|
|
COPYMULTIPOST,
|
|
|
|
MULTILIST,
|
|
|
|
IAMCRED,
|
|
|
|
ABORTMULTIUPLOAD,
|
|
|
|
IAMROLE
|
2020-08-22 12:40:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// class variables
|
2020-10-03 12:09:35 +00:00
|
|
|
static pthread_mutex_t curl_warnings_lock;
|
|
|
|
static bool curl_warnings_once; // emit older curl warnings only once
|
2020-08-22 12:40:53 +00:00
|
|
|
static pthread_mutex_t curl_handles_lock;
|
|
|
|
static struct callback_locks_t {
|
|
|
|
pthread_mutex_t dns;
|
|
|
|
pthread_mutex_t ssl_session;
|
|
|
|
} callback_locks;
|
|
|
|
static bool is_initglobal_done;
|
|
|
|
static CurlHandlerPool* sCurlPool;
|
|
|
|
static int sCurlPoolSize;
|
|
|
|
static CURLSH* hCurlShare;
|
|
|
|
static bool is_cert_check;
|
|
|
|
static bool is_dns_cache;
|
|
|
|
static bool is_ssl_session_cache;
|
|
|
|
static long connect_timeout;
|
|
|
|
static time_t readwrite_timeout;
|
|
|
|
static int retries;
|
|
|
|
static bool is_public_bucket;
|
|
|
|
static acl_t default_acl;
|
2021-05-21 14:34:31 +00:00
|
|
|
static std::string storage_class;
|
2020-08-22 12:40:53 +00:00
|
|
|
static sseckeylist_t sseckeys;
|
|
|
|
static std::string ssekmsid;
|
|
|
|
static sse_type_t ssetype;
|
|
|
|
static bool is_content_md5;
|
|
|
|
static bool is_verbose;
|
|
|
|
static bool is_dump_body;
|
2022-01-30 08:04:33 +00:00
|
|
|
static S3fsCred* ps3fscred;
|
2020-08-22 12:40:53 +00:00
|
|
|
static long ssl_verify_hostname;
|
|
|
|
static curltime_t curl_times;
|
|
|
|
static curlprogress_t curl_progress;
|
|
|
|
static std::string curl_ca_bundle;
|
|
|
|
static mimes_t mimeTypes;
|
|
|
|
static std::string userAgent;
|
|
|
|
static int max_parallel_cnt;
|
|
|
|
static int max_multireq;
|
|
|
|
static off_t multipart_size;
|
2021-02-08 11:32:12 +00:00
|
|
|
static off_t multipart_copy_size;
|
2020-10-01 09:50:49 +00:00
|
|
|
static signature_type_t signature_type;
|
2021-11-01 14:33:55 +00:00
|
|
|
static bool is_unsigned_payload;
|
2020-08-22 12:40:53 +00:00
|
|
|
static bool is_ua; // User-Agent
|
2021-02-23 00:45:13 +00:00
|
|
|
static bool listobjectsv2;
|
2020-08-22 12:40:53 +00:00
|
|
|
static bool requester_pays;
|
2022-12-04 16:09:09 +00:00
|
|
|
static std::string proxy_url;
|
|
|
|
static bool proxy_http;
|
|
|
|
static std::string proxy_userpwd; // load from file(<username>:<passphrase>)
|
2020-08-22 12:40:53 +00:00
|
|
|
|
|
|
|
// variables
|
|
|
|
CURL* hCurl;
|
|
|
|
REQTYPE type; // type of request
|
|
|
|
std::string path; // target object path
|
|
|
|
std::string base_path; // base path (for multi curl head request)
|
|
|
|
std::string saved_path; // saved path = cache key (for multi curl head request)
|
|
|
|
std::string url; // target object path(url)
|
|
|
|
struct curl_slist* requestHeaders;
|
|
|
|
headers_t responseHeaders; // header data by HeaderCallback
|
2023-08-17 13:49:41 +00:00
|
|
|
std::string bodydata; // body data by WriteMemoryCallback
|
|
|
|
std::string headdata; // header data by WriteMemoryCallback
|
2021-06-29 23:20:44 +00:00
|
|
|
long LastResponseCode;
|
2020-08-22 12:40:53 +00:00
|
|
|
const unsigned char* postdata; // use by post method and read callback function.
|
2021-06-13 03:50:07 +00:00
|
|
|
off_t postdata_remaining; // use by post method and read callback function.
|
2020-08-22 12:40:53 +00:00
|
|
|
filepart partdata; // use by multipart upload/get object callback
|
|
|
|
bool is_use_ahbe; // additional header by extension
|
|
|
|
int retry_count; // retry count for multipart
|
|
|
|
FILE* b_infile; // backup for retrying
|
|
|
|
const unsigned char* b_postdata; // backup for retrying
|
2021-06-13 03:50:07 +00:00
|
|
|
off_t b_postdata_remaining; // backup for retrying
|
2020-08-22 12:40:53 +00:00
|
|
|
off_t b_partdata_startpos; // backup for retrying
|
2020-09-14 09:09:25 +00:00
|
|
|
off_t b_partdata_size; // backup for retrying
|
2021-06-13 03:50:07 +00:00
|
|
|
size_t b_ssekey_pos; // backup for retrying
|
2020-08-22 12:40:53 +00:00
|
|
|
std::string b_ssevalue; // backup for retrying
|
|
|
|
sse_type_t b_ssetype; // backup for retrying
|
|
|
|
std::string b_from; // backup for retrying(for copy request)
|
|
|
|
headers_t b_meta; // backup for retrying(for copy request)
|
|
|
|
std::string op; // the HTTP verb of the request ("PUT", "GET", etc.)
|
|
|
|
std::string query_string; // request query string
|
|
|
|
Semaphore *sem;
|
|
|
|
pthread_mutex_t *completed_tids_lock;
|
|
|
|
std::vector<pthread_t> *completed_tids;
|
|
|
|
s3fscurl_lazy_setup fpLazySetup; // curl options for lazy setting function
|
2021-01-04 13:57:56 +00:00
|
|
|
CURLcode curlCode; // handle curl return
|
2021-11-02 12:16:48 +00:00
|
|
|
|
2020-08-22 12:40:53 +00:00
|
|
|
public:
|
2023-11-14 13:15:17 +00:00
|
|
|
static constexpr long S3FSCURL_RESPONSECODE_NOTSET = -1;
|
|
|
|
static constexpr long S3FSCURL_RESPONSECODE_FATAL_ERROR = -2;
|
|
|
|
static constexpr int S3FSCURL_PERFORM_RESULT_NOTSET = 1;
|
2020-08-22 12:40:53 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
// constructor/destructor
|
|
|
|
explicit S3fsCurl(bool ahbe = false);
|
|
|
|
~S3fsCurl();
|
2023-09-06 14:52:10 +00:00
|
|
|
S3fsCurl(const S3fsCurl&) = delete;
|
|
|
|
S3fsCurl(S3fsCurl&&) = delete;
|
|
|
|
S3fsCurl& operator=(const S3fsCurl&) = delete;
|
|
|
|
S3fsCurl& operator=(S3fsCurl&&) = delete;
|
2020-08-22 12:40:53 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// class methods
|
2020-09-20 22:02:06 +00:00
|
|
|
static bool InitGlobalCurl();
|
|
|
|
static bool DestroyGlobalCurl();
|
|
|
|
static bool InitShareCurl();
|
|
|
|
static bool DestroyShareCurl();
|
2020-08-22 12:40:53 +00:00
|
|
|
static void LockCurlShare(CURL* handle, curl_lock_data nLockData, curl_lock_access laccess, void* useptr);
|
|
|
|
static void UnlockCurlShare(CURL* handle, curl_lock_data nLockData, void* useptr);
|
2020-09-20 22:02:06 +00:00
|
|
|
static bool InitCryptMutex();
|
|
|
|
static bool DestroyCryptMutex();
|
2020-08-22 12:40:53 +00:00
|
|
|
static int CurlProgress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
|
|
|
|
|
2020-09-20 22:02:06 +00:00
|
|
|
static bool LocateBundle();
|
2020-08-22 12:40:53 +00:00
|
|
|
static size_t HeaderCallback(void *data, size_t blockSize, size_t numBlocks, void *userPtr);
|
|
|
|
static size_t WriteMemoryCallback(void *ptr, size_t blockSize, size_t numBlocks, void *data);
|
|
|
|
static size_t ReadCallback(void *ptr, size_t size, size_t nmemb, void *userp);
|
|
|
|
static size_t UploadReadCallback(void *ptr, size_t size, size_t nmemb, void *userp);
|
|
|
|
static size_t DownloadWriteCallback(void* ptr, size_t size, size_t nmemb, void* userp);
|
|
|
|
|
2022-07-17 15:45:45 +00:00
|
|
|
static bool UploadMultipartPostCallback(S3fsCurl* s3fscurl, void* param);
|
|
|
|
static bool CopyMultipartPostCallback(S3fsCurl* s3fscurl, void* param);
|
|
|
|
static bool MixMultipartPostCallback(S3fsCurl* s3fscurl, void* param);
|
2023-08-17 13:08:56 +00:00
|
|
|
static std::unique_ptr<S3fsCurl> UploadMultipartPostRetryCallback(S3fsCurl* s3fscurl);
|
|
|
|
static std::unique_ptr<S3fsCurl> CopyMultipartPostRetryCallback(S3fsCurl* s3fscurl);
|
|
|
|
static std::unique_ptr<S3fsCurl> MixMultipartPostRetryCallback(S3fsCurl* s3fscurl);
|
|
|
|
static std::unique_ptr<S3fsCurl> ParallelGetObjectRetryCallback(S3fsCurl* s3fscurl);
|
2020-08-22 12:40:53 +00:00
|
|
|
|
|
|
|
// lazy functions for set curl options
|
|
|
|
static bool CopyMultipartPostSetCurlOpts(S3fsCurl* s3fscurl);
|
|
|
|
static bool PreGetObjectRequestSetCurlOpts(S3fsCurl* s3fscurl);
|
|
|
|
static bool PreHeadRequestSetCurlOpts(S3fsCurl* s3fscurl);
|
|
|
|
|
2020-09-20 22:02:06 +00:00
|
|
|
static bool LoadEnvSseCKeys();
|
|
|
|
static bool LoadEnvSseKmsid();
|
2020-09-14 08:47:21 +00:00
|
|
|
static bool PushbackSseKeys(const std::string& onekey);
|
2020-08-22 12:40:53 +00:00
|
|
|
static bool AddUserAgent(CURL* hCurl);
|
|
|
|
|
2021-10-07 13:19:36 +00:00
|
|
|
static int CurlDebugFunc(const CURL* hcurl, curl_infotype type, char* data, size_t size, void* userptr);
|
|
|
|
static int CurlDebugBodyInFunc(const CURL* hcurl, curl_infotype type, char* data, size_t size, void* userptr);
|
|
|
|
static int CurlDebugBodyOutFunc(const CURL* hcurl, curl_infotype type, char* data, size_t size, void* userptr);
|
|
|
|
static int RawCurlDebugFunc(const CURL* hcurl, curl_infotype type, char* data, size_t size, void* userptr, curl_infotype datatype);
|
2020-08-22 12:40:53 +00:00
|
|
|
|
|
|
|
// methods
|
2022-07-30 06:33:37 +00:00
|
|
|
bool ResetHandle(AutoLock::Type locktype = AutoLock::NONE);
|
2020-09-20 22:02:06 +00:00
|
|
|
bool RemakeHandle();
|
|
|
|
bool ClearInternalData();
|
2022-02-23 15:03:08 +00:00
|
|
|
void insertV4Headers(const std::string& access_key_id, const std::string& secret_access_key, const std::string& access_token);
|
|
|
|
void insertV2Headers(const std::string& access_key_id, const std::string& secret_access_key, const std::string& access_token);
|
|
|
|
void insertIBMIAMHeaders(const std::string& access_key_id, const std::string& access_token);
|
2020-08-22 12:40:53 +00:00
|
|
|
void insertAuthHeaders();
|
2023-01-08 14:24:21 +00:00
|
|
|
bool AddSseRequestHead(sse_type_t ssetype, const std::string& ssevalue, bool is_copy);
|
2022-02-23 15:03:08 +00:00
|
|
|
std::string CalcSignatureV2(const std::string& method, const std::string& strMD5, const std::string& content_type, const std::string& date, const std::string& resource, const std::string& secret_access_key, const std::string& access_token);
|
|
|
|
std::string CalcSignature(const std::string& method, const std::string& canonical_uri, const std::string& query_string, const std::string& strdate, const std::string& payload_hash, const std::string& date8601, const std::string& secret_access_key, const std::string& access_token);
|
2020-08-22 12:40:53 +00:00
|
|
|
int UploadMultipartPostSetup(const char* tpath, int part_num, const std::string& upload_id);
|
|
|
|
int CopyMultipartPostSetup(const char* from, const char* to, int part_num, const std::string& upload_id, headers_t& meta);
|
|
|
|
bool UploadMultipartPostComplete();
|
|
|
|
bool CopyMultipartPostComplete();
|
2021-04-25 04:18:11 +00:00
|
|
|
int MapPutErrorResponse(int result);
|
2020-08-22 12:40:53 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
// class methods
|
2020-09-20 22:02:06 +00:00
|
|
|
static bool InitS3fsCurl();
|
2022-01-30 08:04:33 +00:00
|
|
|
static bool InitCredentialObject(S3fsCred* pcredobj);
|
2020-08-22 12:40:53 +00:00
|
|
|
static bool InitMimeType(const std::string& strFile);
|
2020-09-20 22:02:06 +00:00
|
|
|
static bool DestroyS3fsCurl();
|
2023-07-27 00:12:28 +00:00
|
|
|
static std::unique_ptr<S3fsCurl> CreateParallelS3fsCurl(const char* tpath, int fd, off_t start, off_t size, int part_num, bool is_copy, etagpair* petag, const std::string& upload_id, int& result);
|
2020-08-22 12:40:53 +00:00
|
|
|
static int ParallelMultipartUploadRequest(const char* tpath, headers_t& meta, int fd);
|
|
|
|
static int ParallelMixMultipartUploadRequest(const char* tpath, headers_t& meta, int fd, const fdpage_list_t& mixuppages);
|
2020-09-14 09:09:25 +00:00
|
|
|
static int ParallelGetObjectRequest(const char* tpath, int fd, off_t start, off_t size);
|
2020-08-22 12:40:53 +00:00
|
|
|
|
2021-11-02 12:16:48 +00:00
|
|
|
// lazy functions for set curl options(public)
|
|
|
|
static bool UploadMultipartPostSetCurlOpts(S3fsCurl* s3fscurl);
|
|
|
|
|
2020-08-22 12:40:53 +00:00
|
|
|
// class methods(variables)
|
|
|
|
static std::string LookupMimeType(const std::string& name);
|
|
|
|
static bool SetCheckCertificate(bool isCertCheck);
|
|
|
|
static bool SetDnsCache(bool isCache);
|
|
|
|
static bool SetSslSessionCache(bool isCache);
|
|
|
|
static long SetConnectTimeout(long timeout);
|
|
|
|
static time_t SetReadwriteTimeout(time_t timeout);
|
2020-09-20 22:02:06 +00:00
|
|
|
static time_t GetReadwriteTimeout() { return S3fsCurl::readwrite_timeout; }
|
2020-08-22 12:40:53 +00:00
|
|
|
static int SetRetries(int count);
|
|
|
|
static bool SetPublicBucket(bool flag);
|
2020-09-20 22:02:06 +00:00
|
|
|
static bool IsPublicBucket() { return S3fsCurl::is_public_bucket; }
|
2020-08-22 12:40:53 +00:00
|
|
|
static acl_t SetDefaultAcl(acl_t acl);
|
|
|
|
static acl_t GetDefaultAcl();
|
2021-05-21 14:34:31 +00:00
|
|
|
static std::string SetStorageClass(const std::string& storage_class);
|
|
|
|
static std::string GetStorageClass() { return S3fsCurl::storage_class; }
|
2020-09-20 22:02:06 +00:00
|
|
|
static bool LoadEnvSse() { return (S3fsCurl::LoadEnvSseCKeys() && S3fsCurl::LoadEnvSseKmsid()); }
|
2020-08-22 12:40:53 +00:00
|
|
|
static sse_type_t SetSseType(sse_type_t type);
|
2020-09-20 22:02:06 +00:00
|
|
|
static sse_type_t GetSseType() { return S3fsCurl::ssetype; }
|
|
|
|
static bool IsSseDisable() { return (sse_type_t::SSE_DISABLE == S3fsCurl::ssetype); }
|
|
|
|
static bool IsSseS3Type() { return (sse_type_t::SSE_S3 == S3fsCurl::ssetype); }
|
|
|
|
static bool IsSseCType() { return (sse_type_t::SSE_C == S3fsCurl::ssetype); }
|
|
|
|
static bool IsSseKmsType() { return (sse_type_t::SSE_KMS == S3fsCurl::ssetype); }
|
|
|
|
static bool FinalCheckSse();
|
2020-08-22 12:40:53 +00:00
|
|
|
static bool SetSseCKeys(const char* filepath);
|
|
|
|
static bool SetSseKmsid(const char* kmsid);
|
2020-09-20 22:02:06 +00:00
|
|
|
static bool IsSetSseKmsId() { return !S3fsCurl::ssekmsid.empty(); }
|
|
|
|
static const char* GetSseKmsId() { return S3fsCurl::ssekmsid.c_str(); }
|
2020-08-22 12:40:53 +00:00
|
|
|
static bool GetSseKey(std::string& md5, std::string& ssekey);
|
2021-06-13 03:50:07 +00:00
|
|
|
static bool GetSseKeyMd5(size_t pos, std::string& md5);
|
|
|
|
static size_t GetSseKeyCount();
|
2020-08-22 12:40:53 +00:00
|
|
|
static bool SetContentMd5(bool flag);
|
|
|
|
static bool SetVerbose(bool flag);
|
2020-09-20 22:02:06 +00:00
|
|
|
static bool GetVerbose() { return S3fsCurl::is_verbose; }
|
2020-08-22 12:40:53 +00:00
|
|
|
static bool SetDumpBody(bool flag);
|
2020-09-20 22:02:06 +00:00
|
|
|
static bool IsDumpBody() { return S3fsCurl::is_dump_body; }
|
2020-08-22 12:40:53 +00:00
|
|
|
static long SetSslVerifyHostname(long value);
|
2020-09-20 22:02:06 +00:00
|
|
|
static long GetSslVerifyHostname() { return S3fsCurl::ssl_verify_hostname; }
|
2021-01-04 13:57:56 +00:00
|
|
|
static void ResetOffset(S3fsCurl* pCurl);
|
2020-08-22 12:40:53 +00:00
|
|
|
// maximum parallel GET and PUT requests
|
|
|
|
static int SetMaxParallelCount(int value);
|
2020-09-20 22:02:06 +00:00
|
|
|
static int GetMaxParallelCount() { return S3fsCurl::max_parallel_cnt; }
|
2020-08-22 12:40:53 +00:00
|
|
|
// maximum parallel HEAD requests
|
|
|
|
static int SetMaxMultiRequest(int max);
|
2020-09-20 22:02:06 +00:00
|
|
|
static int GetMaxMultiRequest() { return S3fsCurl::max_multireq; }
|
2020-08-22 12:40:53 +00:00
|
|
|
static bool SetMultipartSize(off_t size);
|
2020-09-20 22:02:06 +00:00
|
|
|
static off_t GetMultipartSize() { return S3fsCurl::multipart_size; }
|
2021-02-08 11:32:12 +00:00
|
|
|
static bool SetMultipartCopySize(off_t size);
|
|
|
|
static off_t GetMultipartCopySize() { return S3fsCurl::multipart_copy_size; }
|
2020-10-01 09:50:49 +00:00
|
|
|
static signature_type_t SetSignatureType(signature_type_t signature_type) { signature_type_t bresult = S3fsCurl::signature_type; S3fsCurl::signature_type = signature_type; return bresult; }
|
|
|
|
static signature_type_t GetSignatureType() { return S3fsCurl::signature_type; }
|
2021-11-01 14:33:55 +00:00
|
|
|
static bool SetUnsignedPayload(bool issset) { bool bresult = S3fsCurl::is_unsigned_payload; S3fsCurl::is_unsigned_payload = issset; return bresult; }
|
|
|
|
static bool GetUnsignedPayload() { return S3fsCurl::is_unsigned_payload; }
|
2020-08-22 12:40:53 +00:00
|
|
|
static bool SetUserAgentFlag(bool isset) { bool bresult = S3fsCurl::is_ua; S3fsCurl::is_ua = isset; return bresult; }
|
2020-09-20 22:02:06 +00:00
|
|
|
static bool IsUserAgentFlag() { return S3fsCurl::is_ua; }
|
|
|
|
static void InitUserAgent();
|
2021-02-23 00:45:13 +00:00
|
|
|
static bool SetListObjectsV2(bool isset) { bool bresult = S3fsCurl::listobjectsv2; S3fsCurl::listobjectsv2 = isset; return bresult; }
|
|
|
|
static bool IsListObjectsV2() { return S3fsCurl::listobjectsv2; }
|
2020-08-22 12:40:53 +00:00
|
|
|
static bool SetRequesterPays(bool flag) { bool old_flag = S3fsCurl::requester_pays; S3fsCurl::requester_pays = flag; return old_flag; }
|
2020-09-20 22:02:06 +00:00
|
|
|
static bool IsRequesterPays() { return S3fsCurl::requester_pays; }
|
2022-12-04 16:09:09 +00:00
|
|
|
static bool SetProxy(const char* url);
|
|
|
|
static bool SetProxyUserPwd(const char* userpwd);
|
2020-08-22 12:40:53 +00:00
|
|
|
|
|
|
|
// methods
|
|
|
|
bool CreateCurlHandle(bool only_pool = false, bool remake = false);
|
2022-07-27 14:00:15 +00:00
|
|
|
bool DestroyCurlHandle(bool restore_pool = true, bool clear_internal_data = true, AutoLock::Type locktype = AutoLock::NONE);
|
2020-08-22 12:40:53 +00:00
|
|
|
|
2022-02-23 15:03:08 +00:00
|
|
|
bool GetIAMCredentials(const char* cred_url, const char* iam_v2_token, const char* ibm_secret_access_key, std::string& response);
|
|
|
|
bool GetIAMRoleFromMetaData(const char* cred_url, const char* iam_v2_token, std::string& token);
|
2023-01-04 11:23:39 +00:00
|
|
|
bool GetResponseCode(long& responseCode, bool from_curl_handle = true) const;
|
2020-08-22 12:40:53 +00:00
|
|
|
int RequestPerform(bool dontAddAuthHeaders=false);
|
|
|
|
int DeleteRequest(const char* tpath);
|
2022-02-23 15:03:08 +00:00
|
|
|
int GetIAMv2ApiToken(const char* token_url, int token_ttl, const char* token_ttl_hdr, std::string& response);
|
2023-07-27 12:56:58 +00:00
|
|
|
bool PreHeadRequest(const char* tpath, const char* bpath = nullptr, const char* savedpath = nullptr, size_t ssekey_pos = -1);
|
2021-06-13 03:50:07 +00:00
|
|
|
bool PreHeadRequest(const std::string& tpath, const std::string& bpath, const std::string& savedpath, size_t ssekey_pos = -1) {
|
2020-08-22 12:40:53 +00:00
|
|
|
return PreHeadRequest(tpath.c_str(), bpath.c_str(), savedpath.c_str(), ssekey_pos);
|
|
|
|
}
|
|
|
|
int HeadRequest(const char* tpath, headers_t& meta);
|
|
|
|
int PutHeadRequest(const char* tpath, headers_t& meta, bool is_copy);
|
|
|
|
int PutRequest(const char* tpath, headers_t& meta, int fd);
|
2020-09-14 08:47:21 +00:00
|
|
|
int PreGetObjectRequest(const char* tpath, int fd, off_t start, off_t size, sse_type_t ssetype, const std::string& ssevalue);
|
2020-09-14 09:09:25 +00:00
|
|
|
int GetObjectRequest(const char* tpath, int fd, off_t start = -1, off_t size = -1);
|
2023-05-07 00:15:27 +00:00
|
|
|
int CheckBucket(const char* check_path, bool compat_dir);
|
2020-08-22 12:40:53 +00:00
|
|
|
int ListBucketRequest(const char* tpath, const char* query);
|
|
|
|
int PreMultipartPostRequest(const char* tpath, headers_t& meta, std::string& upload_id, bool is_copy);
|
|
|
|
int CompleteMultipartPostRequest(const char* tpath, const std::string& upload_id, etaglist_t& parts);
|
|
|
|
int UploadMultipartPostRequest(const char* tpath, int part_num, const std::string& upload_id);
|
2021-11-02 12:16:48 +00:00
|
|
|
bool MixMultipartPostComplete();
|
2020-08-22 12:40:53 +00:00
|
|
|
int MultipartListRequest(std::string& body);
|
|
|
|
int AbortMultipartUpload(const char* tpath, const std::string& upload_id);
|
|
|
|
int MultipartHeadRequest(const char* tpath, off_t size, headers_t& meta, bool is_copy);
|
2021-08-15 14:34:21 +00:00
|
|
|
int MultipartUploadRequest(const std::string& upload_id, const char* tpath, int fd, off_t offset, off_t size, etagpair* petagpair);
|
2020-08-22 12:40:53 +00:00
|
|
|
int MultipartRenameRequest(const char* from, const char* to, headers_t& meta, off_t size);
|
|
|
|
|
|
|
|
// methods(variables)
|
2020-09-20 22:02:06 +00:00
|
|
|
CURL* GetCurlHandle() const { return hCurl; }
|
|
|
|
std::string GetPath() const { return path; }
|
|
|
|
std::string GetBasePath() const { return base_path; }
|
2021-06-27 02:22:33 +00:00
|
|
|
std::string GetSpecialSavedPath() const { return saved_path; }
|
2020-09-20 22:02:06 +00:00
|
|
|
std::string GetUrl() const { return url; }
|
|
|
|
std::string GetOp() const { return op; }
|
2023-01-04 11:23:39 +00:00
|
|
|
const headers_t* GetResponseHeaders() const { return &responseHeaders; }
|
2023-08-17 13:49:41 +00:00
|
|
|
const std::string* GetBodyData() const { return &bodydata; }
|
|
|
|
const std::string* GetHeadData() const { return &headdata; }
|
2021-01-04 13:57:56 +00:00
|
|
|
CURLcode GetCurlCode() const { return curlCode; }
|
2020-09-20 22:02:06 +00:00
|
|
|
long GetLastResponseCode() const { return LastResponseCode; }
|
2020-08-22 12:40:53 +00:00
|
|
|
bool SetUseAhbe(bool ahbe);
|
2020-09-20 22:02:06 +00:00
|
|
|
bool EnableUseAhbe() { return SetUseAhbe(true); }
|
|
|
|
bool DisableUseAhbe() { return SetUseAhbe(false); }
|
|
|
|
bool IsUseAhbe() const { return is_use_ahbe; }
|
|
|
|
int GetMultipartRetryCount() const { return retry_count; }
|
2020-08-22 12:40:53 +00:00
|
|
|
void SetMultipartRetryCount(int retrycnt) { retry_count = retrycnt; }
|
2020-09-20 22:02:06 +00:00
|
|
|
bool IsOverMultipartRetryCount() const { return (retry_count >= S3fsCurl::retries); }
|
2021-06-13 03:50:07 +00:00
|
|
|
size_t GetLastPreHeadSeecKeyPos() const { return b_ssekey_pos; }
|
2013-03-30 13:37:14 +00:00
|
|
|
};
|
|
|
|
|
2011-03-01 19:35:55 +00:00
|
|
|
#endif // S3FS_CURL_H_
|
2014-09-07 15:08:27 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
2020-08-22 12:40:53 +00:00
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
2014-09-07 15:08:27 +00:00
|
|
|
* End:
|
2020-08-22 12:40:53 +00:00
|
|
|
* vim600: expandtab sw=4 ts=4 fdm=marker
|
|
|
|
* vim<600: expandtab sw=4 ts=4
|
2014-09-07 15:08:27 +00:00
|
|
|
*/
|