From c1f805e6e2bb2809fac8b6e3b9e53261a2018dab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Fri, 2 Aug 2019 19:53:39 -0400
Subject: [PATCH] tools: use default port from network utils

---
 tools/dhtnode.cpp    | 2 +-
 tools/tools_common.h | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/tools/dhtnode.cpp b/tools/dhtnode.cpp
index fc9e220d..84ce1d02 100644
--- a/tools/dhtnode.cpp
+++ b/tools/dhtnode.cpp
@@ -196,7 +196,7 @@ void cmd_loop(std::shared_ptr<DhtRunner>& node, dht_params& params
             try {
                 auto addr = splitPort(idstr);
                 if (not addr.first.empty() and addr.second.empty())
-                    addr.second = std::to_string(DHT_DEFAULT_PORT);
+                    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;
diff --git a/tools/tools_common.h b/tools/tools_common.h
index 66cc5792..f9726859 100644
--- a/tools/tools_common.h
+++ b/tools/tools_common.h
@@ -24,6 +24,7 @@
 #include <opendht.h>
 #include <opendht/log.h>
 #include <opendht/crypto.h>
+#include <opendht/network_utils.h>
 #ifndef WIN32_NATIVE
 #include <getopt.h>
 #include <readline/readline.h>
@@ -106,8 +107,6 @@ loadFile(const std::string& path)
     return buffer;
 }
 
-static const constexpr in_port_t DHT_DEFAULT_PORT = 4222;
-
 struct dht_params {
     bool help {false}; // print help and exit
     bool version {false};
@@ -200,7 +199,7 @@ parseArgs(int argc, char **argv) {
         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_DEFAULT_PORT);
+                params.bootstrap.second = std::to_string(dht::net::DHT_DEFAULT_PORT);
             }
             break;
         case 'V':
-- 
GitLab