From 6eba061c2ad9dc08287be4c5ff895e060d415d92 Mon Sep 17 00:00:00 2001 From: orignal Date: Sun, 13 Mar 2022 11:04:37 -0400 Subject: [PATCH] show local SSU2 address --- daemon/HTTPServer.cpp | 14 ++++++++++---- libi2pd/RouterContext.cpp | 7 ++++++- libi2pd/RouterInfo.cpp | 4 ++-- libi2pd/RouterInfo.h | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/daemon/HTTPServer.cpp b/daemon/HTTPServer.cpp index 419c1588..2a274f5c 100644 --- a/daemon/HTTPServer.cpp +++ b/daemon/HTTPServer.cpp @@ -311,7 +311,7 @@ namespace http { if (address->IsNTCP2 () && !address->IsPublishedNTCP2 ()) { s << "NTCP2"; - if (address->host.is_v6 ()) s << "v6"; + if (address->IsV6 ()) s << "v6"; s << "" << tr("supported") << "\r\n\r\n"; continue; } @@ -321,18 +321,24 @@ namespace http { { s << "NTCP"; if (address->IsPublishedNTCP2 ()) s << "2"; - if (address->host.is_v6 ()) s << "v6"; + if (address->IsV6 ()) s << "v6"; s << "\r\n"; break; } case i2p::data::RouterInfo::eTransportSSU: { s << "SSU"; - if (address->host.is_v6 ()) - s << "v6"; + if (address->IsV6 ()) s << "v6"; s << "\r\n"; break; } + case i2p::data::RouterInfo::eTransportSSU2: + { + s << "SSU2"; + if (address->IsV6 ()) s << "v6"; + s << "" << tr("supported") << "\r\n\r\n"; + break; + } default: s << "" << tr("Unknown") << "\r\n"; } diff --git a/libi2pd/RouterContext.cpp b/libi2pd/RouterContext.cpp index f1bdf27d..4602f5eb 100644 --- a/libi2pd/RouterContext.cpp +++ b/libi2pd/RouterContext.cpp @@ -346,7 +346,12 @@ namespace i2p } if (enable && !found) { - m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey); + uint8_t addressCaps = 0; + bool ipv4; i2p::config::GetOption("ipv4", ipv4); + bool ipv6; i2p::config::GetOption("ipv6", ipv6); + if (ipv4) addressCaps |= i2p::data::RouterInfo::AddressCaps::eV4; + if (ipv6) addressCaps |= i2p::data::RouterInfo::AddressCaps::eV6; + m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, addressCaps); updated = true; } if (updated) diff --git a/libi2pd/RouterInfo.cpp b/libi2pd/RouterInfo.cpp index c3afbf9a..4f1338fa 100644 --- a/libi2pd/RouterInfo.cpp +++ b/libi2pd/RouterInfo.cpp @@ -631,11 +631,11 @@ namespace data m_Addresses->push_back(std::move(addr)); } - void RouterInfo::AddSSU2Address (const uint8_t * staticKey) + void RouterInfo::AddSSU2Address (const uint8_t * staticKey, uint8_t caps) { auto addr = std::make_shared
(); addr->transportStyle = eTransportSSU2; - addr->caps = 0; + addr->caps = caps; addr->date = 0; memcpy (addr->s, staticKey, 32); m_Addresses->push_back(std::move(addr)); diff --git a/libi2pd/RouterInfo.h b/libi2pd/RouterInfo.h index 511098bc..ae846724 100644 --- a/libi2pd/RouterInfo.h +++ b/libi2pd/RouterInfo.h @@ -190,7 +190,7 @@ namespace data void AddSSUAddress (const char * host, int port, const uint8_t * key, int mtu = 0); void AddNTCP2Address (const uint8_t * staticKey, const uint8_t * iv, const boost::asio::ip::address& host = boost::asio::ip::address(), int port = 0, uint8_t caps = 0); - void AddSSU2Address (const uint8_t * staticKey); // non published + void AddSSU2Address (const uint8_t * staticKey, uint8_t caps = 0); // non published bool AddIntroducer (const Introducer& introducer); bool RemoveIntroducer (const boost::asio::ip::udp::endpoint& e); void SetUnreachableAddressesTransportCaps (uint8_t transports); // bitmask of AddressCaps