updated build system

This commit is contained in:
2025-10-19 13:53:06 -05:00
parent d632e46dc3
commit e5169445ae
6 changed files with 150 additions and 124 deletions

View File

@@ -15,6 +15,7 @@
* Remote mounts must be upgraded to v2.1.0+ to support new authentication scheme * Remote mounts must be upgraded to v2.1.0+ to support new authentication scheme
* Protocol handshake added for DoS protection * Protocol handshake added for DoS protection
<!-- markdownlint-disable-next-line -->
### Issues ### Issues
* \#12 [unit test] Complete all providers unit tests * \#12 [unit test] Complete all providers unit tests
@@ -43,6 +44,8 @@
* Enhanced remote mount client thread mapping * Enhanced remote mount client thread mapping
* Threads are now mapped 1-1 from client to server instead of being tied to a fixed-size thread pool * Threads are now mapped 1-1 from client to server instead of being tied to a fixed-size thread pool
---
## v2.0.7-release ## v2.0.7-release
<!-- markdownlint-disable-next-line --> <!-- markdownlint-disable-next-line -->
@@ -51,6 +54,8 @@
* \#55 [bug] UI is unable to launch `repertory.exe` on Windows when absolute path contains spaces * \#55 [bug] UI is unable to launch `repertory.exe` on Windows when absolute path contains spaces
* \#57 [bug] Directory entries . and .. are incorrectly being reported as files in Linux remote mounts * \#57 [bug] Directory entries . and .. are incorrectly being reported as files in Linux remote mounts
---
## v2.0.6-release ## v2.0.6-release
<!-- markdownlint-disable-next-line --> <!-- markdownlint-disable-next-line -->
@@ -75,6 +80,8 @@
* Migrated to v2 error handling * Migrated to v2 error handling
* Upgraded WinFSP to v2.1 (2025) * Upgraded WinFSP to v2.1 (2025)
---
## v2.0.5-rc ## v2.0.5-rc
<!-- markdownlint-disable-next-line --> <!-- markdownlint-disable-next-line -->
@@ -92,6 +99,8 @@
* Renamed setting `ApiAuth` to `ApiPassword` * Renamed setting `ApiAuth` to `ApiPassword`
* Require `--name,-na` option for encryption provider * Require `--name,-na` option for encryption provider
---
## v2.0.4-rc ## v2.0.4-rc
### BREAKING CHANGES ### BREAKING CHANGES
@@ -119,6 +128,8 @@
* Refactored `app_config` unit tests * Refactored `app_config` unit tests
* Refactored polling to be more accurate on scheduling tasks * Refactored polling to be more accurate on scheduling tasks
---
## v2.0.3-rc ## v2.0.3-rc
<!-- markdownlint-disable-next-line --> <!-- markdownlint-disable-next-line -->
@@ -143,6 +154,8 @@
* Updated build system to MinGW-w64 12.0.0 * Updated build system to MinGW-w64 12.0.0
* Updated copyright to 2018-2025 * Updated copyright to 2018-2025
---
## v2.0.2-rc ## v2.0.2-rc
<!-- markdownlint-disable-next-line --> <!-- markdownlint-disable-next-line -->
@@ -175,6 +188,8 @@
* Corrected handling of `chown()` and `chmod()` * Corrected handling of `chown()` and `chmod()`
* Fixed erroneous download of chunks after resize * Fixed erroneous download of chunks after resize
---
## v2.0.1-rc ## v2.0.1-rc
<!-- markdownlint-disable-next-line --> <!-- markdownlint-disable-next-line -->
@@ -197,6 +212,8 @@
* Updated `curl` to v8.4.0 * Updated `curl` to v8.4.0
* Updated `libsodium` to v1.0.19 * Updated `libsodium` to v1.0.19
---
## v2.0.0-rc ## v2.0.0-rc
<!-- markdownlint-disable-next-line --> <!-- markdownlint-disable-next-line -->

View File

@@ -120,7 +120,7 @@ if(PROJECT_BUILD)
@ONLY @ONLY
) )
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${PROJECT_NAME}.iss.in") if (PROJECT_IS_MINGW AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${PROJECT_NAME}.iss.in")
configure_file( configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${PROJECT_NAME}.iss.in ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${PROJECT_NAME}.iss.in
${PROJECT_DIST_DIR}/../${PROJECT_NAME}.iss ${PROJECT_DIST_DIR}/../${PROJECT_NAME}.iss
@@ -128,6 +128,14 @@ if(PROJECT_BUILD)
) )
endif() endif()
if (PROJECT_IS_DARWIN AND EXISTS "${CMAKE_SOURCE_DIR}/${PROJECT_NAME}/Info.plist.in")
configure_file(
${CMAKE_SOURCE_DIR}/${PROJECT_NAME}/Info.plist.in
${CMAKE_SOURCE_DIR}/${PROJECT_NAME}/Info.plist
@ONLY
)
endif()
find_package(ICU REQUIRED COMPONENTS data i18n io uc) find_package(ICU REQUIRED COMPONENTS data i18n io uc)
else() else()
message(STATUS "-=[CMake Settings]=-") message(STATUS "-=[CMake Settings]=-")

