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

dhtrunner: don't bind port if proxy is used

parent 949cbb9f
No related branches found
No related tags found
No related merge requests found
...@@ -132,22 +132,18 @@ DhtRunner::run(const Config& config, Context&& context) ...@@ -132,22 +132,18 @@ DhtRunner::run(const Config& config, Context&& context)
if (context.logger) { if (context.logger) {
logger_ = context.logger; logger_ = context.logger;
logger_->d("[runner %p] state changed to Running", this);
} }
#ifdef OPENDHT_PROXY_CLIENT
config_ = config;
identityAnnouncedCb_ = context.identityAnnouncedCb;
#endif
if (config.proxy_server.empty()) {
if (not context.sock) { if (not context.sock) {
context.sock.reset(new net::UdpSocket(local4, local6, context.logger)); context.sock.reset(new net::UdpSocket(local4, local6, context.logger));
} }
if (not state_path.empty() and config.proxy_server.empty()) {
std::ofstream outConfig(state_path);
outConfig << context.sock->getBoundRef(AF_INET).getPort() << std::endl;
outConfig << context.sock->getBoundRef(AF_INET6).getPort() << std::endl;
}
if (context.logger) {
logger_->d("[runner %p] state changed to Running", this);
}
context.sock->setOnReceive([&] (net::PacketList&& pkts) { context.sock->setOnReceive([&] (net::PacketList&& pkts) {
net::PacketList ret; net::PacketList ret;
{ {
...@@ -166,12 +162,11 @@ DhtRunner::run(const Config& config, Context&& context) ...@@ -166,12 +162,11 @@ DhtRunner::run(const Config& config, Context&& context)
cv.notify_all(); cv.notify_all();
return ret; return ret;
}); });
if (not state_path.empty()) {
#ifdef OPENDHT_PROXY_CLIENT std::ofstream outConfig(state_path);
config_ = config; outConfig << context.sock->getBoundRef(AF_INET).getPort() << std::endl;
identityAnnouncedCb_ = context.identityAnnouncedCb; outConfig << context.sock->getBoundRef(AF_INET6).getPort() << std::endl;
#endif }
if (config.proxy_server.empty()) {
auto dht = std::make_unique<Dht>(std::move(context.sock), SecureDht::getConfig(config.dht_config), context.logger); auto dht = std::make_unique<Dht>(std::move(context.sock), SecureDht::getConfig(config.dht_config), context.logger);
dht_ = std::make_unique<SecureDht>(std::move(dht), config.dht_config, std::move(context.identityAnnouncedCb), context.logger); dht_ = std::make_unique<SecureDht>(std::move(dht), config.dht_config, std::move(context.identityAnnouncedCb), context.logger);
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment