diff --git a/HTTPServer.cpp b/HTTPServer.cpp index 10fcaa3c..ca341179 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -650,7 +650,10 @@ namespace util s << "NTCP  "; break; case i2p::data::RouterInfo::eTransportSSU: - s << "SSU     "; + if (address.host.is_v6 ()) + s << "SSU6     "; + else + s << "SSU     "; break; default: s << "Unknown  "; diff --git a/RouterContext.cpp b/RouterContext.cpp index 8701d46c..94d73081 100644 --- a/RouterContext.cpp +++ b/RouterContext.cpp @@ -136,6 +136,7 @@ namespace i2p m_RouterInfo.EnableV6 (); else m_RouterInfo.DisableV6 (); + UpdateRouterInfo (); } void RouterContext::UpdateNTCPV6Address (const boost::asio::ip::address& host) @@ -145,7 +146,7 @@ namespace i2p auto& addresses = m_RouterInfo.GetAddresses (); for (auto& addr : addresses) { - if (addr.host.is_v6 ()) + if (addr.host.is_v6 () && addr.transportStyle == i2p::data::RouterInfo::eTransportNTCP) { if (addr.host != host) { @@ -161,6 +162,7 @@ namespace i2p { // create new address m_RouterInfo.AddNTCPAddress (host.to_string ().c_str (), port); + m_RouterInfo.AddSSUAddress (host.to_string ().c_str (), port, GetIdentHash ()); // TODO updated = true; } if (updated) diff --git a/RouterInfo.cpp b/RouterInfo.cpp index 893219e1..684e3cb8 100644 --- a/RouterInfo.cpp +++ b/RouterInfo.cpp @@ -577,7 +577,7 @@ namespace data void RouterInfo::EnableV6 () { if (!IsV6 ()) - m_SupportedTransports |= eNTCPV6; + m_SupportedTransports |= eNTCPV6 | eSSUV6; } void RouterInfo::DisableV6 () diff --git a/SSU.cpp b/SSU.cpp index 404021e2..fef956d9 100644 --- a/SSU.cpp +++ b/SSU.cpp @@ -1086,7 +1086,10 @@ namespace transport void SSUServer::Send (const uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& to) { - m_Socket.send_to (boost::asio::buffer (buf, len), to); + if (to.protocol () == boost::asio::ip::udp::v4()) + m_Socket.send_to (boost::asio::buffer (buf, len), to); + else + m_SocketV6.send_to (boost::asio::buffer (buf, len), to); } void SSUServer::Receive () @@ -1132,7 +1135,7 @@ namespace transport if (!session) { session = new SSUSession (*this, from); - m_Sessions[m_SenderEndpoint] = session; + m_Sessions[from] = session; LogPrint ("New SSU session from ", from.address ().to_string (), ":", from.port (), " created"); } session->ProcessNextMessage (buf, bytes_transferred, from); @@ -1160,7 +1163,7 @@ namespace transport SSUSession * session = nullptr; if (router) { - auto address = router->GetSSUAddress (); + auto address = router->GetSSUAddress (!context.SupportsV6 ()); if (address) { boost::asio::ip::udp::endpoint remoteEndpoint (address->host, address->port);