Browse Source

replace GetSession to CreateSession

pull/304/head
orignal 9 years ago
parent
commit
e194854c6d
  1. 6
      SSU.cpp
  2. 2
      SSU.h
  3. 15
      Transports.cpp

6
SSU.cpp

@ -272,7 +272,7 @@ namespace transport @@ -272,7 +272,7 @@ namespace transport
return nullptr;
}
std::shared_ptr<SSUSession> SSUServer::GetSession (std::shared_ptr<const i2p::data::RouterInfo> router, bool peerTest)
void SSUServer::CreateSession (std::shared_ptr<const i2p::data::RouterInfo> router, bool peerTest)
{
std::shared_ptr<SSUSession> session;
if (router)
@ -350,7 +350,6 @@ namespace transport @@ -350,7 +350,6 @@ namespace transport
LogPrint (eLogWarning, "Can't connect to unreachable router. No introducers presented");
std::unique_lock<std::mutex> l(m_SessionsMutex);
m_Sessions.erase (remoteEndpoint);
session.reset ();
}
}
}
@ -358,7 +357,6 @@ namespace transport @@ -358,7 +357,6 @@ namespace transport
else
LogPrint (eLogWarning, "Router ", i2p::data::GetIdentHashAbbreviation (router->GetIdentHash ()), " doesn't have SSU address");
}
return session;
}
void SSUServer::DeleteSession (std::shared_ptr<SSUSession> session)
@ -491,7 +489,7 @@ namespace transport @@ -491,7 +489,7 @@ namespace transport
{
auto introducer = i2p::data::netdb.GetRandomIntroducer ();
if (introducer)
GetSession (introducer);
CreateSession (introducer);
}
ScheduleIntroducersUpdateTimer ();
}

2
SSU.h

@ -40,7 +40,7 @@ namespace transport @@ -40,7 +40,7 @@ namespace transport
~SSUServer ();
void Start ();
void Stop ();
std::shared_ptr<SSUSession> GetSession (std::shared_ptr<const i2p::data::RouterInfo> router, bool peerTest = false);
void CreateSession (std::shared_ptr<const i2p::data::RouterInfo> router, bool peerTest = false);
std::shared_ptr<SSUSession> FindSession (std::shared_ptr<const i2p::data::RouterInfo> router) const;
std::shared_ptr<SSUSession> FindSession (const boost::asio::ip::udp::endpoint& e) const;
std::shared_ptr<SSUSession> GetRandomEstablishedSession (std::shared_ptr<const SSUSession> excluded);

15
Transports.cpp

@ -290,8 +290,11 @@ namespace transport @@ -290,8 +290,11 @@ namespace transport
peer.numAttempts++;
if (m_SSUServer)
{
if (m_SSUServer->GetSession (peer.router))
if (peer.router->IsSSU (!context.SupportsV6 ()))
{
m_SSUServer->CreateSession (peer.router);
return true;
}
}
}
LogPrint (eLogError, "No NTCP and SSU addresses available");
@ -389,14 +392,14 @@ namespace transport @@ -389,14 +392,14 @@ namespace transport
for (int i = 0; i < 5; i++)
{
auto router = i2p::data::netdb.GetRandomPeerTestRouter ();
if (router && router->IsSSU ())
m_SSUServer->GetSession (router, true); // peer test
if (router && router->IsSSU (!context.SupportsV6 ()))
m_SSUServer->CreateSession (router, true); // peer test
else
{
// if not peer test capable routers found pick any
router = i2p::data::netdb.GetRandomRouter ();
if (router && router->IsSSU ())
m_SSUServer->GetSession (router); // no peer test
m_SSUServer->CreateSession (router); // no peer test
}
}
}
@ -412,14 +415,14 @@ namespace transport @@ -412,14 +415,14 @@ namespace transport
for (int i = 0; i < 5; i++)
{
auto router = i2p::data::netdb.GetRandomPeerTestRouter ();
if (router && router->IsSSU ())
if (router && router->IsSSU (!context.SupportsV6 ()))
{
if (!statusChanged)
{
statusChanged = true;
i2p::context.SetStatus (eRouterStatusTesting); // first time only
}
m_SSUServer->GetSession (router, true); // peer test
m_SSUServer->CreateSession (router, true); // peer test
}
}
}

Loading…
Cancel
Save