Browse Source

check presense of introducers in SSU2 address

pull/1752/head
orignal 2 years ago
parent
commit
e970deb92b
  1. 4
      libi2pd/RouterInfo.h
  2. 16
      libi2pd/SSU2.cpp
  3. 2
      libi2pd/Transports.cpp

4
libi2pd/RouterInfo.h

@ -137,7 +137,7 @@ namespace data
bool operator==(const Address& other) const bool operator==(const Address& other) const
{ {
return transportStyle == other.transportStyle && IsNTCP2 () == other.IsNTCP2 () && return transportStyle == other.transportStyle &&
host == other.host && port == other.port; host == other.host && port == other.port;
} }
@ -149,7 +149,7 @@ namespace data
bool IsNTCP2 () const { return transportStyle == eTransportNTCP; }; bool IsNTCP2 () const { return transportStyle == eTransportNTCP; };
bool IsSSU2 () const { return transportStyle == eTransportSSU2; }; bool IsSSU2 () const { return transportStyle == eTransportSSU2; };
bool IsPublishedNTCP2 () const { return IsNTCP2 () && published; }; bool IsPublishedNTCP2 () const { return IsNTCP2 () && published; };
bool IsReachableSSU () const { return (bool)ssu && (published || !ssu->introducers.empty ()); }; bool IsReachableSSU () const { return (bool)ssu && (published || UsesIntroducer ()); };
bool UsesIntroducer () const { return (bool)ssu && !ssu->introducers.empty (); }; bool UsesIntroducer () const { return (bool)ssu && !ssu->introducers.empty (); };
bool IsIntroducer () const { return caps & eSSUIntroducer; }; bool IsIntroducer () const { return caps & eSSUIntroducer; };

16
libi2pd/SSU2.cpp

@ -1124,16 +1124,9 @@ namespace transport
else else
{ {
// we are Alice, message from Bob // we are Alice, message from Bob
boost::asio::ip::udp::endpoint ep; // update Charlie's endpoint and connect
if (ExtractEndpoint (buf + 12, buf[11], ep)) if (ExtractEndpoint (buf + 12, buf[11], it->second.first->m_RemoteEndpoint))
{ {
// update Charlie's address and connect
auto addr = std::make_shared<i2p::data::RouterInfo::Address> ();
auto addr1 = it->second.first->m_Address;
addr->transportStyle = i2p::data::RouterInfo::eTransportSSU2;
addr->host = ep.address (); addr->port = ep.port ();
addr->s = addr1->s; addr->i = addr1->i; addr->caps = addr1->caps;
it->second.first->m_Address = addr;
it->second.first->m_State = eSSU2SessionStateUnknown; it->second.first->m_State = eSSU2SessionStateUnknown;
it->second.first->Connect (); it->second.first->Connect ();
} }
@ -1767,12 +1760,15 @@ namespace transport
std::shared_ptr<const i2p::data::RouterInfo::Address> address) std::shared_ptr<const i2p::data::RouterInfo::Address> address)
{ {
if (router && address) if (router && address)
{
if (address->UsesIntroducer ()) return false; // not implemented yet
GetService ().post ( GetService ().post (
[this, router, address]() [this, router, address]()
{ {
auto session = std::make_shared<SSU2Session> (*this, router, address); auto session = std::make_shared<SSU2Session> (*this, router, address);
session->Connect (); session->Connect ();
}); });
}
else else
return false; return false;
return true; return true;

2
libi2pd/Transports.cpp

@ -561,7 +561,7 @@ namespace transport
} }
peer.numAttempts++; peer.numAttempts++;
} }
if (address && address->published) if (address && address->IsReachableSSU ())
{ {
if (m_SSU2Server->CreateSession (peer.router, address)) if (m_SSU2Server->CreateSession (peer.router, address))
return true; return true;

Loading…
Cancel
Save