View File

@@ -1,17 +1,9 @@
set(CMAKE_CXX_FLAGS "-include common.hpp ${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "-include common.hpp ${CMAKE_CXX_FLAGS}")
if (PROJECT_IS_DARWIN)
configure_file(
${CMAKE_SOURCE_DIR}/${PROJECT_NAME}/Info.plist.in
${CMAKE_SOURCE_DIR}/${PROJECT_NAME}/Info.plist
@ONLY
)
endif()
add_project_library(lib${PROJECT_NAME} "" "" "${PROJECT_ADDITIONAL_SOURCES}") add_project_library(lib${PROJECT_NAME} "" "" "${PROJECT_ADDITIONAL_SOURCES}")
add_project_executable(${PROJECT_NAME} lib${PROJECT_NAME} lib${PROJECT_NAME}) add_project_executable(${PROJECT_NAME} lib${PROJECT_NAME} lib${PROJECT_NAME})
if (PROJECT_IS_DARWIN) if (PROJECT_IS_DARWIN AND EXISTS "${CMAKE_SOURCE_DIR}/${PROJECT_NAME}/Info.plist")
set_target_properties(${PROJECT_NAME} PROPERTIES set_target_properties(${PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/Info.plist MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/Info.plist
) )

View File

@@ -129,21 +129,15 @@ protected:
[[nodiscard]] auto do_io(std::function<api_error()> action) -> api_error; [[nodiscard]] auto do_io(std::function<api_error()> action) -> api_error;
[[nodiscard]] auto get_active_downloads() [[nodiscard]] auto get_active_downloads()
-> std::unordered_map<std::size_t, std::shared_ptr<download>> & { -> std::unordered_map<std::size_t, std::shared_ptr<download>> &;
return active_downloads_;
}
[[nodiscard]] auto get_mutex() const -> std::recursive_mutex & { [[nodiscard]] auto get_mutex() const -> std::recursive_mutex &;
return file_mtx_;
}
[[nodiscard]] auto get_last_chunk_size() const -> std::size_t; [[nodiscard]] auto get_last_chunk_size() const -> std::size_t;
[[nodiscard]] auto get_provider() -> i_provider & { return provider_; } [[nodiscard]] auto get_provider() -> i_provider &;
[[nodiscard]] auto get_provider() const -> const i_provider & { [[nodiscard]] auto get_provider() const -> const i_provider &;
return provider_;
}
[[nodiscard]] auto is_removed() const -> bool; [[nodiscard]] auto is_removed() const -> bool;
@@ -208,9 +202,7 @@ public:
[[nodiscard]] auto has_handle(std::uint64_t handle) const -> bool override; [[nodiscard]] auto has_handle(std::uint64_t handle) const -> bool override;
[[nodiscard]] auto is_directory() const -> bool override { [[nodiscard]] auto is_directory() const -> bool override;
return fsi_.directory;
}
[[nodiscard]] auto is_unlinked() const -> bool override; [[nodiscard]] auto is_unlinked() const -> bool override;

View File

@@ -122,7 +122,9 @@ auto packet_server::handshake(std::shared_ptr<connection> conn) const -> bool {
conn->socket, boost::asio::buffer(boost::asio::buffer(buffer))); conn->socket, boost::asio::buffer(boost::asio::buffer(buffer)));
write_timeout.disable(); write_timeout.disable();
if (bytes_written == buffer.size()) { if (bytes_written != buffer.size()) {
throw std::runtime_error("failed to send handshake");
}
conn->buffer.resize(to_read); conn->buffer.resize(to_read);
utils::timeout read_timeout( utils::timeout read_timeout(
@@ -132,8 +134,7 @@ auto packet_server::handshake(std::shared_ptr<connection> conn) const -> bool {
std::uint32_t total_read{}; std::uint32_t total_read{};
while ((total_read < to_read) && conn->socket.is_open()) { while ((total_read < to_read) && conn->socket.is_open()) {
auto bytes_read = boost::asio::read( auto bytes_read = boost::asio::read(
conn->socket, conn->socket, boost::asio::buffer(&conn->buffer[total_read],
boost::asio::buffer(&conn->buffer[total_read],
conn->buffer.size() - total_read)); conn->buffer.size() - total_read));
if (bytes_read == 0) { if (bytes_read == 0) {
throw std::runtime_error("0 bytes read"); throw std::runtime_error("0 bytes read");
@@ -143,43 +144,40 @@ auto packet_server::handshake(std::shared_ptr<connection> conn) const -> bool {
} }
read_timeout.disable(); read_timeout.disable();
if (total_read == to_read) { if (total_read != to_read) {
throw std::runtime_error("invalid handshake");
}
packet response(conn->buffer); packet response(conn->buffer);
if (response.decrypt(encryption_token_) == 0) { if (response.decrypt(encryption_token_) != 0) {
throw std::runtime_error("decryption failed");
}
std::uint32_t client_version{}; std::uint32_t client_version{};
if (response.decode(client_version) == 0) { if (response.decode(client_version) != 0) {
throw std::runtime_error("invalid client version");
}
std::uint32_t client_version_check{}; std::uint32_t client_version_check{};
if (response.decode(client_version_check) == 0) { if (response.decode(client_version_check) != 0) {
throw std::runtime_error("invalid client version");
}
if (~client_version != client_version_check) { if (~client_version != client_version_check) {
throw std::runtime_error("client version check failed"); throw std::runtime_error("client version check failed");
} }
std::string nonce; std::string nonce;
if (response.decode(nonce) == 0) { if (response.decode(nonce) != 0) {
if (nonce == conn->nonce) {
conn->generate_nonce();
return true;
}
throw std::runtime_error("nonce mismatch");
}
throw std::runtime_error("invalid nonce"); throw std::runtime_error("invalid nonce");
} }
throw std::runtime_error("invalid client version"); if (nonce != conn->nonce) {
throw std::runtime_error("nonce mismatch");
} }
throw std::runtime_error("invalid client version"); conn->generate_nonce();
} return true;
throw std::runtime_error("decryption failed");
}
throw std::runtime_error("invalid handshake");
}
throw std::runtime_error("failed to send handshake");
} catch (const std::exception &e) { } catch (const std::exception &e) {
repertory::utils::error::raise_error(function_name, e, "handlshake failed"); repertory::utils::error::raise_error(function_name, e, "handlshake failed");
} }
@@ -303,13 +301,20 @@ void packet_server::read_packet(std::shared_ptr<connection> conn,
packet::error_type ret{}; packet::error_type ret{};
auto request = std::make_shared<packet>(conn->buffer); auto request = std::make_shared<packet>(conn->buffer);
if (request->decrypt(encryption_token_) == 0) { if (request->decrypt(encryption_token_) != 0) {
throw std::runtime_error("decryption failed");
}
std::string nonce; std::string nonce;
ret = request->decode(nonce); ret = request->decode(nonce);
if (ret == 0) { if (ret != 0) {
throw std::runtime_error("invalid nonce");
}
if (nonce != conn->nonce) { if (nonce != conn->nonce) {
throw std::runtime_error("nonce mismatch"); throw std::runtime_error("nonce mismatch");
} }
conn->generate_nonce(); conn->generate_nonce();
std::string version; std::string version;
@@ -348,12 +353,7 @@ void packet_server::read_packet(std::shared_ptr<connection> conn,
} else { } else {
ret = utils::from_api_error(api_error::invalid_version); ret = utils::from_api_error(api_error::invalid_version);
} }
} else {
throw std::runtime_error("invalid nonce");
}
} else {
throw std::runtime_error("decryption failed");
}
if (should_send_response) { if (should_send_response) {
send_response(conn, ret, *response); send_response(conn, ret, *response);
} }

View File

@@ -206,6 +206,11 @@ void open_file_base::file_io_thread() {
process_queue(); process_queue();
} }
auto open_file_base::get_active_downloads()
-> std::unordered_map<std::size_t, std::shared_ptr<download>> & {
return active_downloads_;
}
auto open_file_base::get_api_error() const -> api_error { auto open_file_base::get_api_error() const -> api_error {
mutex_lock error_lock(error_mtx_); mutex_lock error_lock(error_mtx_);
return error_; return error_;
@@ -221,11 +226,23 @@ auto open_file_base::get_file_size() const -> std::uint64_t {
return fsi_.size; return fsi_.size;
} }
[[nodiscard]] auto open_file_base::get_last_chunk_size() const -> std::size_t { auto open_file_base::get_last_chunk_size() const -> std::size_t {
recur_mutex_lock file_lock(file_mtx_); recur_mutex_lock file_lock(file_mtx_);
return last_chunk_size_; return last_chunk_size_;
} }
auto open_file_base::get_mutex() const -> std::recursive_mutex & {
return file_mtx_;
}
auto open_file_base::get_provider() -> i_provider & { return provider_; }
auto open_file_base::get_provider() const -> const i_provider & {
return provider_;
}
auto open_file_base::is_directory() const -> bool { return fsi_.directory; }
void open_file_base::set_file_size(std::uint64_t size) { void open_file_base::set_file_size(std::uint64_t size) {
recur_mutex_lock file_lock(file_mtx_); recur_mutex_lock file_lock(file_mtx_);
fsi_.size = size; fsi_.size = size;