Browse Source

incoming ipv6 SSU sessions

pull/106/head
orignal 10 years ago
parent
commit
67001e1696
  1. 3
      HTTPServer.cpp
  2. 4
      RouterContext.cpp
  3. 2
      RouterInfo.cpp
  4. 7
      SSU.cpp

3
HTTPServer.cpp

@ -650,6 +650,9 @@ namespace util
s << "NTCP&nbsp;&nbsp;"; s << "NTCP&nbsp;&nbsp;";
break; break;
case i2p::data::RouterInfo::eTransportSSU: case i2p::data::RouterInfo::eTransportSSU:
if (address.host.is_v6 ())
s << "SSU6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
else
s << "SSU&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; s << "SSU&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
break; break;
default: default:

4
RouterContext.cpp

@ -136,6 +136,7 @@ namespace i2p
m_RouterInfo.EnableV6 (); m_RouterInfo.EnableV6 ();
else else
m_RouterInfo.DisableV6 (); m_RouterInfo.DisableV6 ();
UpdateRouterInfo ();
} }
void RouterContext::UpdateNTCPV6Address (const boost::asio::ip::address& host) void RouterContext::UpdateNTCPV6Address (const boost::asio::ip::address& host)
@ -145,7 +146,7 @@ namespace i2p
auto& addresses = m_RouterInfo.GetAddresses (); auto& addresses = m_RouterInfo.GetAddresses ();
for (auto& addr : addresses) for (auto& addr : addresses)
{ {
if (addr.host.is_v6 ()) if (addr.host.is_v6 () && addr.transportStyle == i2p::data::RouterInfo::eTransportNTCP)
{ {
if (addr.host != host) if (addr.host != host)
{ {
@ -161,6 +162,7 @@ namespace i2p
{ {
// create new address // create new address
m_RouterInfo.AddNTCPAddress (host.to_string ().c_str (), port); m_RouterInfo.AddNTCPAddress (host.to_string ().c_str (), port);
m_RouterInfo.AddSSUAddress (host.to_string ().c_str (), port, GetIdentHash ()); // TODO
updated = true; updated = true;
} }
if (updated) if (updated)

2
RouterInfo.cpp

@ -577,7 +577,7 @@ namespace data
void RouterInfo::EnableV6 () void RouterInfo::EnableV6 ()
{ {
if (!IsV6 ()) if (!IsV6 ())
m_SupportedTransports |= eNTCPV6; m_SupportedTransports |= eNTCPV6 | eSSUV6;
} }
void RouterInfo::DisableV6 () void RouterInfo::DisableV6 ()

7
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) void SSUServer::Send (const uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& to)
{ {
if (to.protocol () == boost::asio::ip::udp::v4())
m_Socket.send_to (boost::asio::buffer (buf, len), to); m_Socket.send_to (boost::asio::buffer (buf, len), to);
else
m_SocketV6.send_to (boost::asio::buffer (buf, len), to);
} }
void SSUServer::Receive () void SSUServer::Receive ()
@ -1132,7 +1135,7 @@ namespace transport
if (!session) if (!session)
{ {
session = new SSUSession (*this, from); 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"); LogPrint ("New SSU session from ", from.address ().to_string (), ":", from.port (), " created");
} }
session->ProcessNextMessage (buf, bytes_transferred, from); session->ProcessNextMessage (buf, bytes_transferred, from);
@ -1160,7 +1163,7 @@ namespace transport
SSUSession * session = nullptr; SSUSession * session = nullptr;
if (router) if (router)
{ {
auto address = router->GetSSUAddress (); auto address = router->GetSSUAddress (!context.SupportsV6 ());
if (address) if (address)
{ {
boost::asio::ip::udp::endpoint remoteEndpoint (address->host, address->port); boost::asio::ip::udp::endpoint remoteEndpoint (address->host, address->port);

Loading…
Cancel
Save