Skip to content
Snippets Groups Projects
Commit b31a29ea authored by Seva's avatar Seva Committed by Adrien Béraud
Browse files

dhtproxy: run in both http & https

parent 833bd069
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment