diff --git a/tools/dhtchat.cpp b/tools/dhtchat.cpp index 78e5569df52be8990df9705c2faffe8a8f9686e9..07dfd7c2311306a15bdf65d2c06b43605d87d63d 100644 --- a/tools/dhtchat.cpp +++ b/tools/dhtchat.cpp @@ -64,8 +64,8 @@ main(int argc, char **argv) auto dhtConf = getDhtConfig(params); dht.run(params.port, dhtConf.first, std::move(dhtConf.second)); - if (not params.bootstrap.first.empty()) - dht.bootstrap(params.bootstrap.first.c_str(), params.bootstrap.second.c_str()); + if (not params.bootstrap.empty()) + dht.bootstrap(params.bootstrap); print_node_info(dht.getNodeInfo(), params); std::cout << " type 'c {hash}' to join a channel" << std::endl << std::endl; diff --git a/tools/dhtnode.cpp b/tools/dhtnode.cpp index 923a77d18ce168a7da274549106a9add7f1ea0e1..0318b1510e8b909da5de0798e17e7e14b18be437 100644 --- a/tools/dhtnode.cpp +++ b/tools/dhtnode.cpp @@ -191,14 +191,10 @@ void cmd_loop(std::shared_ptr<DhtRunner>& node, dht_params& params continue; } else if (op == "b") { iss >> idstr; - try { - auto addr = splitPort(idstr); - if (not addr.first.empty() and addr.second.empty()) - addr.second = std::to_string(dht::net::DHT_DEFAULT_PORT); - node->bootstrap(addr.first.c_str(), addr.second.c_str()); - } catch (const std::exception& e) { - std::cerr << e.what() << std::endl; - } + if (not idstr.empty()) + node->bootstrap(idstr); + else + std::cerr << "No service provided. Syntax: b hostname:port" << std::endl; continue; } else if (op == "log") { iss >> idstr; @@ -538,9 +534,9 @@ main(int argc, char **argv) auto dhtConf = getDhtConfig(params); node->run(params.port, dhtConf.first, std::move(dhtConf.second)); - if (not params.bootstrap.first.empty()) { - std::cout << "Bootstrap: " << params.bootstrap.first << ":" << params.bootstrap.second << std::endl; - node->bootstrap(params.bootstrap.first.c_str(), params.bootstrap.second.c_str()); + if (not params.bootstrap.empty()) { + std::cout << "Bootstrap: " << params.bootstrap << std::endl; + node->bootstrap(params.bootstrap); } #ifdef OPENDHT_PROXY_SERVER diff --git a/tools/dhtscanner.cpp b/tools/dhtscanner.cpp index 5f8cedbc04b9c5df6961be433024c0e2c7d0be93..e94f6dbe8bcbfc0340a9c786281e04b09cfebcad 100644 --- a/tools/dhtscanner.cpp +++ b/tools/dhtscanner.cpp @@ -91,8 +91,8 @@ main(int argc, char **argv) auto dhtConf = getDhtConfig(params); dht.run(params.port, dhtConf.first, std::move(dhtConf.second)); - if (not params.bootstrap.first.empty()) - dht.bootstrap(params.bootstrap.first.c_str(), params.bootstrap.second.c_str()); + if (not params.bootstrap.empty()) + dht.bootstrap(params.bootstrap); print_node_info(dht.getNodeInfo(), params); std::cout << "Scanning network..." << std::endl; diff --git a/tools/tools_common.h b/tools/tools_common.h index e28443fc4e2f0e778d0524f6d45850f3f186a6fd..a48d67408a30f2d7287d156689951b1fe5779641 100644 --- a/tools/tools_common.h +++ b/tools/tools_common.h @@ -124,7 +124,7 @@ struct dht_params { bool log {false}; bool syslog {false}; std::string logfile {}; - std::pair<std::string, std::string> bootstrap {}; + std::string bootstrap {}; dht::NetId network {0}; in_port_t port {0}; in_port_t proxyserver {0}; @@ -289,10 +289,7 @@ parseArgs(int argc, char **argv) { params.public_stable = true; break; case 'b': - params.bootstrap = dht::splitPort((optarg[0] == '=') ? optarg+1 : optarg); - if (not params.bootstrap.first.empty() and params.bootstrap.second.empty()) { - params.bootstrap.second = std::to_string(dht::net::DHT_DEFAULT_PORT); - } + params.bootstrap = (optarg[0] == '=') ? optarg+1 : optarg; break; case 'V': params.version = true;