diff --git a/libi2pd/RouterContext.cpp b/libi2pd/RouterContext.cpp index 75235ec6..fd59bd83 100644 --- a/libi2pd/RouterContext.cpp +++ b/libi2pd/RouterContext.cpp @@ -476,15 +476,12 @@ namespace i2p } } - if (!updated) + if (!updated && port) // we have found NTCP2 v4 but not v6 { - if (port) // we have found NTCP2 v4 but not v6 - { - m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv); - PublishNTCP2Address (port, true); - } + m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, host, port); + updated = true; } - else + if (updated) UpdateRouterInfo (); } diff --git a/libi2pd/RouterInfo.cpp b/libi2pd/RouterInfo.cpp index 79a70462..d52e91f3 100644 --- a/libi2pd/RouterInfo.cpp +++ b/libi2pd/RouterInfo.cpp @@ -696,12 +696,11 @@ namespace data m_Caps |= eSSUIntroducer; } - void RouterInfo::AddNTCP2Address (const uint8_t * staticKey, const uint8_t * iv) + void RouterInfo::AddNTCP2Address (const uint8_t * staticKey, const uint8_t * iv, const boost::asio::ip::address& host, int port) { - for (const auto& it: *m_Addresses) // don't insert one more NTCP2 - if (it->ntcp2) return; auto addr = std::make_shared
(); - addr->port = 0; + addr->host = host; + addr->port = port; addr->transportStyle = eTransportNTCP; addr->cost = 3; addr->date = 0; diff --git a/libi2pd/RouterInfo.h b/libi2pd/RouterInfo.h index bc0ed71c..f66a73fa 100644 --- a/libi2pd/RouterInfo.h +++ b/libi2pd/RouterInfo.h @@ -151,7 +151,7 @@ namespace data void AddNTCPAddress (const char * host, int port); void AddSSUAddress (const char * host, int port, const uint8_t * key, int mtu = 0); - void AddNTCP2Address (const uint8_t * staticKey, const uint8_t * iv); + void AddNTCP2Address (const uint8_t * staticKey, const uint8_t * iv, const boost::asio::ip::address& host = boost::asio::ip::address(), int port = 0); bool AddIntroducer (const Introducer& introducer); bool RemoveIntroducer (const boost::asio::ip::udp::endpoint& e); void SetProperty (const std::string& key, const std::string& value); // called from RouterContext only