Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RCPP-6, RCPP-83: Improve networking #216

Merged
merged 41 commits into from
Jul 17, 2024
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
33f499c
Begin adding flexible networking
leemaguire Jun 7, 2024
316bedc
Move network code into its own files
leemaguire Jun 10, 2024
72f3cd2
Add bones for platform networking
leemaguire Jun 10, 2024
e1a9840
Add factory for http transport
leemaguire Jun 10, 2024
5671bdd
cleanup default network transport
leemaguire Jun 10, 2024
6b5ee3c
Add platform networking
leemaguire Jun 13, 2024
2c12b8f
Cleanup, add docs
leemaguire Jun 17, 2024
143bb35
Playing with proxy
leemaguire Jun 25, 2024
509aefd
Networking checkpoint
leemaguire Jul 3, 2024
aec653a
Networking checkpoint
leemaguire Jul 5, 2024
81034b1
Cleanup
leemaguire Jul 8, 2024
df84751
Cleanup
leemaguire Jul 8, 2024
0768165
Add boost to GHA runners
leemaguire Jul 8, 2024
7c90688
Dont use boost for asio
leemaguire Jul 8, 2024
621bb1c
Fix tests
leemaguire Jul 8, 2024
0507774
Fix tests
leemaguire Jul 8, 2024
b4c3031
Fix tests
leemaguire Jul 8, 2024
e28f613
Fix tests
leemaguire Jul 8, 2024
ba0320e
Fix tests
leemaguire Jul 8, 2024
a9d57ea
Begin cleanup
leemaguire Jul 10, 2024
85796b8
Add SSL configuration
leemaguire Jul 10, 2024
bfeb61c
Update tests
leemaguire Jul 10, 2024
3cc3d0b
Update tests
leemaguire Jul 10, 2024
c93dfcd
Cleanup
leemaguire Jul 11, 2024
f874f9a
Cleanup
leemaguire Jul 11, 2024
c62ef0a
Fix tests
leemaguire Jul 11, 2024
0bfd4bb
point to yg/openssl-native-ca
leemaguire Jul 11, 2024
9a2e507
Try out use_default_verify
leemaguire Jul 11, 2024
9ffec41
Add back use_included_certificate_roots
leemaguire Jul 12, 2024
b61d9fe
Cleanup TODO
leemaguire Jul 12, 2024
65af4a1
Cleanup, add SSL verify callback
leemaguire Jul 15, 2024
5bd2e6b
Fix compilation
leemaguire Jul 15, 2024
8cf8fd2
Fix compilation
leemaguire Jul 15, 2024
cf7119d
split interfaces into http and websocket headers
leemaguire Jul 15, 2024
4389342
split interfaces into http and websocket headers
leemaguire Jul 15, 2024
4fb16ec
split interfaces into http and websocket headers
leemaguire Jul 15, 2024
e443f39
split interfaces into http and websocket headers
leemaguire Jul 15, 2024
5ddcab1
split interfaces into http and websocket headers
leemaguire Jul 16, 2024
8ec6316
split interfaces into http and websocket headers
leemaguire Jul 16, 2024
97ea134
Address feedback
leemaguire Jul 16, 2024
71e658c
Address feedback, remove curl and NSURLSession transport
leemaguire Jul 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add platform networking
  • Loading branch information
leemaguire committed Jul 16, 2024
commit 6b5ee3c18b8cce2896278088a35b7403954ef9e8
2 changes: 2 additions & 0 deletions include/cpprealm/app.hpp
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@
#include <cpprealm/internal/bridge/sync_session.hpp>
#include <cpprealm/internal/bridge/utils.hpp>
#include <cpprealm/networking/networking.hpp>
#include <cpprealm/networking/platform_networking.hpp>

#include <future>
#include <utility>
@@ -231,6 +232,7 @@ class App {
std::optional<std::array<char, 64>> metadata_encryption_key;
std::optional<sync_config::proxy_config> proxy_configuration;
std::shared_ptr<::realm::networking::websocket_event_handler> websocket_event_handler;
std::shared_ptr<::realm::networking::sync_socket_provider> sync_socket_provider;
};

[[deprecated("Use App(const configuration&) instead.")]]
2 changes: 1 addition & 1 deletion include/cpprealm/internal/bridge/status.hpp
Original file line number Diff line number Diff line change
@@ -61,7 +61,7 @@ namespace realm::internal::bridge {
};

struct status {

static status ok();
status(const ::realm::Status&);
status(::realm::Status&&);
status(const status&);
5 changes: 4 additions & 1 deletion include/cpprealm/networking/platform_networking.hpp
Original file line number Diff line number Diff line change
@@ -225,7 +225,7 @@ namespace realm::networking {
static std::optional<internal::bridge::realm::sync_config::proxy_config> proxy_config;

static std::shared_ptr<http_transport_client> make_default_http_client();
static void set_http_client_factory(std::shared_ptr<http_transport_client> (*factory)());
static void set_http_client_factory(std::function<std::shared_ptr<http_transport_client>()>&&);
};
}

