Skip to content
Snippets Groups Projects
Commit 38ad5b9e authored by Sébastien Blin's avatar Sébastien Blin
Browse files

add --proxyserver option for dhtnode

parent 67ba435b
Branches
Tags
No related merge requests found
...@@ -29,7 +29,7 @@ extern "C" { ...@@ -29,7 +29,7 @@ extern "C" {
using namespace dht; using namespace dht;
void print_usage() { void print_usage() {
std::cout << "Usage: dhtnode [-v [-l logfile]] [-i] [-d] [-n network_id] [-p local_port] [-b bootstrap_host[: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]" << std::endl << std::endl;
std::cout << "dhtnode, a simple OpenDHT command line node runner." << std::endl; std::cout << "dhtnode, a simple OpenDHT command line node runner." << std::endl;
std::cout << "Report bugs to: http://opendht.net" << std::endl; std::cout << "Report bugs to: http://opendht.net" << std::endl;
} }
...@@ -92,6 +92,9 @@ void cmd_loop(std::shared_ptr<DhtRunner>& dht, dht_params& params) ...@@ -92,6 +92,9 @@ void cmd_loop(std::shared_ptr<DhtRunner>& dht, dht_params& params)
std::map<std::string, indexation::Pht> indexes; std::map<std::string, indexation::Pht> indexes;
#if OPENDHT_PROXY_SERVER #if OPENDHT_PROXY_SERVER
std::map<in_port_t, std::unique_ptr<DhtProxyServer>> proxies; std::map<in_port_t, std::unique_ptr<DhtProxyServer>> proxies;
if (params.proxyserver != 0) {
proxies.emplace(params.proxyserver, new DhtProxyServer(dht, params.proxyserver));
}
#endif //OPENDHT_PROXY_SERVER #endif //OPENDHT_PROXY_SERVER
while (true) while (true)
......
...@@ -121,6 +121,7 @@ struct dht_params { ...@@ -121,6 +121,7 @@ struct dht_params {
bool daemonize {false}; bool daemonize {false};
bool service {false}; bool service {false};
std::pair<std::string, std::string> bootstrap {}; std::pair<std::string, std::string> bootstrap {};
in_port_t proxyserver {0};
}; };
static const constexpr struct option long_options[] = { static const constexpr struct option long_options[] = {
...@@ -134,6 +135,7 @@ static const constexpr struct option long_options[] = { ...@@ -134,6 +135,7 @@ static const constexpr struct option long_options[] = {
{"service", no_argument , nullptr, 's'}, {"service", no_argument , nullptr, 's'},
{"logfile", required_argument, nullptr, 'l'}, {"logfile", required_argument, nullptr, 'l'},
{"syslog", no_argument , nullptr, 'L'}, {"syslog", no_argument , nullptr, 'L'},
{"proxyserver",required_argument, nullptr, 'S'},
{nullptr, 0 , nullptr, 0} {nullptr, 0 , nullptr, 0}
}; };
...@@ -151,6 +153,14 @@ parseArgs(int argc, char **argv) { ...@@ -151,6 +153,14 @@ parseArgs(int argc, char **argv) {
std::cout << "Invalid port: " << port_arg << std::endl; std::cout << "Invalid port: " << port_arg << std::endl;
} }
break; break;
case 'S': {
int port_arg = atoi(optarg);
if (port_arg >= 0 && port_arg < 0x10000)
params.proxyserver = port_arg;
else
std::cout << "Invalid port: " << port_arg << std::endl;
}
break;
case 'n': case 'n':
params.network = strtoul(optarg, nullptr, 0); params.network = strtoul(optarg, nullptr, 0);
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment