mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
don't include same introducer twice
This commit is contained in:
parent
98fd1c7dbc
commit
5435d20199
@ -85,14 +85,17 @@ namespace i2p
|
|||||||
UpdateRouterInfo ();
|
UpdateRouterInfo ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouterContext::AddIntroducer (const i2p::data::RouterInfo& routerInfo, uint32_t tag)
|
bool RouterContext::AddIntroducer (const i2p::data::RouterInfo& routerInfo, uint32_t tag)
|
||||||
{
|
{
|
||||||
|
bool ret = false;
|
||||||
auto address = routerInfo.GetSSUAddress ();
|
auto address = routerInfo.GetSSUAddress ();
|
||||||
if (address)
|
if (address)
|
||||||
{
|
{
|
||||||
if (m_RouterInfo.AddIntroducer (address, tag))
|
ret = m_RouterInfo.AddIntroducer (address, tag);
|
||||||
|
if (ret)
|
||||||
UpdateRouterInfo ();
|
UpdateRouterInfo ();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouterContext::RemoveIntroducer (const boost::asio::ip::udp::endpoint& e)
|
void RouterContext::RemoveIntroducer (const boost::asio::ip::udp::endpoint& e)
|
||||||
|
@ -28,7 +28,7 @@ namespace i2p
|
|||||||
|
|
||||||
void OverrideNTCPAddress (const char * host, int port); // temporary
|
void OverrideNTCPAddress (const char * host, int port); // temporary
|
||||||
void UpdateAddress (const char * host); // called from SSU
|
void UpdateAddress (const char * host); // called from SSU
|
||||||
void AddIntroducer (const i2p::data::RouterInfo& routerInfo, uint32_t tag);
|
bool AddIntroducer (const i2p::data::RouterInfo& routerInfo, uint32_t tag);
|
||||||
void RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
|
void RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
|
||||||
bool IsUnreachable () const { return m_IsUnreachable; };
|
bool IsUnreachable () const { return m_IsUnreachable; };
|
||||||
void SetUnreachable ();
|
void SetUnreachable ();
|
||||||
|
11
SSU.cpp
11
SSU.cpp
@ -1156,7 +1156,7 @@ namespace ssu
|
|||||||
{
|
{
|
||||||
// timeout expired
|
// timeout expired
|
||||||
std::list<boost::asio::ip::udp::endpoint> newList;
|
std::list<boost::asio::ip::udp::endpoint> newList;
|
||||||
int numIntroducers = 0;
|
size_t numIntroducers = 0;
|
||||||
for (auto it :m_Introducers)
|
for (auto it :m_Introducers)
|
||||||
{
|
{
|
||||||
auto session = FindSession (it);
|
auto session = FindSession (it);
|
||||||
@ -1173,13 +1173,16 @@ namespace ssu
|
|||||||
if (numIntroducers < SSU_MAX_NUM_INTRODUCERS)
|
if (numIntroducers < SSU_MAX_NUM_INTRODUCERS)
|
||||||
{
|
{
|
||||||
// create new
|
// create new
|
||||||
auto introducers = FindIntroducers (SSU_MAX_NUM_INTRODUCERS - numIntroducers);
|
auto introducers = FindIntroducers (SSU_MAX_NUM_INTRODUCERS);
|
||||||
if (introducers.size () > 0)
|
if (introducers.size () > 0)
|
||||||
{
|
{
|
||||||
for (auto it1: introducers)
|
for (auto it1: introducers)
|
||||||
{
|
{
|
||||||
i2p::context.AddIntroducer (*it1->GetRemoteRouter (), it1->GetRelayTag ());
|
if (i2p::context.AddIntroducer (*it1->GetRemoteRouter (), it1->GetRelayTag ()))
|
||||||
newList.push_back (it1->GetRemoteEndpoint ());
|
{
|
||||||
|
newList.push_back (it1->GetRemoteEndpoint ());
|
||||||
|
if (newList.size () >= SSU_MAX_NUM_INTRODUCERS) break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
SSU.h
2
SSU.h
@ -35,7 +35,7 @@ namespace ssu
|
|||||||
const int SSU_TERMINATION_TIMEOUT = 330; // 5.5 minutes
|
const int SSU_TERMINATION_TIMEOUT = 330; // 5.5 minutes
|
||||||
const int SSU_KEEP_ALIVE_INTERVAL = 30; // 30 seconds
|
const int SSU_KEEP_ALIVE_INTERVAL = 30; // 30 seconds
|
||||||
const int SSU_TO_INTRODUCER_SESSION_DURATION = 3600; // 1 hour
|
const int SSU_TO_INTRODUCER_SESSION_DURATION = 3600; // 1 hour
|
||||||
const int SSU_MAX_NUM_INTRODUCERS = 3;
|
const size_t SSU_MAX_NUM_INTRODUCERS = 3;
|
||||||
|
|
||||||
// payload types (4 bits)
|
// payload types (4 bits)
|
||||||
const uint8_t PAYLOAD_TYPE_SESSION_REQUEST = 0;
|
const uint8_t PAYLOAD_TYPE_SESSION_REQUEST = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user