From 4ff83fe0bf4bf76d09bc0f1f52ea5d497c700cf5 Mon Sep 17 00:00:00 2001 From: twisterarmy Date: Wed, 30 Apr 2025 09:12:38 +0300 Subject: [PATCH] respect bind address and family for DHT services #254 --- src/twister.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/twister.cpp b/src/twister.cpp index 49c21e34..e000490d 100644 --- a/src/twister.cpp +++ b/src/twister.cpp @@ -328,6 +328,17 @@ void ThreadWaitExtIP() int listen_port = GetListenPort() + LIBTORRENT_PORT_OFFSET; std::string bind_to_interface = ""; + if (mapArgs.count("-bind")) { // respect bind address and family for DHT services (#254) + BOOST_FOREACH(std::string strBind, mapMultiArgs["-bind"]) { + CService addrBind; + if (Lookup(strBind.c_str(), addrBind, GetListenPort(), false)) + bind_to_interface = strBind.c_str(); + else + printf("Cannot resolve -bind address: '%s'", strBind.c_str()); + break; // we are using only the first value (if there are multiple `-bind` options), + // the application behavior may require a separate option for these needs @TODO + } + } proxyType proxyInfoOut; m_usingProxy = GetProxy(NET_IPV4, proxyInfoOut);