diff --git a/include/opendht/dht_proxy_server.h b/include/opendht/dht_proxy_server.h index 272cc975d7029d52fc2337e79c7658bb06f2788d..440d82b8ad77f93c84523a380c9e85e13f9ca435 100644 --- a/include/opendht/dht_proxy_server.h +++ b/include/opendht/dht_proxy_server.h @@ -66,7 +66,6 @@ struct OPENDHT_PUBLIC ProxyServerConfig { std::string address {}; in_port_t port {8000}; std::string pushServer {}; - std::string unifiedPushEndpoint {}; std::string persistStatePath {}; dht::crypto::Identity identity {}; std::string bundleId {}; @@ -426,7 +425,6 @@ private: mutable std::atomic<time_point> lastStatsReset_ {time_point::min()}; std::string pushServer_; - std::string unifiedPushEndpoint_; std::string bundleId_; #ifdef OPENDHT_PUSH_NOTIFICATIONS diff --git a/src/dht_proxy_server.cpp b/src/dht_proxy_server.cpp index c697fe73117b1749dad012bd906c2ed385cf1830..1b4b17729ba900c8b2251ac8ed4097cc6511adee 100644 --- a/src/dht_proxy_server.cpp +++ b/src/dht_proxy_server.cpp @@ -212,7 +212,6 @@ DhtProxyServer::DhtProxyServer(const std::shared_ptr<DhtRunner>& dht, printStatsTimer_(std::make_unique<asio::steady_timer>(*ioContext_, 3s)), connListener_(std::make_shared<ConnectionListener>(std::bind(&DhtProxyServer::onConnectionClosed, this, std::placeholders::_1))), pushServer_(config.pushServer), - unifiedPushEndpoint_(config.unifiedPushEndpoint), bundleId_(config.bundleId) { if (not dht_) @@ -1015,18 +1014,21 @@ DhtProxyServer::handleCancelPushListen(const asio::error_code &ec, const std::st void DhtProxyServer::sendPushNotification(const std::string& token, Json::Value&& json, PushType type, bool highPriority, const std::string& topic) { - if (pushServer_.empty() and unifiedPushEndpoint_.empty()) + if (pushServer_.empty()) return; unsigned reqid = 0; try { - auto request = type == PushType::UnifiedPush - ? std::make_shared<http::Request>(io_context(), unifiedPushEndpoint_, logger_) - : std::make_shared<http::Request>(io_context(), pushHostPort_.first, pushHostPort_.second, pushHostPort_.first.find("https://") == 0, logger_); + std::shared_ptr<http::Request> request; + http::Url tokenUrl(token); + if (type == PushType::UnifiedPush) + request = std::make_shared<http::Request>(io_context(), tokenUrl.protocol + "://" + tokenUrl.host, logger_); + else + request = std::make_shared<http::Request>(io_context(), pushHostPort_.first, pushHostPort_.second, pushHostPort_.first.find("https://") == 0, logger_);; reqid = request->id(); - request->set_target(type == PushType::UnifiedPush ? ("/" + token) : "/api/push"); + request->set_target(type == PushType::UnifiedPush ? (tokenUrl.target) : "/api/push"); request->set_method(restinio::http_method_post()); - request->set_header_field(restinio::http_field_t::host, type == PushType::UnifiedPush ? unifiedPushEndpoint_.c_str() : pushServer_.c_str()); + request->set_header_field(restinio::http_field_t::host, type == PushType::UnifiedPush ? tokenUrl.host.c_str() : pushServer_.c_str()); request->set_header_field(restinio::http_field_t::user_agent, "RESTinio client"); request->set_header_field(restinio::http_field_t::accept, "*/*"); request->set_header_field(restinio::http_field_t::content_type, "application/json"); diff --git a/tools/dhtnode.cpp b/tools/dhtnode.cpp index 1c8d20a4b0d8479393be637574feebc543a5a734..877d0672eed7838cc5c8899770cc9f24e5d49651 100644 --- a/tools/dhtnode.cpp +++ b/tools/dhtnode.cpp @@ -552,7 +552,6 @@ main(int argc, char **argv) serverConfig.pushServer = params.pushserver; serverConfig.bundleId = params.bundle_id; serverConfig.address = params.proxy_address; - serverConfig.unifiedPushEndpoint = params.unifiedPushEndpoint; if (params.proxyserverssl and params.proxy_id.first and params.proxy_id.second){ serverConfig.identity = params.proxy_id; serverConfig.port = params.proxyserverssl; diff --git a/tools/tools_common.h b/tools/tools_common.h index bb783d93946a7c1344f62d07e4beb4e772d16052..cfeade02b8ed698d8be7adb06c1977e43c407905 100644 --- a/tools/tools_common.h +++ b/tools/tools_common.h @@ -130,7 +130,6 @@ struct dht_params { in_port_t port {0}; in_port_t proxyserver {0}; in_port_t proxyserverssl {0}; - std::string unifiedPushEndpoint {}; std::string proxyclient {}; std::string proxy_address {}; std::string pushserver {}; @@ -226,7 +225,6 @@ static const constexpr struct option long_options[] = { {"syslog", no_argument , nullptr, 'L'}, {"proxyserver", required_argument, nullptr, 'S'}, {"proxyserverssl", required_argument, nullptr, 'e'}, - {"unifiedpush", required_argument, nullptr, 'O'}, {"proxy-addr", required_argument, nullptr, 'a'}, {"proxy-certificate", required_argument, nullptr, 'w'}, {"proxy-privkey", required_argument, nullptr, 'K'}, @@ -263,9 +261,6 @@ parseArgs(int argc, char **argv) { std::cout << "Invalid port: " << port_arg << std::endl; } break; - case 'O': - params.unifiedPushEndpoint = optarg; - break; case 'e': { int port_arg = atoi(optarg); if (port_arg >= 0 && port_arg < 0x10000)