Skip to content
Snippets Groups Projects
Commit b01d3cfc authored by Seva's avatar Seva
Browse files

dhtproxy: add identity to constructor if openssl

parent 49f6dd3c
No related branches found
No related tags found
No related merge requests found
...@@ -86,9 +86,13 @@ public: ...@@ -86,9 +86,13 @@ public:
* @note if the server fails to start (if port is already used or reserved), * @note if the server fails to start (if port is already used or reserved),
* it will fails silently * it will fails silently
*/ */
DhtProxyServer(std::shared_ptr<DhtRunner> dht, in_port_t port = 8000, DhtProxyServer(
const std::string& pushServer = "", #ifdef OPENDHT_PROXY_OPENSSL
std::shared_ptr<dht::Logger> logger = {}); dht::crypto::Identity& identity,
#endif
std::shared_ptr<DhtRunner> dht, in_port_t port = 8000,
const std::string& pushServer = "", std::shared_ptr<dht::Logger> logger = {});
virtual ~DhtProxyServer(); virtual ~DhtProxyServer();
DhtProxyServer(const DhtProxyServer& other) = delete; DhtProxyServer(const DhtProxyServer& other) = delete;
......
...@@ -46,9 +46,12 @@ constexpr char RESP_MSG_PUT_FAILED[] = "{\"err\":\"Put failed\"}"; ...@@ -46,9 +46,12 @@ constexpr char RESP_MSG_PUT_FAILED[] = "{\"err\":\"Put failed\"}";
constexpr const std::chrono::minutes PRINT_STATS_PERIOD {2}; constexpr const std::chrono::minutes PRINT_STATS_PERIOD {2};
DhtProxyServer::DhtProxyServer(std::shared_ptr<DhtRunner> dht, in_port_t port, DhtProxyServer::DhtProxyServer(
const std::string& pushServer, #ifdef OPENDHT_PROXY_OPENSSL
std::shared_ptr<dht::Logger> logger dht::crypto::Identity& identity,
#endif
std::shared_ptr<DhtRunner> dht, in_port_t port,
const std::string& pushServer, std::shared_ptr<dht::Logger> logger
): ):
dht_(dht), logger_(logger), lockListener_(std::make_shared<std::mutex>()), dht_(dht), logger_(logger), lockListener_(std::make_shared<std::mutex>()),
listeners_(std::make_shared<std::map<restinio::connection_id_t, http::ListenerSession>>()), listeners_(std::make_shared<std::map<restinio::connection_id_t, http::ListenerSession>>()),
......
...@@ -40,7 +40,17 @@ DhtProxyTester::setUp() { ...@@ -40,7 +40,17 @@ DhtProxyTester::setUp() {
nodeProxy = std::make_shared<dht::DhtRunner>(); nodeProxy = std::make_shared<dht::DhtRunner>();
nodeProxy->run(0, /*identity*/{}, /*threaded*/true); nodeProxy->run(0, /*identity*/{}, /*threaded*/true);
nodeProxy->bootstrap(nodePeer.getBound()); nodeProxy->bootstrap(nodePeer.getBound());
serverProxy = std::unique_ptr<dht::DhtProxyServer>(new dht::DhtProxyServer(
#ifdef OPENDHT_PUSH_NOTIFICATIONS
auto ca_tmp = dht::crypto::generateEcIdentity("DHT Node CA");
serverIdentity = dht::crypto::generateIdentity("DHT Node", ca_tmp);
#endif
serverProxy = std::unique_ptr<dht::DhtProxyServer>(
new dht::DhtProxyServer(
#ifdef OPENDHT_PUSH_NOTIFICATIONS
serverIdentity,
#endif
nodeProxy, 8080, /*pushServer*/"127.0.0.1:8090", logger)); nodeProxy, 8080, /*pushServer*/"127.0.0.1:8090", logger));
clientConfig.dht_config.node_config.maintain_storage = false; clientConfig.dht_config.node_config.maintain_storage = false;
......
...@@ -66,6 +66,10 @@ class DhtProxyTester : public CppUnit::TestFixture { ...@@ -66,6 +66,10 @@ class DhtProxyTester : public CppUnit::TestFixture {
std::shared_ptr<dht::DhtRunner> nodeClient; std::shared_ptr<dht::DhtRunner> nodeClient;
std::shared_ptr<dht::DhtRunner> nodeProxy; std::shared_ptr<dht::DhtRunner> nodeProxy;
#ifdef OPENDHT_PUSH_NOTIFICATIONS
dht::crypto::Identity serverIdentity;
#endif
std::unique_ptr<dht::DhtProxyServer> serverProxy; std::unique_ptr<dht::DhtProxyServer> serverProxy;
dht::DhtRunner::Context clientContext {}; dht::DhtRunner::Context clientContext {};
......
...@@ -225,11 +225,16 @@ void cmd_loop(std::shared_ptr<DhtRunner>& node, dht_params& params ...@@ -225,11 +225,16 @@ void cmd_loop(std::shared_ptr<DhtRunner>& node, dht_params& params
#endif // OPENDHT_PUSH_NOTIFICATIONS #endif // OPENDHT_PUSH_NOTIFICATIONS
try { try {
unsigned int port = std::stoi(idstr); unsigned int port = std::stoi(idstr);
proxies.emplace(port, std::unique_ptr<DhtProxyServer>(
new DhtProxyServer(
#ifdef OPENDHT_PROXY_OPENSSL
params.id, /* dht::crypto::Identity */
#endif
node, port
#ifdef OPENDHT_PUSH_NOTIFICATIONS #ifdef OPENDHT_PUSH_NOTIFICATIONS
proxies.emplace(port, std::unique_ptr<DhtProxyServer>(new DhtProxyServer(node, port, pushServer))); ,pushServer
#else #endif
proxies.emplace(port, std::unique_ptr<DhtProxyServer>(new DhtProxyServer(node, port))); )));
#endif // OPENDHT_PUSH_NOTIFICATIONS
} catch (...) { } } catch (...) { }
continue; continue;
} else if (op == "psp") { } else if (op == "psp") {
...@@ -554,7 +559,12 @@ main(int argc, char **argv) ...@@ -554,7 +559,12 @@ main(int argc, char **argv)
#endif #endif
if (params.proxyserver != 0) { if (params.proxyserver != 0) {
#ifdef OPENDHT_PROXY_SERVER #ifdef OPENDHT_PROXY_SERVER
proxies.emplace(params.proxyserver, std::unique_ptr<DhtProxyServer>(new DhtProxyServer(node, params.proxyserver, params.pushserver, context.logger))); proxies.emplace(params.proxyserver, std::unique_ptr<DhtProxyServer>(
new DhtProxyServer(
#ifdef OPENDHT_PROXY_OPENSSL
params.id, /* dht::crypto::Identity */
#endif
node, params.proxyserver, params.pushserver, context.logger)));
#else #else
std::cerr << "DHT proxy server requested but OpenDHT built without proxy server support." << std::endl; std::cerr << "DHT proxy server requested but OpenDHT built without proxy server support." << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment