Browse Source

check presense of introducers in SSU2 address

pull/1752/head
orignal 3 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 @@ -137,7 +137,7 @@ namespace data
bool operator==(const Address& other) const
{
return transportStyle == other.transportStyle && IsNTCP2 () == other.IsNTCP2 () &&
return transportStyle == other.transportStyle &&
host == other.host && port == other.port;
}
@ -149,7 +149,7 @@ namespace data @@ -149,7 +149,7 @@ namespace data
bool IsNTCP2 () const { return transportStyle == eTransportNTCP; };
bool IsSSU2 () const { return transportStyle == eTransportSSU2; };
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 IsIntroducer () const { return caps & eSSUIntroducer; };

16
libi2pd/SSU2.cpp

@ -1124,16 +1124,9 @@ namespace transport @@ -1124,16 +1124,9 @@ namespace transport
else
{
// we are Alice, message from Bob
boost::asio::ip::udp::endpoint ep;
if (ExtractEndpoint (buf + 12, buf[11], ep))
// update Charlie's endpoint and connect
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->Connect ();
}
@ -1767,12 +1760,15 @@ namespace transport @@ -1767,12 +1760,15 @@ namespace transport
std::shared_ptr<const i2p::data::RouterInfo::Address> address)
{
if (router && address)
{
if (address->UsesIntroducer ()) return false; // not implemented yet
GetService ().post (
[this, router, address]()
{
auto session = std::make_shared<SSU2Session> (*this, router, address);
session->Connect ();
});
});
}
else
return false;
return true;

2
libi2pd/Transports.cpp

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

Loading…
Cancel
Save