Skip to content
Permalink
Browse files

dhtchat: respect new arguments

  • Loading branch information...
aberaud committed Oct 7, 2019
1 parent ed1b022 commit 347f404a920b11ce052087cbb7e3ce98cf5406d4
Showing with 27 additions and 9 deletions.
  1. +26 −5 tools/dhtchat.cpp
  2. +1 −4 tools/dhtnode.cpp
@@ -62,16 +62,37 @@ main(int argc, char **argv)

DhtRunner dht;
try {
dht.run(params.port, dht::crypto::generateIdentity("DHT Chat Node"), true, params.network);
if (not params.id.first) {
auto node_ca = std::make_unique<dht::crypto::Identity>(dht::crypto::generateEcIdentity("DHT Node CA"));
params.id = dht::crypto::generateIdentity("DHT Chat Node", *node_ca);
if (not params.save_identity.empty()) {
dht::crypto::saveIdentity(*node_ca, params.save_identity + "_ca", params.privkey_pwd);
dht::crypto::saveIdentity(params.id, params.save_identity, params.privkey_pwd);
}
}

dht::DhtRunner::Config config {};
config.dht_config.node_config.network = params.network;
config.dht_config.node_config.maintain_storage = false;
config.dht_config.node_config.persist_path = params.persist_path;
config.dht_config.id = params.id;
config.threaded = true;
config.proxy_server = params.proxyclient;
config.push_node_id = "dhtnode";
config.push_token = params.devicekey;
config.peer_discovery = params.peer_discovery;
config.peer_publish = params.peer_discovery;

dht::DhtRunner::Context context {};
if (params.log) {
if (params.syslog)
log::enableSyslog(dht, "dhtnode");
if (params.syslog or (params.daemonize and params.logfile.empty()))
context.logger = log::getSyslogLogger("dhtnode");
else if (not params.logfile.empty())
log::enableFileLogging(dht, params.logfile);
context.logger = log::getFileLogger(params.logfile);
else
log::enableLogging(dht);
context.logger = log::getStdLogger();
}
dht.run(params.port, config, std::move(context));

if (not params.bootstrap.first.empty())
dht.bootstrap(params.bootstrap.first.c_str(), params.bootstrap.second.c_str());
@@ -549,10 +549,9 @@ main(int argc, char **argv)
config.threaded = true;
config.proxy_server = params.proxyclient;
config.push_node_id = "dhtnode";
config.push_token = params.devicekey;
config.peer_discovery = params.peer_discovery;
config.peer_publish = params.peer_discovery;
if (not params.proxyclient.empty())
node->setPushNotificationToken(params.devicekey);

dht::DhtRunner::Context context {};
if (params.log) {
@@ -564,8 +563,6 @@ main(int argc, char **argv)
context.logger = log::getStdLogger();
}
node->run(params.port, config, std::move(context));
if (context.logger)
log::enableLogging(*node);

if (not params.bootstrap.first.empty()) {
std::cout << "Bootstrap: " << params.bootstrap.first << ":" << params.bootstrap.second << std::endl;

0 comments on commit 347f404

Please sign in to comment.
You can’t perform that action at this time.