Skip to content
Snippets Groups Projects
Commit 80b944d9 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

dhtnode: prevent crash in cancelListen

parent 74bfced9
Branches
Tags
No related merge requests found
...@@ -254,11 +254,7 @@ void cmd_loop(std::shared_ptr<DhtRunner>& dht, dht_params& params ...@@ -254,11 +254,7 @@ void cmd_loop(std::shared_ptr<DhtRunner>& dht, dht_params& params
} }
dht::InfoHash id; dht::InfoHash id;
if (op == "cl") { if (false) {}
std::string hash, rem;
iss >> hash >> rem;
dht->cancelListen(dht::InfoHash(hash), std::stoul(rem));
}
#ifdef OPENDHT_INDEXATION #ifdef OPENDHT_INDEXATION
else if (op == "il" or op == "ii") { else if (op == "il" or op == "ii") {
// Pht syntax // Pht syntax
...@@ -268,7 +264,7 @@ void cmd_loop(std::shared_ptr<DhtRunner>& dht, dht_params& params ...@@ -268,7 +264,7 @@ void cmd_loop(std::shared_ptr<DhtRunner>& dht, dht_params& params
return i.first == index; return i.first == index;
}) == indexes.end(); }) == indexes.end();
if (not index.size()) { if (not index.size()) {
std::cout << "You must enter the index name." << std::endl; std::cerr << "You must enter the index name." << std::endl;
continue; continue;
} else if (new_index) { } else if (new_index) {
using namespace dht::indexation; using namespace dht::indexation;
...@@ -338,6 +334,18 @@ void cmd_loop(std::shared_ptr<DhtRunner>& dht, dht_params& params ...@@ -338,6 +334,18 @@ void cmd_loop(std::shared_ptr<DhtRunner>& dht, dht_params& params
auto t = token.get(); auto t = token.get();
std::cout << "Listening, token: " << t << std::endl; std::cout << "Listening, token: " << t << std::endl;
} }
if (op == "cl") {
std::string rem;
iss >> rem;
size_t token;
try {
token = std::stoul(rem);
} catch(...) {
std::cerr << "Syntax: cl [key] [token]" << std::endl;
continue;
}
dht->cancelListen(id, token);
}
else if (op == "p") { else if (op == "p") {
std::string v; std::string v;
iss >> v; iss >> v;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment