diff --git a/libi2pd/Config.cpp b/libi2pd/Config.cpp index 5e4eb4a4..fb4ee08b 100644 --- a/libi2pd/Config.cpp +++ b/libi2pd/Config.cpp @@ -273,6 +273,7 @@ namespace config { options_description ssu2("SSU2 Options"); ntcp2.add_options() ("ssu2.enabled", value()->default_value(false), "Enable SSU2 (default: disabled)") + ("ssu2.published", value()->default_value(false), "Publish SSU2 (default: disabled)") ("ssu2.port", value()->default_value(0), "Port to listen for incoming SSU2 packets (default: auto)") ; diff --git a/libi2pd/RouterContext.cpp b/libi2pd/RouterContext.cpp index 853a3fd2..af92e86c 100644 --- a/libi2pd/RouterContext.cpp +++ b/libi2pd/RouterContext.cpp @@ -696,7 +696,7 @@ namespace i2p // update if (supportsV4) { - bool foundSSU = false, foundNTCP2 = false; + bool foundSSU = false, foundNTCP2 = false, foundSSU2 = false; std::string host = "127.0.0.1"; uint16_t port = 0; auto& addresses = m_RouterInfo.GetAddresses (); @@ -704,10 +704,19 @@ namespace i2p { if (addr->IsV4 ()) { - if (addr->transportStyle == i2p::data::RouterInfo::eTransportSSU) - foundSSU = true; - else if (addr->transportStyle == i2p::data::RouterInfo::eTransportNTCP) - foundNTCP2 = true; + switch (addr->transportStyle) + { + case i2p::data::RouterInfo::eTransportSSU: + foundSSU = true; + break; + case i2p::data::RouterInfo::eTransportNTCP: + foundNTCP2 = true; + break; + case i2p::data::RouterInfo::eTransportSSU2: + foundSSU2 = true; + break; + default: ; + } } if (addr->port) port = addr->port; } @@ -736,6 +745,19 @@ namespace i2p m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, boost::asio::ip::address(), 0, i2p::data::RouterInfo::eV4); } } + // SSU2 + if (!foundSSU2) + { + bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2); + bool ssu2Published; i2p::config::GetOption("ssu2.published", ssu2Published); + if (ssu2Published) + { + uint16_t ssu2Port; i2p::config::GetOption ("ssu2.port", ssu2Port); + m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, boost::asio::ip::address::from_string ("127.0.0.1"), ssu2Port); + } + else + m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, i2p::data::RouterInfo::eV6); + } m_RouterInfo.EnableV4 (); } else