refactor remote mount
This commit is contained in:
parent
c0a6bde9e5
commit
0a45b51760
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system.hpp"
|
||||||
#include "events/events.hpp"
|
#include "events/events.hpp"
|
||||||
|
#include "types/remote.hpp"
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
#include "utils/error_utils.hpp"
|
#include "utils/error_utils.hpp"
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ public:
|
|||||||
[[nodiscard]] static auto default_data_directory(const provider_type &prov)
|
[[nodiscard]] static auto default_data_directory(const provider_type &prov)
|
||||||
-> std::string;
|
-> std::string;
|
||||||
|
|
||||||
[[nodiscard]] static auto default_remote_port(const provider_type &prov)
|
[[nodiscard]] static auto default_remote_api_port(const provider_type &prov)
|
||||||
-> std::uint16_t;
|
-> std::uint16_t;
|
||||||
|
|
||||||
[[nodiscard]] static auto default_rpc_port(const provider_type &prov)
|
[[nodiscard]] static auto default_rpc_port(const provider_type &prov)
|
||||||
@ -76,7 +77,6 @@ private:
|
|||||||
std::atomic<std::uint32_t> eviction_delay_mins_;
|
std::atomic<std::uint32_t> eviction_delay_mins_;
|
||||||
std::atomic<bool> eviction_uses_accessed_time_;
|
std::atomic<bool> eviction_uses_accessed_time_;
|
||||||
std::atomic<std::uint16_t> high_freq_interval_secs_;
|
std::atomic<std::uint16_t> high_freq_interval_secs_;
|
||||||
std::atomic<bool> is_remote_mount_;
|
|
||||||
std::atomic<std::uint16_t> low_freq_interval_secs_;
|
std::atomic<std::uint16_t> low_freq_interval_secs_;
|
||||||
std::atomic<std::uint64_t> max_cache_size_bytes_;
|
std::atomic<std::uint64_t> max_cache_size_bytes_;
|
||||||
std::atomic<std::uint8_t> max_upload_count_;
|
std::atomic<std::uint8_t> max_upload_count_;
|
||||||
@ -85,14 +85,9 @@ private:
|
|||||||
std::atomic<std::uint16_t> online_check_retry_secs_;
|
std::atomic<std::uint16_t> online_check_retry_secs_;
|
||||||
std::atomic<std::uint16_t> orphaned_file_retention_days_;
|
std::atomic<std::uint16_t> orphaned_file_retention_days_;
|
||||||
atomic<std::string> preferred_download_type_;
|
atomic<std::string> preferred_download_type_;
|
||||||
std::atomic<std::uint8_t> read_ahead_count_;
|
|
||||||
std::atomic<std::uint8_t> remote_client_pool_size_;
|
std::atomic<std::uint8_t> remote_client_pool_size_;
|
||||||
atomic<std::string> remote_host_name_or_ip_;
|
std::atomic<std::uint16_t> remote_api_port_;
|
||||||
std::atomic<std::uint8_t> remote_max_connections_;
|
atomic<std::string> remote_encryption_token_;
|
||||||
std::atomic<std::uint16_t> remote_port_;
|
|
||||||
std::atomic<std::uint16_t> remote_receive_timeout_secs_;
|
|
||||||
std::atomic<std::uint16_t> remote_send_timeout_secs_;
|
|
||||||
atomic<std::string> remote_token_;
|
|
||||||
std::atomic<std::uint16_t> retry_read_count_;
|
std::atomic<std::uint16_t> retry_read_count_;
|
||||||
std::atomic<std::uint16_t> ring_buffer_file_size_;
|
std::atomic<std::uint16_t> ring_buffer_file_size_;
|
||||||
std::atomic<std::uint16_t> task_wait_ms_;
|
std::atomic<std::uint16_t> task_wait_ms_;
|
||||||
@ -104,6 +99,7 @@ private:
|
|||||||
atomic<host_config> hc_;
|
atomic<host_config> hc_;
|
||||||
std::string log_directory_;
|
std::string log_directory_;
|
||||||
mutable std::recursive_mutex read_write_mutex_;
|
mutable std::recursive_mutex read_write_mutex_;
|
||||||
|
atomic<remote::remote_config> remote_config_;
|
||||||
atomic<s3_config> s3_config_;
|
atomic<s3_config> s3_config_;
|
||||||
atomic<sia_config> sia_config_;
|
atomic<sia_config> sia_config_;
|
||||||
std::uint64_t version_{REPERTORY_CONFIG_VERSION};
|
std::uint64_t version_{REPERTORY_CONFIG_VERSION};
|
||||||
@ -221,10 +217,6 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] auto get_host_config() const -> host_config { return hc_; }
|
[[nodiscard]] auto get_host_config() const -> host_config { return hc_; }
|
||||||
|
|
||||||
[[nodiscard]] auto get_is_remote_mount() const -> bool {
|
|
||||||
return is_remote_mount_;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] auto get_json() const -> json;
|
[[nodiscard]] auto get_json() const -> json;
|
||||||
|
|
||||||
[[nodiscard]] auto get_log_directory() const -> std::string {
|
[[nodiscard]] auto get_log_directory() const -> std::string {
|
||||||
@ -266,38 +258,21 @@ public:
|
|||||||
return prov_;
|
return prov_;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto get_read_ahead_count() const -> std::uint8_t {
|
|
||||||
return std::max(static_cast<std::uint8_t>(1U), read_ahead_count_.load());
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] auto get_remote_client_pool_size() const -> std::uint8_t {
|
[[nodiscard]] auto get_remote_client_pool_size() const -> std::uint8_t {
|
||||||
return std::max(static_cast<std::uint8_t>(5U),
|
return std::max(static_cast<std::uint8_t>(5U),
|
||||||
remote_client_pool_size_.load());
|
remote_client_pool_size_.load());
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto get_remote_host_name_or_ip() const -> std::string {
|
[[nodiscard]] auto get_remote_api_port() const -> std::uint16_t {
|
||||||
return remote_host_name_or_ip_;
|
return remote_api_port_;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto get_remote_max_connections() const -> std::uint8_t {
|
[[nodiscard]] auto get_remote_config() const -> remote::remote_config {
|
||||||
return std::max(static_cast<std::uint8_t>(1U),
|
return remote_config_;
|
||||||
remote_max_connections_.load());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto get_remote_port() const -> std::uint16_t {
|
[[nodiscard]] auto get_remote_encryption_token() const -> std::string {
|
||||||
return remote_port_;
|
return remote_encryption_token_;
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] auto get_remote_receive_timeout_secs() const -> std::uint16_t {
|
|
||||||
return remote_receive_timeout_secs_;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] auto get_remote_send_timeout_secs() const -> std::uint16_t {
|
|
||||||
return remote_send_timeout_secs_;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] auto get_remote_token() const -> std::string {
|
|
||||||
return remote_token_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto get_retry_read_count() const -> std::uint16_t {
|
[[nodiscard]] auto get_retry_read_count() const -> std::uint16_t {
|
||||||
@ -396,8 +371,6 @@ public:
|
|||||||
|
|
||||||
void set_host_config(host_config cfg);
|
void set_host_config(host_config cfg);
|
||||||
|
|
||||||
void set_is_remote_mount(bool is_remote_mount);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
set_low_frequency_interval_secs(std::uint16_t low_frequency_interval_secs) {
|
set_low_frequency_interval_secs(std::uint16_t low_frequency_interval_secs) {
|
||||||
set_value(low_freq_interval_secs_, low_frequency_interval_secs);
|
set_value(low_freq_interval_secs_, low_frequency_interval_secs);
|
||||||
@ -425,12 +398,8 @@ public:
|
|||||||
set_value(orphaned_file_retention_days_, orphaned_file_retention_days);
|
set_value(orphaned_file_retention_days_, orphaned_file_retention_days);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_preferred_download_type(const download_type &dt) {
|
void set_preferred_download_type(const download_type &type) {
|
||||||
set_value(preferred_download_type_, download_type_to_string(dt));
|
set_value(preferred_download_type_, download_type_to_string(type));
|
||||||
}
|
|
||||||
|
|
||||||
void set_read_ahead_count(std::uint8_t read_ahead_count) {
|
|
||||||
set_value(read_ahead_count_, read_ahead_count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_remote_client_pool_size(std::uint8_t remote_client_pool_size) {
|
void set_remote_client_pool_size(std::uint8_t remote_client_pool_size) {
|
||||||
@ -441,29 +410,14 @@ public:
|
|||||||
set_value(ring_buffer_file_size_, ring_buffer_file_size);
|
set_value(ring_buffer_file_size_, ring_buffer_file_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_remote_host_name_or_ip(const std::string &remote_host_name_or_ip) {
|
void set_remote_api_port(std::uint16_t remote_api_port) {
|
||||||
set_value(remote_host_name_or_ip_, remote_host_name_or_ip);
|
set_value(remote_api_port_, remote_api_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_remote_max_connections(std::uint8_t remote_max_connections) {
|
void set_remote_config(remote::remote_config cfg);
|
||||||
set_value(remote_max_connections_, remote_max_connections);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_remote_port(std::uint16_t remote_port) {
|
void set_remote_encryption_token(const std::string &remote_encryption_token) {
|
||||||
set_value(remote_port_, remote_port);
|
set_value(remote_encryption_token_, remote_encryption_token);
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
set_remote_receive_timeout_secs(std::uint16_t remote_receive_timeout_secs) {
|
|
||||||
set_value(remote_receive_timeout_secs_, remote_receive_timeout_secs);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_remote_send_timeout_secs(std::uint16_t remote_send_timeout_secs) {
|
|
||||||
set_value(remote_send_timeout_secs_, remote_send_timeout_secs);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_remote_token(const std::string &remote_token) {
|
|
||||||
set_value(remote_token_, remote_token);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_retry_read_count(std::uint16_t retry_read_count) {
|
void set_retry_read_count(std::uint16_t retry_read_count) {
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#define REPERTORY_INCLUDE_COMM_PACKET_PACKET_CLIENT_HPP_
|
#define REPERTORY_INCLUDE_COMM_PACKET_PACKET_CLIENT_HPP_
|
||||||
|
|
||||||
#include "comm/packet/packet.hpp"
|
#include "comm/packet/packet.hpp"
|
||||||
|
#include "types/remote.hpp"
|
||||||
|
|
||||||
using boost::asio::ip::tcp;
|
using boost::asio::ip::tcp;
|
||||||
|
|
||||||
@ -36,9 +37,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
packet_client(std::string host_name_or_ip, std::uint8_t max_connections,
|
packet_client(remote::remote_config cfg);
|
||||||
std::uint16_t port, std::uint16_t receive_timeout,
|
|
||||||
std::uint16_t send_timeout, std::string encryption_token);
|
|
||||||
|
|
||||||
~packet_client();
|
~packet_client();
|
||||||
|
|
||||||
@ -49,12 +48,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
boost::asio::io_context io_context_;
|
boost::asio::io_context io_context_;
|
||||||
std::string host_name_or_ip_;
|
remote::remote_config cfg_;
|
||||||
std::uint8_t max_connections_;
|
|
||||||
std::uint16_t port_;
|
|
||||||
std::uint16_t receive_timeout_;
|
|
||||||
std::uint16_t send_timeout_;
|
|
||||||
std::string encryption_token_;
|
|
||||||
std::string unique_id_;
|
std::string unique_id_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -75,21 +69,21 @@ private:
|
|||||||
|
|
||||||
void put_client(std::shared_ptr<client> &cli);
|
void put_client(std::shared_ptr<client> &cli);
|
||||||
|
|
||||||
[[nodiscard]] auto read_packet(client &cli,
|
[[nodiscard]] auto read_packet(client &cli, packet &response)
|
||||||
packet &response) -> packet::error_type;
|
-> packet::error_type;
|
||||||
|
|
||||||
void resolve();
|
void resolve();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] auto send(std::string_view method,
|
[[nodiscard]] auto send(std::string_view method, std::uint32_t &service_flags)
|
||||||
std::uint32_t &service_flags) -> packet::error_type;
|
-> packet::error_type;
|
||||||
|
|
||||||
[[nodiscard]] auto send(std::string_view method, packet &request,
|
[[nodiscard]] auto send(std::string_view method, packet &request,
|
||||||
std::uint32_t &service_flags) -> packet::error_type;
|
std::uint32_t &service_flags) -> packet::error_type;
|
||||||
|
|
||||||
[[nodiscard]] auto send(std::string_view method, packet &request,
|
[[nodiscard]] auto send(std::string_view method, packet &request,
|
||||||
packet &response,
|
packet &response, std::uint32_t &service_flags)
|
||||||
std::uint32_t &service_flags) -> packet::error_type;
|
-> packet::error_type;
|
||||||
};
|
};
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
|
||||||
|
@ -32,6 +32,36 @@ inline constexpr const auto PACKET_SERVICE_FLAGS{PACKET_SERVICE_FUSE};
|
|||||||
#endif // defined(_WIN32)
|
#endif // defined(_WIN32)
|
||||||
|
|
||||||
namespace repertory::remote {
|
namespace repertory::remote {
|
||||||
|
struct remote_config final {
|
||||||
|
std::uint16_t api_port{};
|
||||||
|
std::string encryption_token;
|
||||||
|
std::string host_name_or_ip;
|
||||||
|
std::uint8_t max_connections{20U};
|
||||||
|
std::uint32_t recv_timeout_ms{120U * 1000U};
|
||||||
|
std::uint32_t send_timeout_ms{30U * 1000U};
|
||||||
|
|
||||||
|
auto operator==(const remote_config &cfg) const noexcept -> bool {
|
||||||
|
if (&cfg != this) {
|
||||||
|
return api_port == cfg.api_port &&
|
||||||
|
encryption_token == cfg.encryption_token &&
|
||||||
|
host_name_or_ip == cfg.host_name_or_ip &&
|
||||||
|
max_connections == cfg.max_connections &&
|
||||||
|
recv_timeout_ms == cfg.recv_timeout_ms &&
|
||||||
|
send_timeout_ms == cfg.send_timeout_ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto operator!=(const remote_config &cfg) const noexcept -> bool {
|
||||||
|
if (&cfg != this) {
|
||||||
|
return not(cfg == *this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
using block_count = std::uint64_t;
|
using block_count = std::uint64_t;
|
||||||
using block_size = std::uint32_t;
|
using block_size = std::uint32_t;
|
||||||
using file_handle = std::uint64_t;
|
using file_handle = std::uint64_t;
|
||||||
@ -155,9 +185,35 @@ struct statfs_x final : public statfs {
|
|||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
[[nodiscard]] auto create_open_flags(std::uint32_t flags) -> open_flags;
|
[[nodiscard]] auto create_open_flags(std::uint32_t flags) -> open_flags;
|
||||||
|
|
||||||
[[nodiscard]] auto
|
[[nodiscard]] auto create_os_open_flags(const open_flags &flags)
|
||||||
create_os_open_flags(const open_flags &flags) -> std::uint32_t;
|
-> std::uint32_t;
|
||||||
#endif // !defined(_WIN32)
|
#endif // !defined(_WIN32)
|
||||||
} // namespace repertory::remote
|
} // namespace repertory::remote
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::remote::remote_config> {
|
||||||
|
static void to_json(json &data,
|
||||||
|
const repertory::remote::remote_config &value) {
|
||||||
|
data = {
|
||||||
|
{"ApiPort", value.api_port},
|
||||||
|
{"EncryptionToken", value.encryption_token},
|
||||||
|
{"HostNameOrIp", value.host_name_or_ip},
|
||||||
|
{"ReceiveTimeoutMs", value.recv_timeout_ms},
|
||||||
|
{"SendTimeoutMs", value.send_timeout_ms},
|
||||||
|
{"MaxConnections", value.max_connections},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::remote::remote_config &value) {
|
||||||
|
data.at("ApiPort").get_to(value.api_port);
|
||||||
|
data.at("EncryptionToken").get_to(value.encryption_token);
|
||||||
|
data.at("HostNameOrIp").get_to(value.host_name_or_ip);
|
||||||
|
data.at("ReceiveTimeoutMs").get_to(value.recv_timeout_ms);
|
||||||
|
data.at("SendTimeoutMs").get_to(value.send_timeout_ms);
|
||||||
|
data.at("MaxConnections").get_to(value.max_connections);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
#endif // REPERTORY_INCLUDE_TYPES_REMOTE_HPP_
|
#endif // REPERTORY_INCLUDE_TYPES_REMOTE_HPP_
|
||||||
|
@ -43,13 +43,12 @@ constexpr const auto default_med_freq_interval_secs{2U * 60U};
|
|||||||
constexpr const auto default_min_download_timeout_secs{5U};
|
constexpr const auto default_min_download_timeout_secs{5U};
|
||||||
constexpr const auto default_online_check_retry_secs{60U};
|
constexpr const auto default_online_check_retry_secs{60U};
|
||||||
constexpr const auto default_orphaned_file_retention_days{15U};
|
constexpr const auto default_orphaned_file_retention_days{15U};
|
||||||
constexpr const auto default_read_ahead_count{4U};
|
|
||||||
constexpr const auto default_remote_client_pool_size{10U};
|
constexpr const auto default_remote_client_pool_size{10U};
|
||||||
constexpr const auto default_remote_host_name_or_ip{""};
|
constexpr const auto default_remote_host_name_or_ip{""};
|
||||||
constexpr const auto default_remote_max_connections{20U};
|
constexpr const auto default_remote_max_connections{20U};
|
||||||
constexpr const auto default_remote_receive_timeout_secs{120U};
|
constexpr const auto default_remote_receive_timeout_secs{120U};
|
||||||
constexpr const auto default_remote_send_timeout_secs{30U};
|
constexpr const auto default_remote_send_timeout_secs{30U};
|
||||||
constexpr const auto default_remote_token{""};
|
constexpr const auto default_remote_encryption_token{""};
|
||||||
constexpr const auto default_retry_read_count{6U};
|
constexpr const auto default_retry_read_count{6U};
|
||||||
constexpr const auto default_ring_buffer_file_size{512U};
|
constexpr const auto default_ring_buffer_file_size{512U};
|
||||||
constexpr const auto default_task_wait_ms{100U};
|
constexpr const auto default_task_wait_ms{100U};
|
||||||
@ -78,7 +77,6 @@ app_config::app_config(const provider_type &prov,
|
|||||||
eviction_delay_mins_(default_eviction_delay_mins),
|
eviction_delay_mins_(default_eviction_delay_mins),
|
||||||
eviction_uses_accessed_time_(false),
|
eviction_uses_accessed_time_(false),
|
||||||
high_freq_interval_secs_(default_high_freq_interval_secs),
|
high_freq_interval_secs_(default_high_freq_interval_secs),
|
||||||
is_remote_mount_(false),
|
|
||||||
low_freq_interval_secs_(default_low_freq_interval_secs),
|
low_freq_interval_secs_(default_low_freq_interval_secs),
|
||||||
max_cache_size_bytes_(default_max_cache_size_bytes),
|
max_cache_size_bytes_(default_max_cache_size_bytes),
|
||||||
max_upload_count_(default_max_upload_count),
|
max_upload_count_(default_max_upload_count),
|
||||||
@ -88,14 +86,9 @@ app_config::app_config(const provider_type &prov,
|
|||||||
orphaned_file_retention_days_(default_orphaned_file_retention_days),
|
orphaned_file_retention_days_(default_orphaned_file_retention_days),
|
||||||
preferred_download_type_(
|
preferred_download_type_(
|
||||||
download_type_to_string(download_type::fallback)),
|
download_type_to_string(download_type::fallback)),
|
||||||
read_ahead_count_(default_read_ahead_count),
|
|
||||||
remote_client_pool_size_(default_remote_client_pool_size),
|
remote_client_pool_size_(default_remote_client_pool_size),
|
||||||
remote_host_name_or_ip_(default_remote_host_name_or_ip),
|
remote_api_port_(default_remote_api_port(prov)),
|
||||||
remote_max_connections_(default_remote_max_connections),
|
remote_encryption_token_(default_remote_encryption_token),
|
||||||
remote_port_(default_remote_port(prov)),
|
|
||||||
remote_receive_timeout_secs_(default_remote_receive_timeout_secs),
|
|
||||||
remote_send_timeout_secs_(default_remote_send_timeout_secs),
|
|
||||||
remote_token_(default_remote_token),
|
|
||||||
retry_read_count_(default_retry_read_count),
|
retry_read_count_(default_retry_read_count),
|
||||||
ring_buffer_file_size_(default_ring_buffer_file_size),
|
ring_buffer_file_size_(default_ring_buffer_file_size),
|
||||||
task_wait_ms_(default_task_wait_ms) {
|
task_wait_ms_(default_task_wait_ms) {
|
||||||
@ -182,7 +175,7 @@ auto app_config::default_data_directory(const provider_type &prov)
|
|||||||
return data_directory;
|
return data_directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto app_config::default_remote_port(const provider_type &prov)
|
auto app_config::default_remote_api_port(const provider_type &prov)
|
||||||
-> std::uint16_t {
|
-> std::uint16_t {
|
||||||
static const std::array<std::uint16_t,
|
static const std::array<std::uint16_t,
|
||||||
static_cast<std::size_t>(provider_type::unknown)>
|
static_cast<std::size_t>(provider_type::unknown)>
|
||||||
@ -237,19 +230,13 @@ auto app_config::get_json() const -> json {
|
|||||||
{"OnlineCheckRetrySeconds", online_check_retry_secs_},
|
{"OnlineCheckRetrySeconds", online_check_retry_secs_},
|
||||||
{"OrphanedFileRetentionDays", orphaned_file_retention_days_},
|
{"OrphanedFileRetentionDays", orphaned_file_retention_days_},
|
||||||
{"PreferredDownloadType", preferred_download_type_},
|
{"PreferredDownloadType", preferred_download_type_},
|
||||||
{"ReadAheadCount", read_ahead_count_},
|
|
||||||
{
|
{
|
||||||
"RemoteMount",
|
"RemoteMount",
|
||||||
{
|
{
|
||||||
{"EnableRemoteMount", enable_remote_mount_},
|
{"EnableRemoteMount", enable_remote_mount_},
|
||||||
{"IsRemoteMount", is_remote_mount_},
|
{"ClientPoolSize", remote_client_pool_size_},
|
||||||
{"RemoteClientPoolSize", remote_client_pool_size_},
|
{"ApiPort", remote_api_port_},
|
||||||
{"RemoteMaxConnections", remote_max_connections_},
|
{"EncryptionToken", remote_encryption_token_},
|
||||||
{"RemoteHostNameOrIp", remote_host_name_or_ip_},
|
|
||||||
{"RemotePort", remote_port_},
|
|
||||||
{"RemoteReceiveTimeoutSeconds", remote_receive_timeout_secs_},
|
|
||||||
{"RemoteSendTimeoutSeconds", remote_send_timeout_secs_},
|
|
||||||
{"RemoteToken", remote_token_},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{"RetryReadCount", retry_read_count_},
|
{"RetryReadCount", retry_read_count_},
|
||||||
@ -271,7 +258,7 @@ auto app_config::get_json() const -> json {
|
|||||||
ret.erase("OnlineCheckRetrySeconds");
|
ret.erase("OnlineCheckRetrySeconds");
|
||||||
ret.erase("OrphanedFileRetentionDays");
|
ret.erase("OrphanedFileRetentionDays");
|
||||||
ret.erase("PreferredDownloadType");
|
ret.erase("PreferredDownloadType");
|
||||||
ret.erase("ReadAheadCount");
|
ret.erase("RemoteConfig");
|
||||||
ret.erase("RetryReadCount");
|
ret.erase("RetryReadCount");
|
||||||
ret.erase("RingBufferFileSize");
|
ret.erase("RingBufferFileSize");
|
||||||
ret.erase("S3Config");
|
ret.erase("S3Config");
|
||||||
@ -279,15 +266,16 @@ auto app_config::get_json() const -> json {
|
|||||||
} else if (prov_ == provider_type::s3) {
|
} else if (prov_ == provider_type::s3) {
|
||||||
ret.erase("EncryptConfig");
|
ret.erase("EncryptConfig");
|
||||||
ret.erase("HostConfig");
|
ret.erase("HostConfig");
|
||||||
|
ret.erase("RemoteConfig");
|
||||||
ret.erase("SiaConfig");
|
ret.erase("SiaConfig");
|
||||||
} else if (prov_ == provider_type::sia) {
|
} else if (prov_ == provider_type::sia) {
|
||||||
ret.erase("EncryptConfig");
|
ret.erase("EncryptConfig");
|
||||||
|
ret.erase("RemoteConfig");
|
||||||
ret.erase("S3Config");
|
ret.erase("S3Config");
|
||||||
} else if (prov_ == provider_type::remote) {
|
} else if (prov_ == provider_type::remote) {
|
||||||
ret.erase("ChunkDownloaderTimeoutSeconds");
|
ret.erase("ChunkDownloaderTimeoutSeconds");
|
||||||
ret.erase("DatabaseType");
|
ret.erase("DatabaseType");
|
||||||
ret.erase("EnableChunkDownloaderTimeout");
|
ret.erase("EnableChunkDownloaderTimeout");
|
||||||
ret.erase("EnableChunkDownloaderTimeout");
|
|
||||||
ret.erase("EnableMaxCacheSize");
|
ret.erase("EnableMaxCacheSize");
|
||||||
ret.erase("EncryptConfig");
|
ret.erase("EncryptConfig");
|
||||||
ret.erase("EvictionDelayMinutes");
|
ret.erase("EvictionDelayMinutes");
|
||||||
@ -300,7 +288,7 @@ auto app_config::get_json() const -> json {
|
|||||||
ret.erase("OnlineCheckRetrySeconds");
|
ret.erase("OnlineCheckRetrySeconds");
|
||||||
ret.erase("OrphanedFileRetentionDays");
|
ret.erase("OrphanedFileRetentionDays");
|
||||||
ret.erase("PreferredDownloadType");
|
ret.erase("PreferredDownloadType");
|
||||||
ret.erase("ReadAheadCount");
|
ret.erase("RemoteMount");
|
||||||
ret.erase("RetryReadCount");
|
ret.erase("RetryReadCount");
|
||||||
ret.erase("RingBufferFileSize");
|
ret.erase("RingBufferFileSize");
|
||||||
ret.erase("S3Config");
|
ret.erase("S3Config");
|
||||||
@ -434,35 +422,17 @@ auto app_config::get_value_by_name(const std::string &name) const
|
|||||||
return download_type_to_string(download_type_from_string(
|
return download_type_to_string(download_type_from_string(
|
||||||
preferred_download_type_, download_type::fallback));
|
preferred_download_type_, download_type::fallback));
|
||||||
}
|
}
|
||||||
if (name == "ReadAheadCount") {
|
if (name == "RemoteMount.Enable") {
|
||||||
return std::to_string(get_read_ahead_count());
|
|
||||||
}
|
|
||||||
if (name == "RemoteMount.EnableRemoteMount") {
|
|
||||||
return utils::string::from_bool(get_enable_remote_mount());
|
return utils::string::from_bool(get_enable_remote_mount());
|
||||||
}
|
}
|
||||||
if (name == "RemoteMount.IsRemoteMount") {
|
if (name == "RemoteMount.ClientPoolSize") {
|
||||||
return utils::string::from_bool(get_is_remote_mount());
|
|
||||||
}
|
|
||||||
if (name == "RemoteMount.RemoteClientPoolSize") {
|
|
||||||
return std::to_string(get_remote_client_pool_size());
|
return std::to_string(get_remote_client_pool_size());
|
||||||
}
|
}
|
||||||
if (name == "RemoteMount.RemoteHostNameOrIp") {
|
if (name == "RemoteMount.ApiPort") {
|
||||||
return get_remote_host_name_or_ip();
|
return std::to_string(get_remote_api_port());
|
||||||
}
|
}
|
||||||
if (name == "RemoteMount.RemoteMaxConnections") {
|
if (name == "RemoteMount.EncryptionToken") {
|
||||||
return std::to_string(get_remote_max_connections());
|
return get_remote_encryption_token();
|
||||||
}
|
|
||||||
if (name == "RemoteMount.RemotePort") {
|
|
||||||
return std::to_string(get_remote_port());
|
|
||||||
}
|
|
||||||
if (name == "RemoteMount.RemoteReceiveTimeoutSeconds") {
|
|
||||||
return std::to_string(get_remote_receive_timeout_secs());
|
|
||||||
}
|
|
||||||
if (name == "RemoteMount.RemoteSendTimeoutSeconds") {
|
|
||||||
return std::to_string(get_remote_send_timeout_secs());
|
|
||||||
}
|
|
||||||
if (name == "RemoteMount.RemoteToken") {
|
|
||||||
return get_remote_token();
|
|
||||||
}
|
}
|
||||||
if (name == "RetryReadCount") {
|
if (name == "RetryReadCount") {
|
||||||
return std::to_string(get_retry_read_count());
|
return std::to_string(get_retry_read_count());
|
||||||
@ -576,7 +546,6 @@ auto app_config::load() -> bool {
|
|||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
get_value(json_document, "ReadAheadCount", read_ahead_count_, ret);
|
|
||||||
get_value(json_document, "RingBufferFileSize", ring_buffer_file_size_,
|
get_value(json_document, "RingBufferFileSize", ring_buffer_file_size_,
|
||||||
ret);
|
ret);
|
||||||
get_value(json_document, "TaskWaitMillis", task_wait_ms_, ret);
|
get_value(json_document, "TaskWaitMillis", task_wait_ms_, ret);
|
||||||
@ -603,22 +572,13 @@ auto app_config::load() -> bool {
|
|||||||
preferred_download_type_, ret);
|
preferred_download_type_, ret);
|
||||||
get_value(json_document, "RetryReadCount", retry_read_count_, ret);
|
get_value(json_document, "RetryReadCount", retry_read_count_, ret);
|
||||||
if (json_document.find("RemoteMount") != json_document.end()) {
|
if (json_document.find("RemoteMount") != json_document.end()) {
|
||||||
auto remoteMount = json_document["RemoteMount"];
|
auto remoteMount = json_document.at("RemoteMount");
|
||||||
get_value(remoteMount, "EnableRemoteMount", enable_remote_mount_,
|
get_value(remoteMount, "Enable", enable_remote_mount_, ret);
|
||||||
|
get_value(remoteMount, "ClientPoolSize", remote_client_pool_size_,
|
||||||
|
ret);
|
||||||
|
get_value(remoteMount, "ApiPort", remote_api_port_, ret);
|
||||||
|
get_value(remoteMount, "EncryptionToken", remote_encryption_token_,
|
||||||
ret);
|
ret);
|
||||||
get_value(remoteMount, "IsRemoteMount", is_remote_mount_, ret);
|
|
||||||
get_value(remoteMount, "RemoteClientPoolSize",
|
|
||||||
remote_client_pool_size_, ret);
|
|
||||||
get_value(remoteMount, "RemoteHostNameOrIp",
|
|
||||||
remote_host_name_or_ip_, ret);
|
|
||||||
get_value(remoteMount, "RemoteMaxConnections",
|
|
||||||
remote_max_connections_, ret);
|
|
||||||
get_value(remoteMount, "RemotePort", remote_port_, ret);
|
|
||||||
get_value(remoteMount, "RemoteReceiveTimeoutSeconds",
|
|
||||||
remote_receive_timeout_secs_, ret);
|
|
||||||
get_value(remoteMount, "RemoteSendTimeoutSeconds",
|
|
||||||
remote_send_timeout_secs_, ret);
|
|
||||||
get_value(remoteMount, "RemoteToken", remote_token_, ret);
|
|
||||||
} else {
|
} else {
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
@ -677,11 +637,6 @@ void app_config::save() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void app_config::set_enable_remote_mount(bool enable_remote_mount) {
|
void app_config::set_enable_remote_mount(bool enable_remote_mount) {
|
||||||
if (get_is_remote_mount()) {
|
|
||||||
set_value(enable_remote_mount_, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
set_value(enable_remote_mount_, enable_remote_mount);
|
set_value(enable_remote_mount_, enable_remote_mount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -691,19 +646,14 @@ void app_config::set_encrypt_config(encrypt_config cfg) {
|
|||||||
|
|
||||||
void app_config::set_host_config(host_config cfg) { set_value(hc_, cfg); }
|
void app_config::set_host_config(host_config cfg) { set_value(hc_, cfg); }
|
||||||
|
|
||||||
|
void app_config::set_remote_config(remote::remote_config cfg) {
|
||||||
|
set_value(remote_config_, cfg);
|
||||||
|
}
|
||||||
|
|
||||||
void app_config::set_s3_config(s3_config cfg) { set_value(s3_config_, cfg); }
|
void app_config::set_s3_config(s3_config cfg) { set_value(s3_config_, cfg); }
|
||||||
|
|
||||||
void app_config::set_sia_config(sia_config cfg) { set_value(sia_config_, cfg); }
|
void app_config::set_sia_config(sia_config cfg) { set_value(sia_config_, cfg); }
|
||||||
|
|
||||||
void app_config::set_is_remote_mount(bool is_remote_mount) {
|
|
||||||
if (get_enable_remote_mount()) {
|
|
||||||
set_value(is_remote_mount_, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
set_value(is_remote_mount_, is_remote_mount);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto app_config::set_value_by_name(const std::string &name,
|
auto app_config::set_value_by_name(const std::string &name,
|
||||||
const std::string &value) -> std::string {
|
const std::string &value) -> std::string {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
@ -839,45 +789,21 @@ auto app_config::set_value_by_name(const std::string &name,
|
|||||||
download_type_from_string(value, download_type::fallback));
|
download_type_from_string(value, download_type::fallback));
|
||||||
return download_type_to_string(get_preferred_download_type());
|
return download_type_to_string(get_preferred_download_type());
|
||||||
}
|
}
|
||||||
if (name == "ReadAheadCount") {
|
if (name == "RemoteMount.ApiPort") {
|
||||||
set_read_ahead_count(utils::string::to_uint8(value));
|
set_remote_api_port(utils::string::to_uint16(value));
|
||||||
return std::to_string(get_read_ahead_count());
|
return std::to_string(get_remote_api_port());
|
||||||
}
|
}
|
||||||
if (name == "RemoteMount.EnableRemoteMount") {
|
if (name == "RemoteMount.ClientPoolSize") {
|
||||||
set_enable_remote_mount(utils::string::to_bool(value));
|
|
||||||
return utils::string::from_bool(get_enable_remote_mount());
|
|
||||||
}
|
|
||||||
if (name == "RemoteMount.IsRemoteMount") {
|
|
||||||
set_is_remote_mount(utils::string::to_bool(value));
|
|
||||||
return utils::string::from_bool(get_is_remote_mount());
|
|
||||||
}
|
|
||||||
if (name == "RemoteMount.RemoteClientPoolSize") {
|
|
||||||
set_remote_client_pool_size(utils::string::to_uint8(value));
|
set_remote_client_pool_size(utils::string::to_uint8(value));
|
||||||
return std::to_string(get_remote_client_pool_size());
|
return std::to_string(get_remote_client_pool_size());
|
||||||
}
|
}
|
||||||
if (name == "RemoteMount.RemoteHostNameOrIp") {
|
if (name == "RemoteMount.Enable") {
|
||||||
set_remote_host_name_or_ip(value);
|
set_enable_remote_mount(utils::string::to_bool(value));
|
||||||
return get_remote_host_name_or_ip();
|
return utils::string::from_bool(get_enable_remote_mount());
|
||||||
}
|
}
|
||||||
if (name == "RemoteMount.RemoteMaxConnections") {
|
if (name == "RemoteMount.EncryptionToken") {
|
||||||
set_remote_max_connections(utils::string::to_uint8(value));
|
set_remote_encryption_token(value);
|
||||||
return std::to_string(get_remote_max_connections());
|
return get_remote_encryption_token();
|
||||||
}
|
|
||||||
if (name == "RemoteMount.RemotePort") {
|
|
||||||
set_remote_port(utils::string::to_uint16(value));
|
|
||||||
return std::to_string(get_remote_port());
|
|
||||||
}
|
|
||||||
if (name == "RemoteMount.RemoteReceiveTimeoutSeconds") {
|
|
||||||
set_remote_receive_timeout_secs(utils::string::to_uint16(value));
|
|
||||||
return std::to_string(get_remote_receive_timeout_secs());
|
|
||||||
}
|
|
||||||
if (name == "RemoteMount.RemoteSendTimeoutSeconds") {
|
|
||||||
set_remote_send_timeout_secs(utils::string::to_uint16(value));
|
|
||||||
return std::to_string(get_remote_send_timeout_secs());
|
|
||||||
}
|
|
||||||
if (name == "RemoteMount.RemoteToken") {
|
|
||||||
set_remote_token(value);
|
|
||||||
return get_remote_token();
|
|
||||||
}
|
}
|
||||||
if (name == "RetryReadCount") {
|
if (name == "RetryReadCount") {
|
||||||
set_retry_read_count(utils::string::to_uint16(value));
|
set_retry_read_count(utils::string::to_uint16(value));
|
||||||
|
@ -38,18 +38,8 @@ E_SIMPLE2(packet_client_timeout, error, true,
|
|||||||
);
|
);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
packet_client::packet_client(std::string host_name_or_ip,
|
packet_client::packet_client(remote::remote_config cfg)
|
||||||
std::uint8_t max_connections, std::uint16_t port,
|
: cfg_(std::move(cfg)), unique_id_(utils::create_uuid_string()) {}
|
||||||
std::uint16_t receive_timeout,
|
|
||||||
std::uint16_t send_timeout,
|
|
||||||
std::string encryption_token)
|
|
||||||
: host_name_or_ip_(std::move(host_name_or_ip)),
|
|
||||||
max_connections_(max_connections == 0U ? 20U : max_connections),
|
|
||||||
port_(port),
|
|
||||||
receive_timeout_(receive_timeout),
|
|
||||||
send_timeout_(send_timeout),
|
|
||||||
encryption_token_(std::move(encryption_token)),
|
|
||||||
unique_id_(utils::create_uuid_string()) {}
|
|
||||||
|
|
||||||
packet_client::~packet_client() {
|
packet_client::~packet_client() {
|
||||||
allow_connections_ = false;
|
allow_connections_ = false;
|
||||||
@ -115,7 +105,7 @@ auto packet_client::get_client() -> std::shared_ptr<packet_client::client> {
|
|||||||
|
|
||||||
void packet_client::put_client(std::shared_ptr<client> &cli) {
|
void packet_client::put_client(std::shared_ptr<client> &cli) {
|
||||||
mutex_lock clientsLock(clients_mutex_);
|
mutex_lock clientsLock(clients_mutex_);
|
||||||
if (clients_.size() < max_connections_) {
|
if (clients_.size() < cfg_.max_connections) {
|
||||||
clients_.emplace_back(cli);
|
clients_.emplace_back(cli);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,7 +134,7 @@ auto packet_client::read_packet(client &cli, packet &response)
|
|||||||
read_buffer();
|
read_buffer();
|
||||||
response = std::move(buffer);
|
response = std::move(buffer);
|
||||||
|
|
||||||
auto ret = response.decrypt(encryption_token_);
|
auto ret = response.decrypt(cfg_.encryption_token);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = response.decode(cli.nonce);
|
ret = response.decode(cli.nonce);
|
||||||
}
|
}
|
||||||
@ -157,8 +147,9 @@ void packet_client::resolve() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve_results_ = tcp::resolver(io_context_)
|
resolve_results_ =
|
||||||
.resolve(host_name_or_ip_, std::to_string(port_));
|
tcp::resolver(io_context_)
|
||||||
|
.resolve(cfg_.host_name_or_ip, std::to_string(cfg_.api_port));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto packet_client::send(std::string_view method, std::uint32_t &service_flags)
|
auto packet_client::send(std::string_view method, std::uint32_t &service_flags)
|
||||||
@ -193,7 +184,7 @@ auto packet_client::send(std::string_view method, packet &request,
|
|||||||
if (current_client) {
|
if (current_client) {
|
||||||
try {
|
try {
|
||||||
request.encode_top(current_client->nonce);
|
request.encode_top(current_client->nonce);
|
||||||
request.encrypt(encryption_token_);
|
request.encrypt(cfg_.encryption_token);
|
||||||
|
|
||||||
timeout request_timeout(
|
timeout request_timeout(
|
||||||
[method, current_client]() {
|
[method, current_client]() {
|
||||||
@ -201,7 +192,7 @@ auto packet_client::send(std::string_view method, packet &request,
|
|||||||
"request", std::string{method});
|
"request", std::string{method});
|
||||||
packet_client::close(*current_client);
|
packet_client::close(*current_client);
|
||||||
},
|
},
|
||||||
std::chrono::seconds(send_timeout_));
|
std::chrono::milliseconds(cfg_.send_timeout_ms));
|
||||||
|
|
||||||
std::uint32_t offset{};
|
std::uint32_t offset{};
|
||||||
while (offset < request.get_size()) {
|
while (offset < request.get_size()) {
|
||||||
@ -223,7 +214,7 @@ auto packet_client::send(std::string_view method, packet &request,
|
|||||||
"response", std::string{method});
|
"response", std::string{method});
|
||||||
packet_client::close(*current_client);
|
packet_client::close(*current_client);
|
||||||
},
|
},
|
||||||
std::chrono::seconds(receive_timeout_));
|
std::chrono::milliseconds(cfg_.recv_timeout_ms));
|
||||||
|
|
||||||
ret = read_packet(*current_client, response);
|
ret = read_packet(*current_client, response);
|
||||||
response_timeout.disable();
|
response_timeout.disable();
|
||||||
|
@ -27,12 +27,7 @@
|
|||||||
|
|
||||||
namespace repertory::remote_fuse {
|
namespace repertory::remote_fuse {
|
||||||
remote_client::remote_client(const app_config &config)
|
remote_client::remote_client(const app_config &config)
|
||||||
: config_(config),
|
: config_(config), packet_client_(config.get_remote_config()) {}
|
||||||
packet_client_(
|
|
||||||
config.get_remote_host_name_or_ip(),
|
|
||||||
config.get_remote_max_connections(), config.get_remote_port(),
|
|
||||||
config.get_remote_receive_timeout_secs(),
|
|
||||||
config.get_remote_send_timeout_secs(), config.get_remote_token()) {}
|
|
||||||
|
|
||||||
auto remote_client::fuse_access(const char *path, const std::int32_t &mask)
|
auto remote_client::fuse_access(const char *path, const std::int32_t &mask)
|
||||||
-> packet::error_type {
|
-> packet::error_type {
|
||||||
|
@ -47,12 +47,7 @@ E_SIMPLE3(remote_winfsp_client_event, debug, true,
|
|||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
remote_client::remote_client(const app_config &config)
|
remote_client::remote_client(const app_config &config)
|
||||||
: config_(config),
|
: config_(config), packet_client_(config.get_remote_config()) {}
|
||||||
packet_client_(
|
|
||||||
config.get_remote_host_name_or_ip(),
|
|
||||||
config.get_remote_max_connections(), config.get_remote_port(),
|
|
||||||
config.get_remote_receive_timeout_secs(),
|
|
||||||
config.get_remote_send_timeout_secs(), config.get_remote_token()) {}
|
|
||||||
|
|
||||||
auto remote_client::winfsp_can_delete(PVOID file_desc, PWSTR file_name)
|
auto remote_client::winfsp_can_delete(PVOID file_desc, PWSTR file_name)
|
||||||
-> packet::error_type {
|
-> packet::error_type {
|
||||||
|
@ -71,11 +71,10 @@ mount(std::vector<const char *> args, std::string data_directory,
|
|||||||
if (generate_config) {
|
if (generate_config) {
|
||||||
app_config config(prov, data_directory);
|
app_config config(prov, data_directory);
|
||||||
if (prov == provider_type::remote) {
|
if (prov == provider_type::remote) {
|
||||||
config.set_enable_remote_mount(false);
|
auto cfg = config.get_remote_config();
|
||||||
config.set_is_remote_mount(true);
|
cfg.host_name_or_ip = remote_host;
|
||||||
config.set_remote_host_name_or_ip(remote_host);
|
cfg.api_port = remote_port;
|
||||||
config.set_remote_port(remote_port);
|
config.set_remote_config(cfg);
|
||||||
config.save();
|
|
||||||
} else if (prov == provider_type::sia &&
|
} else if (prov == provider_type::sia &&
|
||||||
config.get_sia_config().bucket.empty()) {
|
config.get_sia_config().bucket.empty()) {
|
||||||
config.set_value_by_name("SiaConfig.Bucket", unique_id);
|
config.set_value_by_name("SiaConfig.Bucket", unique_id);
|
||||||
@ -128,12 +127,12 @@ mount(std::vector<const char *> args, std::string data_directory,
|
|||||||
if (prov == provider_type::remote) {
|
if (prov == provider_type::remote) {
|
||||||
std::uint16_t port{0U};
|
std::uint16_t port{0U};
|
||||||
if (utils::get_next_available_port(config.get_api_port(), port)) {
|
if (utils::get_next_available_port(config.get_api_port(), port)) {
|
||||||
config.set_remote_host_name_or_ip(remote_host);
|
auto cfg = config.get_remote_config();
|
||||||
config.set_remote_port(remote_port);
|
cfg.host_name_or_ip = remote_host;
|
||||||
|
cfg.api_port = remote_port;
|
||||||
|
config.set_remote_config(cfg);
|
||||||
config.set_api_port(port);
|
config.set_api_port(port);
|
||||||
config.set_is_remote_mount(true);
|
|
||||||
config.set_enable_remote_mount(false);
|
|
||||||
config.save();
|
|
||||||
try {
|
try {
|
||||||
remote_drive drive(
|
remote_drive drive(
|
||||||
config,
|
config,
|
||||||
@ -161,8 +160,6 @@ mount(std::vector<const char *> args, std::string data_directory,
|
|||||||
config.set_value_by_name("SiaConfig.Bucket", unique_id);
|
config.set_value_by_name("SiaConfig.Bucket", unique_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
config.set_is_remote_mount(false);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto provider = create_provider(prov, config);
|
auto provider = create_provider(prov, config);
|
||||||
repertory_drive drive(config, lock, *provider);
|
repertory_drive drive(config, lock, *provider);
|
||||||
|
@ -86,17 +86,11 @@ const auto DEFAULT_SIA_CONFIG = "{\n"
|
|||||||
" \"OnlineCheckRetrySeconds\": 60,\n"
|
" \"OnlineCheckRetrySeconds\": 60,\n"
|
||||||
" \"OrphanedFileRetentionDays\": 15,\n"
|
" \"OrphanedFileRetentionDays\": 15,\n"
|
||||||
" \"PreferredDownloadType\": \"fallback\",\n"
|
" \"PreferredDownloadType\": \"fallback\",\n"
|
||||||
" \"ReadAheadCount\": 4,\n"
|
|
||||||
" \"RemoteMount\": {\n"
|
" \"RemoteMount\": {\n"
|
||||||
" \"EnableRemoteMount\": false,\n"
|
" \"Enable\": false,\n"
|
||||||
" \"IsRemoteMount\": false,\n"
|
" \"ClientPoolSize\": 10,\n"
|
||||||
" \"RemoteClientPoolSize\": 10,\n"
|
" \"ApiPort\": 20000,\n"
|
||||||
" \"RemoteHostNameOrIp\": \"\",\n"
|
" \"EncryptionToken\": \"\"\n"
|
||||||
" \"RemoteMaxConnections\": 20,\n"
|
|
||||||
" \"RemotePort\": 20000,\n"
|
|
||||||
" \"RemoteReceiveTimeoutSeconds\": 120,\n"
|
|
||||||
" \"RemoteSendTimeoutSeconds\": 30,\n"
|
|
||||||
" \"RemoteToken\": \"\"\n"
|
|
||||||
" },\n"
|
" },\n"
|
||||||
" \"RetryReadCount\": 6,\n"
|
" \"RetryReadCount\": 6,\n"
|
||||||
" \"RingBufferFileSize\": 512,\n"
|
" \"RingBufferFileSize\": 512,\n"
|
||||||
@ -133,17 +127,11 @@ const auto DEFAULT_S3_CONFIG = "{\n"
|
|||||||
" \"OnlineCheckRetrySeconds\": 60,\n"
|
" \"OnlineCheckRetrySeconds\": 60,\n"
|
||||||
" \"OrphanedFileRetentionDays\": 15,\n"
|
" \"OrphanedFileRetentionDays\": 15,\n"
|
||||||
" \"PreferredDownloadType\": \"fallback\",\n"
|
" \"PreferredDownloadType\": \"fallback\",\n"
|
||||||
" \"ReadAheadCount\": 4,\n"
|
|
||||||
" \"RemoteMount\": {\n"
|
" \"RemoteMount\": {\n"
|
||||||
" \"EnableRemoteMount\": false,\n"
|
" \"Enable\": false,\n"
|
||||||
" \"IsRemoteMount\": false,\n"
|
" \"ClientPoolSize\": 10,\n"
|
||||||
" \"RemoteClientPoolSize\": 10,\n"
|
" \"ApiPort\": 20100,\n"
|
||||||
" \"RemoteHostNameOrIp\": \"\",\n"
|
" \"EncryptionToken\": \"\"\n"
|
||||||
" \"RemoteMaxConnections\": 20,\n"
|
|
||||||
" \"RemotePort\": 20100,\n"
|
|
||||||
" \"RemoteReceiveTimeoutSeconds\": 120,\n"
|
|
||||||
" \"RemoteSendTimeoutSeconds\": 30,\n"
|
|
||||||
" \"RemoteToken\": \"\"\n"
|
|
||||||
" },\n"
|
" },\n"
|
||||||
" \"RetryReadCount\": 6,\n"
|
" \"RetryReadCount\": 6,\n"
|
||||||
" \"RingBufferFileSize\": 512,\n"
|
" \"RingBufferFileSize\": 512,\n"
|
||||||
@ -169,7 +157,7 @@ TEST_F(config_test, sia_default_settings) {
|
|||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
app_config config(provider_type::sia, sia_directory);
|
app_config config(provider_type::sia, sia_directory);
|
||||||
config.set_remote_token("");
|
config.set_remote_encryption_token("");
|
||||||
config.set_api_auth("");
|
config.set_api_auth("");
|
||||||
EXPECT_TRUE(config.set_value_by_name("HostConfig.ApiPassword", "").empty());
|
EXPECT_TRUE(config.set_value_by_name("HostConfig.ApiPassword", "").empty());
|
||||||
json data;
|
json data;
|
||||||
@ -189,7 +177,7 @@ TEST_F(config_test, s3_default_settings) {
|
|||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
app_config config(provider_type::s3, s3_directory);
|
app_config config(provider_type::s3, s3_directory);
|
||||||
config.set_remote_token("");
|
config.set_remote_encryption_token("");
|
||||||
config.set_api_auth("");
|
config.set_api_auth("");
|
||||||
json data;
|
json data;
|
||||||
EXPECT_TRUE(utils::file::read_json_file(config_file, data));
|
EXPECT_TRUE(utils::file::read_json_file(config_file, data));
|
||||||
@ -504,20 +492,6 @@ TEST_F(config_test, orphaned_file_retention_days_maximum_value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(config_test, read_ahead_count) {
|
|
||||||
std::uint8_t original_value{};
|
|
||||||
{
|
|
||||||
app_config config(provider_type::sia, sia_directory);
|
|
||||||
original_value = config.get_read_ahead_count();
|
|
||||||
config.set_read_ahead_count(original_value + 5);
|
|
||||||
EXPECT_EQ(original_value + 5, config.get_read_ahead_count());
|
|
||||||
}
|
|
||||||
{
|
|
||||||
app_config config(provider_type::sia, sia_directory);
|
|
||||||
EXPECT_EQ(original_value + 5, config.get_read_ahead_count());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(config_test, get_cache_directory) {
|
TEST_F(config_test, get_cache_directory) {
|
||||||
{
|
{
|
||||||
app_config config(provider_type::sia, sia_directory);
|
app_config config(provider_type::sia, sia_directory);
|
||||||
@ -668,99 +642,102 @@ TEST_F(config_test, enable_remote_mount) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(config_test, is_remote_mount) {
|
// TEST_F(config_test, is_remote_mount) {
|
||||||
bool original_value{};
|
// bool original_value{};
|
||||||
{
|
// {
|
||||||
app_config config(provider_type::sia, sia_directory);
|
// app_config config(provider_type::sia, sia_directory);
|
||||||
original_value = config.get_is_remote_mount();
|
// original_value = config.get_is_remote_mount();
|
||||||
config.set_is_remote_mount(not original_value);
|
// config.set_is_remote_mount(not original_value);
|
||||||
EXPECT_EQ(not original_value, config.get_is_remote_mount());
|
// EXPECT_EQ(not original_value, config.get_is_remote_mount());
|
||||||
}
|
// }
|
||||||
{
|
// {
|
||||||
app_config config(provider_type::sia, sia_directory);
|
// app_config config(provider_type::sia, sia_directory);
|
||||||
EXPECT_EQ(not original_value, config.get_is_remote_mount());
|
// EXPECT_EQ(not original_value, config.get_is_remote_mount());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
TEST_F(config_test, enable_remote_mount_fails_if_remote_mount_is_true) {
|
// TEST_F(config_test, enable_remote_mount_fails_if_remote_mount_is_true) {
|
||||||
app_config config(provider_type::sia, sia_directory);
|
// app_config config(provider_type::sia, sia_directory);
|
||||||
config.set_is_remote_mount(true);
|
// config.set_is_remote_mount(true);
|
||||||
config.set_enable_remote_mount(true);
|
// config.set_enable_remote_mount(true);
|
||||||
EXPECT_FALSE(config.get_enable_remote_mount());
|
// EXPECT_FALSE(config.get_enable_remote_mount());
|
||||||
EXPECT_TRUE(config.get_is_remote_mount());
|
// EXPECT_TRUE(config.get_is_remote_mount());
|
||||||
}
|
// }
|
||||||
|
|
||||||
TEST_F(config_test, set_is_remote_mount_fails_if_enable_remote_mount_is_true) {
|
// TEST_F(config_test, set_is_remote_mount_fails_if_enable_remote_mount_is_true)
|
||||||
app_config config(provider_type::sia, sia_directory);
|
// {
|
||||||
config.set_enable_remote_mount(true);
|
// app_config config(provider_type::sia, sia_directory);
|
||||||
config.set_is_remote_mount(true);
|
// config.set_enable_remote_mount(true);
|
||||||
EXPECT_FALSE(config.get_is_remote_mount());
|
// config.set_is_remote_mount(true);
|
||||||
EXPECT_TRUE(config.get_enable_remote_mount());
|
// EXPECT_FALSE(config.get_is_remote_mount());
|
||||||
}
|
// EXPECT_TRUE(config.get_enable_remote_mount());
|
||||||
|
// }
|
||||||
|
|
||||||
TEST_F(config_test, remote_host_name_or_ip) {
|
// TEST_F(config_test, remote_host_name_or_ip) {
|
||||||
{
|
// {
|
||||||
app_config config(provider_type::sia, sia_directory);
|
// app_config config(provider_type::sia, sia_directory);
|
||||||
config.set_remote_host_name_or_ip("my.host.name");
|
// config.set_remote_host_name_or_ip("my.host.name");
|
||||||
EXPECT_STREQ("my.host.name", config.get_remote_host_name_or_ip().c_str());
|
// EXPECT_STREQ("my.host.name",
|
||||||
}
|
// config.get_remote_host_name_or_ip().c_str());
|
||||||
{
|
// }
|
||||||
app_config config(provider_type::sia, sia_directory);
|
// {
|
||||||
EXPECT_STREQ("my.host.name", config.get_remote_host_name_or_ip().c_str());
|
// app_config config(provider_type::sia, sia_directory);
|
||||||
}
|
// EXPECT_STREQ("my.host.name",
|
||||||
}
|
// config.get_remote_host_name_or_ip().c_str());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
TEST_F(config_test, remote_port) {
|
TEST_F(config_test, remote_api_port) {
|
||||||
std::uint16_t original_value{};
|
std::uint16_t original_value{};
|
||||||
{
|
{
|
||||||
app_config config(provider_type::sia, sia_directory);
|
app_config config(provider_type::sia, sia_directory);
|
||||||
original_value = config.get_remote_port();
|
original_value = config.get_remote_api_port();
|
||||||
config.set_remote_port(original_value + 5);
|
config.set_remote_api_port(original_value + 5);
|
||||||
EXPECT_EQ(original_value + 5, config.get_remote_port());
|
EXPECT_EQ(original_value + 5, config.get_remote_api_port());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
app_config config(provider_type::sia, sia_directory);
|
app_config config(provider_type::sia, sia_directory);
|
||||||
EXPECT_EQ(original_value + 5, config.get_remote_port());
|
EXPECT_EQ(original_value + 5, config.get_remote_api_port());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(config_test, remote_receive_timeout_secs) {
|
// TEST_F(config_test, remote_receive_timeout_secs) {
|
||||||
std::uint16_t original_value{};
|
// std::uint16_t original_value{};
|
||||||
{
|
// {
|
||||||
app_config config(provider_type::sia, sia_directory);
|
// app_config config(provider_type::sia, sia_directory);
|
||||||
original_value = config.get_remote_receive_timeout_secs();
|
// original_value = config.get_remote_receive_timeout_secs();
|
||||||
config.set_remote_receive_timeout_secs(original_value + 5);
|
// config.set_remote_receive_timeout_secs(original_value + 5);
|
||||||
EXPECT_EQ(original_value + 5, config.get_remote_receive_timeout_secs());
|
// EXPECT_EQ(original_value + 5, config.get_remote_receive_timeout_secs());
|
||||||
}
|
// }
|
||||||
{
|
// {
|
||||||
app_config config(provider_type::sia, sia_directory);
|
// app_config config(provider_type::sia, sia_directory);
|
||||||
EXPECT_EQ(original_value + 5, config.get_remote_receive_timeout_secs());
|
// EXPECT_EQ(original_value + 5, config.get_remote_receive_timeout_secs());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
TEST_F(config_test, remote_send_timeout_secs) {
|
// TEST_F(config_test, remote_send_timeout_secs) {
|
||||||
std::uint16_t original_value{};
|
// std::uint16_t original_value{};
|
||||||
{
|
// {
|
||||||
app_config config(provider_type::sia, sia_directory);
|
// app_config config(provider_type::sia, sia_directory);
|
||||||
original_value = config.get_remote_send_timeout_secs();
|
// original_value = config.get_remote_send_timeout_secs();
|
||||||
config.set_remote_send_timeout_secs(original_value + 5);
|
// config.set_remote_send_timeout_secs(original_value + 5);
|
||||||
EXPECT_EQ(original_value + 5, config.get_remote_send_timeout_secs());
|
// EXPECT_EQ(original_value + 5, config.get_remote_send_timeout_secs());
|
||||||
}
|
// }
|
||||||
{
|
// {
|
||||||
app_config config(provider_type::sia, sia_directory);
|
// app_config config(provider_type::sia, sia_directory);
|
||||||
EXPECT_EQ(original_value + 5, config.get_remote_send_timeout_secs());
|
// EXPECT_EQ(original_value + 5, config.get_remote_send_timeout_secs());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
TEST_F(config_test, remote_token) {
|
TEST_F(config_test, remote_encryption_token) {
|
||||||
{
|
{
|
||||||
app_config config(provider_type::sia, sia_directory);
|
app_config config(provider_type::sia, sia_directory);
|
||||||
config.set_remote_token("myToken");
|
config.set_remote_encryption_token("myToken");
|
||||||
EXPECT_STREQ("myToken", config.get_remote_token().c_str());
|
EXPECT_STREQ("myToken", config.get_remote_encryption_token().c_str());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
app_config config(provider_type::sia, sia_directory);
|
app_config config(provider_type::sia, sia_directory);
|
||||||
EXPECT_STREQ("myToken", config.get_remote_token().c_str());
|
EXPECT_STREQ("myToken", config.get_remote_encryption_token().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -790,31 +767,31 @@ TEST_F(config_test, remote_client_pool_size_minimum_value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(config_test, remote_max_connections) {
|
// TEST_F(config_test, remote_max_connections) {
|
||||||
std::uint8_t original_value{};
|
// std::uint8_t original_value{};
|
||||||
{
|
// {
|
||||||
app_config config(provider_type::sia, sia_directory);
|
// app_config config(provider_type::sia, sia_directory);
|
||||||
original_value = config.get_remote_max_connections();
|
// original_value = config.get_remote_max_connections();
|
||||||
config.set_remote_max_connections(original_value + 5);
|
// config.set_remote_max_connections(original_value + 5);
|
||||||
EXPECT_EQ(original_value + 5, config.get_remote_max_connections());
|
// EXPECT_EQ(original_value + 5, config.get_remote_max_connections());
|
||||||
}
|
// }
|
||||||
{
|
// {
|
||||||
app_config config(provider_type::sia, sia_directory);
|
// app_config config(provider_type::sia, sia_directory);
|
||||||
EXPECT_EQ(original_value + 5, config.get_remote_max_connections());
|
// EXPECT_EQ(original_value + 5, config.get_remote_max_connections());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
TEST_F(config_test, remote_max_connections_minimum_value) {
|
// TEST_F(config_test, remote_max_connections_minimum_value) {
|
||||||
{
|
// {
|
||||||
app_config config(provider_type::sia, sia_directory);
|
// app_config config(provider_type::sia, sia_directory);
|
||||||
config.set_remote_max_connections(0);
|
// config.set_remote_max_connections(0);
|
||||||
EXPECT_EQ(1, config.get_remote_max_connections());
|
// EXPECT_EQ(1, config.get_remote_max_connections());
|
||||||
}
|
// }
|
||||||
{
|
// {
|
||||||
app_config config(provider_type::sia, sia_directory);
|
// app_config config(provider_type::sia, sia_directory);
|
||||||
EXPECT_EQ(1, config.get_remote_max_connections());
|
// EXPECT_EQ(1, config.get_remote_max_connections());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
TEST_F(config_test, retry_read_count) {
|
TEST_F(config_test, retry_read_count) {
|
||||||
std::uint16_t original_value{};
|
std::uint16_t original_value{};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user