From 3effb4c80a0775aca001a97a080cc22319f78657 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Tue, 12 Aug 2025 18:28:15 -0500 Subject: [PATCH] updated build system --- .cspell/words.txt | 1 + cmake/versions.cmake | 14 +- docker/x86_64/mingw64 | 2 + repertory/librepertory/include/app_config.hpp | 32 +- .../include/comm/curl/curl_comm.hpp | 7 +- .../include/providers/provider.hpp | 5 +- .../librepertory/include/types/repertory.hpp | 101 +---- .../librepertory/include/utils/cli_utils.hpp | 2 +- .../librepertory/include/utils/utils.hpp | 3 +- repertory/librepertory/src/app_config.cpp | 21 +- .../src/drives/fuse/fuse_base.cpp | 1 - .../providers/encrypt/encrypt_provider.cpp | 85 ++-- .../librepertory/src/providers/provider.cpp | 2 +- .../src/providers/s3/s3_provider.cpp | 8 +- repertory/librepertory/src/rpc/common.cpp | 2 +- .../librepertory/src/utils/cli_utils.cpp | 2 +- .../src/utils/unix/unix_utils.cpp | 2 +- repertory/librepertory/src/utils/utils.cpp | 2 +- repertory/repertory/include/cli/actions.hpp | 6 +- .../repertory/include/cli/check_version.hpp | 2 +- .../repertory/include/cli/display_config.hpp | 2 +- .../include/cli/drive_information.hpp | 2 +- repertory/repertory/include/cli/get.hpp | 2 +- .../include/cli/get_directory_items.hpp | 9 +- .../include/cli/get_pinned_files.hpp | 2 +- .../repertory/include/cli/open_files.hpp | 2 +- repertory/repertory/include/cli/pin_file.hpp | 2 +- .../repertory/include/cli/pinned_status.hpp | 2 +- repertory/repertory/include/cli/set.hpp | 6 +- repertory/repertory/include/cli/status.hpp | 2 +- repertory/repertory/include/cli/test.hpp | 2 +- repertory/repertory/include/cli/unmount.hpp | 2 +- .../repertory/include/cli/unpin_file.hpp | 2 +- .../repertory_test/src/app_config_test.cpp | 2 +- support/include/utils/all.hpp | 2 + support/include/utils/atomic.hpp | 118 +++++ support/include/utils/common.hpp | 7 +- support/include/utils/encrypting_reader.hpp | 44 +- support/include/utils/encryption.hpp | 402 +++++++++++++++++- support/include/utils/hash.hpp | 32 +- support/include/utils/ttl_cache.hpp | 100 +++++ support/src/utils/encrypting_reader.cpp | 370 +++++++++------- support/src/utils/encryption.cpp | 163 ++++--- support/src/utils/file_enc_file.cpp | 17 +- support/src/utils/hash.cpp | 12 +- .../test/src/utils/encrypting_reader_test.cpp | 224 ++++++++++ .../src/utils/encryption_kdf_config_test.cpp | 144 +++++++ support/test/src/utils/encryption_test.cpp | 161 +++++-- support/test/src/utils/hash_test.cpp | 63 ++- support/test/src/utils/ttl_cache_test.cpp | 253 +++++++++++ 50 files changed, 1915 insertions(+), 536 deletions(-) create mode 100644 support/include/utils/atomic.hpp create mode 100644 support/include/utils/ttl_cache.hpp create mode 100644 support/test/src/utils/encryption_kdf_config_test.cpp create mode 100644 support/test/src/utils/ttl_cache_test.cpp diff --git a/.cspell/words.txt b/.cspell/words.txt index e096732a..0ec5a6a0 100644 --- a/.cspell/words.txt +++ b/.cspell/words.txt @@ -244,6 +244,7 @@ wextra wfloat wformat=2 winfsp +winfsp_drive winhttp wininet winspool diff --git a/cmake/versions.cmake b/cmake/versions.cmake index 7b24f207..01c6d81b 100644 --- a/cmake/versions.cmake +++ b/cmake/versions.cmake @@ -1,15 +1,15 @@ set(BINUTILS_VERSION 2.44) -set(BOOST_MAJOR_VERSION 1) -set(BOOST_MINOR_VERSION 88) -set(BOOST_PATCH_VERSION 0) set(BOOST2_MAJOR_VERSION 1) set(BOOST2_MINOR_VERSION 76) set(BOOST2_PATCH_VERSION 0) +set(BOOST_MAJOR_VERSION 1) +set(BOOST_MINOR_VERSION 88) +set(BOOST_PATCH_VERSION 0) set(CPP_HTTPLIB_VERSION 0.23.1) -set(CURL_VERSION 8.15.0) set(CURL2_VERSION 8_15_0) -set(EXPAT_VERSION 2.7.1) +set(CURL_VERSION 8.15.0) set(EXPAT2_VERSION 2_7_1) +set(EXPAT_VERSION 2.7.1) set(GCC_VERSION 15.1.0) set(GTEST_VERSION 1.17.0) set(ICU_VERSION 76-1) @@ -22,9 +22,9 @@ set(PKG_CONFIG_VERSION 0.29.2) set(PUGIXML_VERSION 1.15) set(ROCKSDB_VERSION 10.4.2) set(SPDLOG_VERSION 1.15.3) -set(SQLITE_VERSION 3500300) set(SQLITE2_VERSION 3.50.3) +set(SQLITE_VERSION 3500300) set(STDUUID_VERSION 1.2.3) -set(WINFSP_VERSION 2.1.25156) set(WINFSP2_VERSION 2.1) +set(WINFSP_VERSION 2.1.25156) set(ZLIB_VERSION 1.3.1) diff --git a/docker/x86_64/mingw64 b/docker/x86_64/mingw64 index 638ef6ce..d01e4eb8 100644 --- a/docker/x86_64/mingw64 +++ b/docker/x86_64/mingw64 @@ -1170,6 +1170,8 @@ ARG UID=1000 ARG GID=1000 ARG USERNAME=myuser +RUN delgroup scanner || echo "no scanner group found" + RUN addgroup -g $GID $USERNAME && \ adduser -D -u $UID -G $USERNAME -h /home/$USERNAME $USERNAME diff --git a/repertory/librepertory/include/app_config.hpp b/repertory/librepertory/include/app_config.hpp index db4be5f0..a2838222 100644 --- a/repertory/librepertory/include/app_config.hpp +++ b/repertory/librepertory/include/app_config.hpp @@ -31,24 +31,22 @@ private: static stop_type stop_requested; public: - [[nodiscard]] static auto default_agent_name(const provider_type &prov) + [[nodiscard]] static auto default_agent_name(provider_type prov) -> std::string; - [[nodiscard]] static auto default_api_port(const provider_type &prov) + [[nodiscard]] static auto default_api_port(provider_type prov) -> std::uint16_t; - [[nodiscard]] static auto default_data_directory(const provider_type &prov) + [[nodiscard]] static auto default_data_directory(provider_type prov) -> std::string; - [[nodiscard]] static auto default_remote_api_port(const provider_type &prov) + [[nodiscard]] static auto default_remote_api_port(provider_type prov) -> std::uint16_t; - [[nodiscard]] static auto default_rpc_port() -> std::uint16_t; - - [[nodiscard]] static auto get_provider_display_name(const provider_type &prov) + [[nodiscard]] static auto get_provider_display_name(provider_type prov) -> std::string; - [[nodiscard]] static auto get_provider_name(const provider_type &prov) + [[nodiscard]] static auto get_provider_name(provider_type prov) -> std::string; [[nodiscard]] static auto get_root_data_directory() -> std::string; @@ -59,7 +57,7 @@ public: static void set_stop_requested(); public: - app_config(const provider_type &prov, std::string_view data_directory = ""); + app_config(provider_type prov, std::string_view data_directory = ""); app_config() = delete; app_config(app_config &&) = delete; @@ -72,9 +70,9 @@ public: private: provider_type prov_; - atomic api_password_; + utils::atomic api_password_; std::atomic api_port_; - atomic api_user_; + utils::atomic api_user_; std::atomic config_changed_; std::atomic db_type_{database_type::rocksdb}; std::atomic download_timeout_secs_; @@ -100,14 +98,14 @@ private: private: std::string cache_directory_; std::string data_directory_; - atomic encrypt_config_; - atomic host_config_; + utils::atomic encrypt_config_; + utils::atomic host_config_; std::string log_directory_; mutable std::recursive_mutex read_write_mutex_; - atomic remote_config_; - atomic remote_mount_; - atomic s3_config_; - atomic sia_config_; + utils::atomic remote_config_; + utils::atomic remote_mount_; + utils::atomic s3_config_; + utils::atomic sia_config_; std::unordered_map> value_get_lookup_; std::unordered_map( - request.decryption_token.value()); + const auto key = utils::encryption::generate_key( + request.decryption_token.value()); if (not utils::encryption::read_encrypted_range( request.range.value(), key, [&](data_buffer &ct, std::uint64_t start_offset, diff --git a/repertory/librepertory/include/providers/provider.hpp b/repertory/librepertory/include/providers/provider.hpp index 0f6c1cab..28d92fdd 100644 --- a/repertory/librepertory/include/providers/provider.hpp +++ b/repertory/librepertory/include/providers/provider.hpp @@ -28,9 +28,8 @@ namespace repertory { class app_config; class i_provider; -[[nodiscard]] auto -create_provider(const provider_type &prov, - app_config &config) -> std::unique_ptr; +[[nodiscard]] auto create_provider(provider_type prov, app_config &config) + -> std::unique_ptr; } // namespace repertory #endif // REPERTORY_INCLUDE_PROVIDERS_PROVIDER_HPP_ diff --git a/repertory/librepertory/include/types/repertory.hpp b/repertory/librepertory/include/types/repertory.hpp index a0d13722..84a860df 100644 --- a/repertory/librepertory/include/types/repertory.hpp +++ b/repertory/librepertory/include/types/repertory.hpp @@ -22,6 +22,8 @@ #ifndef REPERTORY_INCLUDE_TYPES_REPERTORY_HPP_ #define REPERTORY_INCLUDE_TYPES_REPERTORY_HPP_ +#include "utils/atomic.hpp" + namespace repertory { inline constexpr auto default_api_password_size{48U}; inline constexpr auto default_download_timeout_secs{30U}; @@ -40,6 +42,7 @@ inline constexpr auto default_med_freq_interval_secs{ inline constexpr auto default_online_check_retry_secs{60U}; inline constexpr auto default_retry_read_count{6U}; inline constexpr auto default_ring_buffer_file_size{512U}; +inline constexpr auto default_rpc_port{std::uint16_t(10000U)}; inline constexpr auto default_task_wait_ms{100U}; inline constexpr auto default_timeout_ms{60000U}; inline constexpr auto default_ui_mgmt_port{std::uint16_t{30000U}}; @@ -54,95 +57,6 @@ inline constexpr auto min_retry_read_count{std::uint16_t(2U)}; inline constexpr auto min_ring_buffer_file_size{std::uint16_t(64U)}; inline constexpr auto min_task_wait_ms{std::uint16_t(50U)}; -template class atomic final { -public: - atomic() : mtx_(std::make_shared()) {} - - atomic(const atomic &at_data) - : data_(at_data.load()), mtx_(std::make_shared()) {} - - atomic(data_t data) - : data_(std::move(data)), mtx_(std::make_shared()) {} - - atomic(atomic &&) = default; - - ~atomic() = default; - -private: - data_t data_; - std::shared_ptr mtx_; - -public: - [[nodiscard]] auto load() const -> data_t { - mutex_lock lock(*mtx_); - return data_; - } - - auto store(data_t data) -> data_t { - mutex_lock lock(*mtx_); - data_ = std::move(data); - return data_; - } - - auto operator=(const atomic &at_data) -> atomic & { - if (&at_data == this) { - return *this; - } - - store(at_data.load()); - return *this; - } - - auto operator=(atomic &&) -> atomic & = default; - - auto operator=(data_t data) -> atomic & { - if (&data == &data_) { - return *this; - } - - store(std::move(data)); - return *this; - } - - [[nodiscard]] auto operator==(const atomic &at_data) const -> bool { - if (&at_data == this) { - return true; - } - - mutex_lock lock(*mtx_); - return at_data.load() == data_; - } - - [[nodiscard]] auto operator==(const data_t &data) const -> bool { - if (&data == &data_) { - return true; - } - - mutex_lock lock(*mtx_); - return data == data_; - } - - [[nodiscard]] auto operator!=(const atomic &at_data) const -> bool { - if (&at_data == this) { - return false; - } - - mutex_lock lock(*mtx_); - return at_data.load() != data_; - } - - [[nodiscard]] auto operator!=(const data_t &data) const -> bool { - if (&data == &data_) { - return false; - } - - mutex_lock lock(*mtx_); - return data != data_; - } - - [[nodiscard]] operator data_t() const { return load(); } -}; - inline constexpr auto max_time{ std::numeric_limits::max(), }; @@ -617,12 +531,15 @@ template <> struct adl_serializer { } }; -template struct adl_serializer> { - static void to_json(json &data, const repertory::atomic &value) { +template +struct adl_serializer> { + static void to_json(json &data, + const repertory::utils::atomic &value) { data = value.load(); } - static void from_json(const json &data, repertory::atomic &value) { + static void from_json(const json &data, + repertory::utils::atomic &value) { value.store(data.get()); } }; diff --git a/repertory/librepertory/include/utils/cli_utils.hpp b/repertory/librepertory/include/utils/cli_utils.hpp index 165c7a9f..8f2a8c0c 100644 --- a/repertory/librepertory/include/utils/cli_utils.hpp +++ b/repertory/librepertory/include/utils/cli_utils.hpp @@ -92,7 +92,7 @@ inline const std::vector