diff --git a/tools/dhtnode.cpp b/tools/dhtnode.cpp index bd99b1a47fa124e0bb013e7ae8332b7d7b8c8763..83c6c494e8548a3c00ce30af9980fea036cc343d 100644 --- a/tools/dhtnode.cpp +++ b/tools/dhtnode.cpp @@ -40,7 +40,7 @@ void print_version() { } void print_usage() { - std::cout << "Usage: dhtnode [-v [-l logfile]] [-i] [-d] [-n network_id] [-p local_port] [-b bootstrap_host[:port]] [--proxyserver local_port]" << std::endl << std::endl; + std::cout << "Usage: dhtnode [-v [-l logfile]] [-i] [-d] [-n network_id] [-p local_port] [-b bootstrap_host[:port]] [--proxyserver local_port] [--proxyserverssl local_port]" << std::endl << std::endl; print_info(); } @@ -79,6 +79,7 @@ void print_help() { << " pst [port] <pushServer> Start the proxy interface on port." << std::endl #else << " pst [port] Start the proxy interface on port." << std::endl + << " psx [port] Start the proxy ssl interface on port." << std::endl #endif // OPENDHT_PUSH_NOTIFICATIONS << " psp [port] Stop the proxy interface on port." << std::endl; #endif //OPENDHT_PROXY_SERVER @@ -222,6 +223,23 @@ void cmd_loop(std::shared_ptr<DhtRunner>& node, dht_params& params iss >> idstr >> pushServer; #else iss >> idstr; +#endif // OPENDHT_PUSH_NOTIFICATIONS + try { + unsigned int port = std::stoi(idstr); + proxies.emplace(port, std::unique_ptr<DhtProxyServer>( + new DhtProxyServer( + dht::crypto::Identity{}, node, port +#ifdef OPENDHT_PUSH_NOTIFICATIONS + ,pushServer +#endif + ))); + } catch (...) { } + continue; + } else if (op == "psx") { +#ifdef OPENDHT_PUSH_NOTIFICATIONS + iss >> idstr >> pushServer; +#else + iss >> idstr; #endif // OPENDHT_PUSH_NOTIFICATIONS try { unsigned int port = std::stoi(idstr); @@ -557,11 +575,17 @@ main(int argc, char **argv) #ifdef OPENDHT_PROXY_SERVER std::map<in_port_t, std::unique_ptr<DhtProxyServer>> proxies; #endif - if (params.proxyserver != 0) { + if (params.proxyserverssl != 0) { #ifdef OPENDHT_PROXY_SERVER - proxies.emplace(params.proxyserver, std::unique_ptr<DhtProxyServer>( + proxies.emplace(params.proxyserverssl, std::unique_ptr<DhtProxyServer>( new DhtProxyServer( params.generate_identity ? params.id : dht::crypto::Identity{}, + node, params.proxyserverssl, params.pushserver, context.logger))); + } + if (params.proxyserver != 0) { + proxies.emplace(params.proxyserver, std::unique_ptr<DhtProxyServer>( + new DhtProxyServer( + dht::crypto::Identity{}, node, params.proxyserver, params.pushserver, context.logger))); #else std::cerr << "DHT proxy server requested but OpenDHT built without proxy server support." << std::endl; diff --git a/tools/tools_common.h b/tools/tools_common.h index f97268593670f636e88b5b6c48368745099b55a4..7a6b2a1a10a2d8ffe67507849a6fcc8048403635 100644 --- a/tools/tools_common.h +++ b/tools/tools_common.h @@ -121,6 +121,7 @@ struct dht_params { dht::NetId network {0}; in_port_t port {0}; in_port_t proxyserver {0}; + in_port_t proxyserverssl {0}; std::string proxyclient {}; std::string pushserver {}; std::string devicekey {}; @@ -148,6 +149,7 @@ static const constexpr struct option long_options[] = { {"logfile", required_argument, nullptr, 'l'}, {"syslog", no_argument , nullptr, 'L'}, {"proxyserver", required_argument, nullptr, 'S'}, + {"proxyserverssl", required_argument, nullptr, 'e'}, {"proxyclient", required_argument, nullptr, 'C'}, {"pushserver", required_argument, nullptr, 'y'}, {"devicekey", required_argument, nullptr, 'z'}, @@ -178,6 +180,14 @@ parseArgs(int argc, char **argv) { std::cout << "Invalid port: " << port_arg << std::endl; } break; + case 'e': { + int port_arg = atoi(optarg); + if (port_arg >= 0 && port_arg < 0x10000) + params.proxyserverssl = port_arg; + else + std::cout << "Invalid port: " << port_arg << std::endl; + } + break; case 'D': params.peer_discovery = true; break;