diff --git a/include/opendht/dht_proxy_client.h b/include/opendht/dht_proxy_client.h index 0535f1005b8fd30f9692ccc4bd1f1db6c1a0d9ae..c85ef9c839d2be19c5bfd52a150c6dbe02b9d741 100644 --- a/include/opendht/dht_proxy_client.h +++ b/include/opendht/dht_proxy_client.h @@ -57,8 +57,11 @@ public: crypto::Identity clientIdentity, std::function<void()> loopSignal, const std::string& serverHost, - const std::string& pushClientId = "", const std::string& userAgent = "", + const std::string& pushClientId = "", + const std::string& pushToken = "", + const std::string& pushTopic = "", + const std::string& pushPlatform = "", std::shared_ptr<Logger> logger = {} ); @@ -356,10 +359,9 @@ private: std::string proxyUrl_; dht::crypto::Identity clientIdentity_; std::shared_ptr<dht::crypto::Certificate> serverCertificate_; - //std::pair<std::string, std::string> serverHostService_; + std::string userAgent_ {"OpenDHT"}; std::string pushClientId_; std::string pushSessionId_; - std::string userAgent_ {"OpenDHT"}; mutable std::mutex lockCurrentProxyInfos_; NodeStatus statusIpv4_ {NodeStatus::Disconnected}; diff --git a/src/dht_proxy_client.cpp b/src/dht_proxy_client.cpp index f2dc8c3a4fc8b2b219ca0997e007df675119399c..21dd6730c23ca76acf42aebe588b9d4054e1aaf2 100644 --- a/src/dht_proxy_client.cpp +++ b/src/dht_proxy_client.cpp @@ -106,15 +106,26 @@ getRandomSessionId(size_t length = 8) { DhtProxyClient::DhtProxyClient() {} DhtProxyClient::DhtProxyClient( - std::shared_ptr<dht::crypto::Certificate> serverCA, dht::crypto::Identity clientIdentity, - std::function<void()> signal, const std::string& serverHost, - const std::string& pushClientId, const std::string& userAgent, std::shared_ptr<dht::Logger> logger) + std::shared_ptr<dht::crypto::Certificate> serverCA, + dht::crypto::Identity clientIdentity, + std::function<void()> signal, + const std::string& serverHost, + const std::string& userAgent, + const std::string& pushClientId, + const std::string& pushToken, + const std::string& pushTopic, + const std::string& pushPlatform, + std::shared_ptr<dht::Logger> logger +) : DhtInterface(logger) , proxyUrl_(serverHost) , clientIdentity_(clientIdentity), serverCertificate_(serverCA) + , userAgent_(userAgent) , pushClientId_(pushClientId) , pushSessionId_(getRandomSessionId()) - , userAgent_(userAgent) + , deviceKey_(pushToken) + , notificationTopic_(pushTopic) + , platform_(pushPlatform) , loopSignal_(signal) , jsonReader_(Json::CharReaderBuilder{}.newCharReader()) { diff --git a/src/dhtrunner.cpp b/src/dhtrunner.cpp index 439c8c9fc02eded40d916a96062a7be6750861eb..e1965d273fb70250faa1b6cb458b79fb96cddb90 100644 --- a/src/dhtrunner.cpp +++ b/src/dhtrunner.cpp @@ -1120,13 +1120,13 @@ DhtRunner::enableProxy(bool proxify) cv.notify_all(); } }, - config_.proxy_server, config_.push_node_id, config_.proxy_user_agent, logger_); - if (not config_.push_token.empty()) - dht_via_proxy->setPushNotificationToken(config_.push_token); - if (not config_.push_topic.empty()) - dht_via_proxy->setPushNotificationTopic(config_.push_topic); - if (not config_.push_platform.empty()) - dht_via_proxy->setPushNotificationPlatform(config_.push_platform); + config_.proxy_server, + config_.proxy_user_agent, + config_.push_node_id, + config_.push_token, + config_.push_topic, + config_.push_platform, + logger_); dht_ = std::make_unique<SecureDht>(std::move(dht_via_proxy), config_.dht_config, identityAnnouncedCb_, logger_); // and use it use_proxy = proxify;