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

dhtrunner: don't read port config if already configured

parent f99fe16a
No related branches found
No related tags found
No related merge requests found
......@@ -119,25 +119,27 @@ DhtRunner::run(const Config& config, Context&& context)
local6.setFamily(AF_INET6);
}
auto state_path = config.dht_config.node_config.persist_path;
if (not state_path.empty()) {
if (not state_path.empty() && (local4.getPort() == 0 || local6.getPort() == 0)) {
state_path += "_port.txt";
std::ifstream inConfig(state_path);
if (inConfig.is_open()) {
in_port_t port;
if (inConfig >> port) {
if (local4.getPort() == 0) {
if (context.logger)
context.logger->d("[runner %p] Using IPv4 port %hu from saved configuration", this, port);
if (local4.getPort() == 0)
local4.setPort(port);
}
}
if (inConfig >> port) {
if (local6.getPort() == 0) {
if (context.logger)
context.logger->d("[runner %p] Using IPv6 port %hu from saved configuration", this, port);
if (local6.getPort() == 0)
local6.setPort(port);
}
}
}
}
if (not context.sock)
context.sock.reset(new net::UdpSocket(local4, local6, context.logger));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment