diff --git a/daemon/Daemon.cpp b/daemon/Daemon.cpp index ba11e500..c53a5d47 100644 --- a/daemon/Daemon.cpp +++ b/daemon/Daemon.cpp @@ -164,7 +164,7 @@ namespace i2p } i2p::context.SetSupportsV6 (ipv6); i2p::context.SetSupportsV4 (ipv4); - i2p::context.SetSupportsMesh (ygg); + i2p::context.SetSupportsMesh (ygg, yggaddr); i2p::context.RemoveNTCPAddress (!ipv6); // TODO: remove later bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2); diff --git a/libi2pd/RouterContext.cpp b/libi2pd/RouterContext.cpp index 33cfb943..9faa75aa 100644 --- a/libi2pd/RouterContext.cpp +++ b/libi2pd/RouterContext.cpp @@ -521,10 +521,25 @@ namespace i2p UpdateRouterInfo (); } - void RouterContext::SetSupportsMesh (bool supportsmesh) + void RouterContext::SetSupportsMesh (bool supportsmesh, const boost::asio::ip::address_v6& host) { if (supportsmesh) + { m_RouterInfo.EnableMesh (); + uint16_t port = 0; + i2p::config::GetOption ("ntcp2.port", port); + if (!port) i2p::config::GetOption("port", port); + if (!port) + { + auto& addresses = m_RouterInfo.GetAddresses (); + for (auto& addr: addresses) + { + port = addr->port; + if (port) break; + } + } + m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, host, port); + } else m_RouterInfo.DisableMesh (); UpdateRouterInfo (); diff --git a/libi2pd/RouterContext.h b/libi2pd/RouterContext.h index 81921d1c..1def089a 100644 --- a/libi2pd/RouterContext.h +++ b/libi2pd/RouterContext.h @@ -110,7 +110,7 @@ namespace i2p bool SupportsMesh () const { return m_RouterInfo.IsMesh (); }; void SetSupportsV6 (bool supportsV6); void SetSupportsV4 (bool supportsV4); - void SetSupportsMesh (bool supportsmesh); + void SetSupportsMesh (bool supportsmesh, const boost::asio::ip::address_v6& host); bool IsECIES () const { return GetIdentity ()->GetCryptoKeyType () == i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD; }; std::unique_ptr& GetCurrentNoiseState () { return m_CurrentNoiseState; };