diff --git a/daemon/Daemon.cpp b/daemon/Daemon.cpp index ee56a1c7..5efdc693 100644 --- a/daemon/Daemon.cpp +++ b/daemon/Daemon.cpp @@ -152,6 +152,17 @@ namespace i2p i2p::context.SetSupportsV6 (ipv6); i2p::context.SetSupportsV4 (ipv4); + bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2); + if (ntcp2) + { + bool published; i2p::config::GetOption("ntcp2.published", published); + if (published) + { + uint16_t port; i2p::config::GetOption("ntcp2.port", port); + i2p::context.PublishNTCP2Address (port); + } + } + bool transit; i2p::config::GetOption("notransit", transit); i2p::context.SetAcceptsTunnels (!transit); uint16_t transitTunnels; i2p::config::GetOption("limits.transittunnels", transitTunnels); diff --git a/libi2pd/Config.cpp b/libi2pd/Config.cpp index 3233c875..098a7baa 100644 --- a/libi2pd/Config.cpp +++ b/libi2pd/Config.cpp @@ -233,7 +233,9 @@ namespace config { options_description ntcp2("NTCP2 Options"); ntcp2.add_options() - ("ntcp2.enabled", value()->default_value(false), "Enable NTCP2 (experimental, default: disabled)") + ("ntcp2.enabled", value()->default_value(false), "Enable NTCP2 (default: disabled)") + ("ntcp2.published", value()->default_value(false), "Publish NTCP2 (default: disabled)") + ("ntcp2.port", value()->default_value(0), "Port to listen for incoming NTCP2 connections (default: auto)") ; m_OptionsDesc diff --git a/libi2pd/RouterContext.cpp b/libi2pd/RouterContext.cpp index 9529a757..e8629ad5 100644 --- a/libi2pd/RouterContext.cpp +++ b/libi2pd/RouterContext.cpp @@ -158,6 +158,8 @@ namespace i2p void RouterContext::PublishNTCP2Address (int port) { + if (!port) + port = rand () % (30777 - 9111) + 9111; // I2P network ports range bool updated = false; for (auto& address : m_RouterInfo.GetAddresses ()) {