mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-22 00:59:08 +01:00
check ureachable cap and actual introducers separately
This commit is contained in:
parent
4f3333c841
commit
0f166973ca
5 changed files with 8 additions and 12 deletions
|
@ -454,7 +454,7 @@ namespace data
|
||||||
{
|
{
|
||||||
auto r = std::make_shared<RouterInfo>(path);
|
auto r = std::make_shared<RouterInfo>(path);
|
||||||
if (r->GetRouterIdentity () && !r->IsUnreachable () &&
|
if (r->GetRouterIdentity () && !r->IsUnreachable () &&
|
||||||
(!r->UsesIntroducer () || m_LastLoad < r->GetTimestamp () + NETDB_INTRODUCEE_EXPIRATION_TIMEOUT*1000LL)) // 1 hour
|
(!r->HasUnreachableCap () || m_LastLoad < r->GetTimestamp () + NETDB_INTRODUCEE_EXPIRATION_TIMEOUT*1000LL)) // 1 hour
|
||||||
{
|
{
|
||||||
r->DeleteBuffer ();
|
r->DeleteBuffer ();
|
||||||
r->ClearProperties (); // properties are not used for regular routers
|
r->ClearProperties (); // properties are not used for regular routers
|
||||||
|
@ -584,7 +584,7 @@ namespace data
|
||||||
if (it.second->IsUnreachable () && total - deletedCount < NETDB_MIN_ROUTERS)
|
if (it.second->IsUnreachable () && total - deletedCount < NETDB_MIN_ROUTERS)
|
||||||
it.second->SetUnreachable (false);
|
it.second->SetUnreachable (false);
|
||||||
// find & mark expired routers
|
// find & mark expired routers
|
||||||
if (it.second->UsesIntroducer ())
|
if (it.second->HasUnreachableCap ())
|
||||||
{
|
{
|
||||||
if (ts > it.second->GetTimestamp () + NETDB_INTRODUCEE_EXPIRATION_TIMEOUT*1000LL)
|
if (ts > it.second->GetTimestamp () + NETDB_INTRODUCEE_EXPIRATION_TIMEOUT*1000LL)
|
||||||
// RouterInfo expires after 1 hour if uses introducer
|
// RouterInfo expires after 1 hour if uses introducer
|
||||||
|
|
|
@ -1007,11 +1007,6 @@ namespace data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RouterInfo::UsesIntroducer () const
|
|
||||||
{
|
|
||||||
return m_Caps & Caps::eUnreachable; // non-reachable
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<const RouterInfo::Address> RouterInfo::GetSSUAddress (bool v4only) const
|
std::shared_ptr<const RouterInfo::Address> RouterInfo::GetSSUAddress (bool v4only) const
|
||||||
{
|
{
|
||||||
return GetAddress (
|
return GetAddress (
|
||||||
|
|
|
@ -148,6 +148,7 @@ namespace data
|
||||||
bool IsNTCP2 () const { return (bool)ntcp2; };
|
bool IsNTCP2 () const { return (bool)ntcp2; };
|
||||||
bool IsPublishedNTCP2 () const { return IsNTCP2 () && ntcp2->isPublished; };
|
bool IsPublishedNTCP2 () const { return IsNTCP2 () && ntcp2->isPublished; };
|
||||||
bool IsReachableSSU () const { return (bool)ssu && (!host.is_unspecified () || !ssu->introducers.empty ()); };
|
bool IsReachableSSU () const { return (bool)ssu && (!host.is_unspecified () || !ssu->introducers.empty ()); };
|
||||||
|
bool UsesIntroducer () const { return (bool)ssu && !ssu->introducers.empty (); };
|
||||||
|
|
||||||
bool IsIntroducer () const { return caps & eSSUIntroducer; };
|
bool IsIntroducer () const { return caps & eSSUIntroducer; };
|
||||||
bool IsPeerTesting () const { return caps & eSSUTesting; };
|
bool IsPeerTesting () const { return caps & eSSUTesting; };
|
||||||
|
@ -188,6 +189,7 @@ namespace data
|
||||||
void SetUnreachableAddressesTransportCaps (uint8_t transports); // bitmask of AddressCaps
|
void SetUnreachableAddressesTransportCaps (uint8_t transports); // bitmask of AddressCaps
|
||||||
bool IsFloodfill () const { return m_Caps & Caps::eFloodfill; };
|
bool IsFloodfill () const { return m_Caps & Caps::eFloodfill; };
|
||||||
bool IsReachable () const { return m_Caps & Caps::eReachable; };
|
bool IsReachable () const { return m_Caps & Caps::eReachable; };
|
||||||
|
bool HasUnreachableCap () const { return m_Caps & Caps::eUnreachable; };
|
||||||
bool IsSSU (bool v4only = true) const;
|
bool IsSSU (bool v4only = true) const;
|
||||||
bool IsSSUV6 () const;
|
bool IsSSUV6 () const;
|
||||||
bool IsNTCP2 (bool v4only = true) const;
|
bool IsNTCP2 (bool v4only = true) const;
|
||||||
|
@ -204,7 +206,6 @@ namespace data
|
||||||
bool IsCompatible (const RouterInfo& other) const { return m_SupportedTransports & other.m_SupportedTransports; };
|
bool IsCompatible (const RouterInfo& other) const { return m_SupportedTransports & other.m_SupportedTransports; };
|
||||||
bool IsReachableFrom (const RouterInfo& other) const;
|
bool IsReachableFrom (const RouterInfo& other) const;
|
||||||
bool HasValidAddresses () const { return m_SupportedTransports; };
|
bool HasValidAddresses () const { return m_SupportedTransports; };
|
||||||
bool UsesIntroducer () const;
|
|
||||||
bool IsHidden () const { return m_Caps & eHidden; };
|
bool IsHidden () const { return m_Caps & eHidden; };
|
||||||
bool IsHighBandwidth () const { return m_Caps & RouterInfo::eHighBandwidth; };
|
bool IsHighBandwidth () const { return m_Caps & RouterInfo::eHighBandwidth; };
|
||||||
bool IsExtraBandwidth () const { return m_Caps & RouterInfo::eExtraBandwidth; };
|
bool IsExtraBandwidth () const { return m_Caps & RouterInfo::eExtraBandwidth; };
|
||||||
|
|
|
@ -445,7 +445,7 @@ namespace transport
|
||||||
{
|
{
|
||||||
if (router && address)
|
if (router && address)
|
||||||
{
|
{
|
||||||
if (router->UsesIntroducer ())
|
if (address->UsesIntroducer ())
|
||||||
m_Service.post (std::bind (&SSUServer::CreateSessionThroughIntroducer, this, router, address, peerTest)); // always V4 thread
|
m_Service.post (std::bind (&SSUServer::CreateSessionThroughIntroducer, this, router, address, peerTest)); // always V4 thread
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -481,7 +481,7 @@ namespace transport
|
||||||
void SSUServer::CreateSessionThroughIntroducer (std::shared_ptr<const i2p::data::RouterInfo> router,
|
void SSUServer::CreateSessionThroughIntroducer (std::shared_ptr<const i2p::data::RouterInfo> router,
|
||||||
std::shared_ptr<const i2p::data::RouterInfo::Address> address, bool peerTest)
|
std::shared_ptr<const i2p::data::RouterInfo::Address> address, bool peerTest)
|
||||||
{
|
{
|
||||||
if (router && router->UsesIntroducer () && address)
|
if (router && address && address->UsesIntroducer ())
|
||||||
{
|
{
|
||||||
if (address->IsV4 () && !i2p::context.SupportsV4 ()) return;
|
if (address->IsV4 () && !i2p::context.SupportsV4 ()) return;
|
||||||
if (address->IsV6 () && !i2p::context.SupportsV6 ()) return;
|
if (address->IsV6 () && !i2p::context.SupportsV6 ()) return;
|
||||||
|
@ -566,7 +566,7 @@ namespace transport
|
||||||
LogPrint (eLogInfo, "SSU: Introduce new session to [", i2p::data::GetIdentHashAbbreviation (router->GetIdentHash ()),
|
LogPrint (eLogInfo, "SSU: Introduce new session to [", i2p::data::GetIdentHashAbbreviation (router->GetIdentHash ()),
|
||||||
"] through introducer ", introducer->iHost, ":", introducer->iPort);
|
"] through introducer ", introducer->iHost, ":", introducer->iPort);
|
||||||
session->WaitForIntroduction ();
|
session->WaitForIntroduction ();
|
||||||
if (i2p::context.GetRouterInfo ().UsesIntroducer ()) // if we are unreachable
|
if (i2p::context.GetRouterInfo ().HasUnreachableCap ()) // if we are unreachable. TODO: ipv4 and ipv6
|
||||||
{
|
{
|
||||||
uint8_t buf[1];
|
uint8_t buf[1];
|
||||||
Send (buf, 0, remoteEndpoint); // send HolePunch
|
Send (buf, 0, remoteEndpoint); // send HolePunch
|
||||||
|
|
|
@ -681,7 +681,7 @@ namespace transport
|
||||||
// we didn't have correct endpoint when sent relay request
|
// we didn't have correct endpoint when sent relay request
|
||||||
// now we do
|
// now we do
|
||||||
LogPrint (eLogInfo, "SSU: RelayReponse connecting to endpoint ", remoteEndpoint);
|
LogPrint (eLogInfo, "SSU: RelayReponse connecting to endpoint ", remoteEndpoint);
|
||||||
if (i2p::context.GetRouterInfo ().UsesIntroducer ()) // if we are unreachable
|
if (i2p::context.GetRouterInfo ().HasUnreachableCap ()) // if we are unreachable. TODO: ipv4 and ipv6
|
||||||
m_Server.Send (buf, 0, remoteEndpoint); // send HolePunch
|
m_Server.Send (buf, 0, remoteEndpoint); // send HolePunch
|
||||||
// we assume that HolePunch has been sent by this time and our SessionRequest will go through
|
// we assume that HolePunch has been sent by this time and our SessionRequest will go through
|
||||||
m_Server.CreateDirectSession (it->second, remoteEndpoint, false);
|
m_Server.CreateDirectSession (it->second, remoteEndpoint, false);
|
||||||
|
|
Loading…
Add table
Reference in a new issue