@@ -236,6 +236,9 @@ namespace realm::internal::networking {
const std::shared_ptr<::realm::networking::websocket_event_handler>&);

std::shared_ptr<app::GenericNetworkTransport> create_http_client_shim(const std::shared_ptr<::realm::networking::http_transport_client>&);

std::unique_ptr<::realm::sync::SyncSocketProvider> create_sync_socket_provider_shim(const std::shared_ptr<::realm::networking::sync_socket_provider>& provider,
const std::shared_ptr<::realm::networking::websocket_event_handler>& handler);
}

#endif//CPPREALM_PLATFORM_NETWORKING_HPP
3 changes: 3 additions & 0 deletions src/cpprealm/app.cpp
Original file line number Diff line number Diff line change
@@ -500,6 +500,9 @@ namespace realm {
config.websocket_event_handler);
client_config.socket_provider = websocket_provider;
}
if (config.sync_socket_provider) {
client_config.socket_provider = ::realm::internal::networking::create_sync_socket_provider_shim(config.sync_socket_provider, config.websocket_event_handler);
}

networking::http_client_factory::custom_http_headers = config.custom_http_headers;
networking::http_client_factory::proxy_config = config.proxy_configuration;
4 changes: 4 additions & 0 deletions src/cpprealm/internal/bridge/status.cpp
Original file line number Diff line number Diff line change
@@ -24,6 +24,10 @@ namespace realm::internal::bridge {
return reinterpret_cast<const ErrorCategory*>(&m_error_category)->value();
}

status status::ok() {
return ::realm::Status::OK();
}

status::status(const ::realm::Status& other) {
#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
new (&m_status) Status(other);
14 changes: 7 additions & 7 deletions src/cpprealm/networking/platform_networking.cpp
Original file line number Diff line number Diff line change
@@ -5,16 +5,16 @@
#include <realm/util/platform_info.hpp>

namespace realm::networking {
std::shared_ptr<http_transport_client> (*s_http_client_factory)() = http_client_factory::make_default_http_client;
std::function<std::shared_ptr<http_transport_client>()> s_http_client_factory = http_client_factory::make_default_http_client;
std::optional<std::map<std::string, std::string>> http_client_factory::custom_http_headers = std::nullopt;
std::optional<internal::bridge::realm::sync_config::proxy_config> http_client_factory::proxy_config = std::nullopt;

std::shared_ptr<http_transport_client> http_client_factory::make_default_http_client() {
return std::make_shared<internal::networking::DefaultTransport>(custom_http_headers, proxy_config);
}

void http_client_factory::set_http_client_factory(std::shared_ptr<http_transport_client> (*factory)()) {
s_http_client_factory = std::move(factory);
void http_client_factory::set_http_client_factory(std::function<std::shared_ptr<http_transport_client>()>&& factory_fn) {
s_http_client_factory = std::move(factory_fn);
}
}

@@ -139,7 +139,7 @@ namespace realm::internal::networking {
return std::make_unique<core_websocket_observer_shim>(std::move(m_observer));
}

std::unique_ptr<::realm::sync::SyncSocketProvider> create_sync_socket_provider_shim(std::unique_ptr<::realm::networking::sync_socket_provider>&& provider,
std::unique_ptr<::realm::sync::SyncSocketProvider> create_sync_socket_provider_shim(const std::shared_ptr<::realm::networking::sync_socket_provider>& provider,
const std::shared_ptr<::realm::networking::websocket_event_handler>& handler) {

struct sync_timer_shim final : public ::realm::sync::SyncSocketProvider::Timer {
@@ -155,9 +155,9 @@ namespace realm::internal::networking {
};

struct sync_socket_provider_shim final : public ::realm::sync::SyncSocketProvider {
explicit sync_socket_provider_shim(std::unique_ptr<::realm::networking::sync_socket_provider>&& provider,
explicit sync_socket_provider_shim(const std::shared_ptr<::realm::networking::sync_socket_provider>& provider,
const std::shared_ptr<::realm::networking::websocket_event_handler>& handler) {
m_provider = std::move(provider);
m_provider = provider;
m_websocket_event_handler = handler;
}

@@ -191,7 +191,7 @@ namespace realm::internal::networking {
}
private:
std::shared_ptr<::realm::networking::websocket_event_handler> m_websocket_event_handler;
std::unique_ptr<::realm::networking::sync_socket_provider> m_provider;
std::shared_ptr<::realm::networking::sync_socket_provider> m_provider;
};

return std::make_unique<sync_socket_provider_shim>(std::move(provider), handler);