mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
use list instead vector for addresses
This commit is contained in:
parent
562f320198
commit
d98d091c43
|
@ -224,11 +224,11 @@ namespace i2p
|
||||||
m_RouterInfo.SetCaps (i2p::data::RouterInfo::eUnreachable | i2p::data::RouterInfo::eSSUTesting); // LU, B
|
m_RouterInfo.SetCaps (i2p::data::RouterInfo::eUnreachable | i2p::data::RouterInfo::eSSUTesting); // LU, B
|
||||||
// remove NTCP address
|
// remove NTCP address
|
||||||
auto& addresses = m_RouterInfo.GetAddresses ();
|
auto& addresses = m_RouterInfo.GetAddresses ();
|
||||||
for (size_t i = 0; i < addresses.size (); i++)
|
for (auto it = addresses.begin (); it != addresses.end (); it++)
|
||||||
{
|
{
|
||||||
if (addresses[i]->transportStyle == i2p::data::RouterInfo::eTransportNTCP)
|
if ((*it)->transportStyle == i2p::data::RouterInfo::eTransportNTCP)
|
||||||
{
|
{
|
||||||
addresses.erase (addresses.begin () + i);
|
addresses.erase (it);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,12 +253,12 @@ namespace i2p
|
||||||
|
|
||||||
// insert NTCP back
|
// insert NTCP back
|
||||||
auto& addresses = m_RouterInfo.GetAddresses ();
|
auto& addresses = m_RouterInfo.GetAddresses ();
|
||||||
for (size_t i = 0; i < addresses.size (); i++)
|
for (auto addr : addresses)
|
||||||
{
|
{
|
||||||
if (addresses[i]->transportStyle == i2p::data::RouterInfo::eTransportSSU)
|
if (addr->transportStyle == i2p::data::RouterInfo::eTransportSSU)
|
||||||
{
|
{
|
||||||
// insert NTCP address with host/port from SSU
|
// insert NTCP address with host/port from SSU
|
||||||
m_RouterInfo.AddNTCPAddress (addresses[i]->host.to_string ().c_str (), addresses[i]->port);
|
m_RouterInfo.AddNTCPAddress (addr->host.to_string ().c_str (), addr->port);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -700,28 +700,14 @@ namespace data
|
||||||
{
|
{
|
||||||
if (IsV6 ())
|
if (IsV6 ())
|
||||||
{
|
{
|
||||||
// NTCP
|
m_SupportedTransports &= ~(eNTCPV6 | eSSUV6);
|
||||||
m_SupportedTransports &= ~eNTCPV6;
|
for (auto it = m_Addresses->begin (); it != m_Addresses->end ();)
|
||||||
for (size_t i = 0; i < m_Addresses->size (); i++)
|
|
||||||
{
|
{
|
||||||
if ((*m_Addresses)[i]->transportStyle == i2p::data::RouterInfo::eTransportNTCP &&
|
auto addr = *it;
|
||||||
(*m_Addresses)[i]->host.is_v6 ())
|
if (addr->host.is_v6 ())
|
||||||
{
|
it = m_Addresses->erase (it);
|
||||||
m_Addresses->erase (m_Addresses->begin () + i);
|
else
|
||||||
break;
|
it++;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SSU
|
|
||||||
m_SupportedTransports &= ~eSSUV6;
|
|
||||||
for (size_t i = 0; i < m_Addresses->size (); i++)
|
|
||||||
{
|
|
||||||
if ((*m_Addresses)[i]->transportStyle == i2p::data::RouterInfo::eTransportSSU &&
|
|
||||||
(*m_Addresses)[i]->host.is_v6 ())
|
|
||||||
{
|
|
||||||
m_Addresses->erase (m_Addresses->begin () + i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -730,28 +716,14 @@ namespace data
|
||||||
{
|
{
|
||||||
if (IsV4 ())
|
if (IsV4 ())
|
||||||
{
|
{
|
||||||
// NTCP
|
m_SupportedTransports &= ~(eNTCPV4 | eSSUV4);
|
||||||
m_SupportedTransports &= ~eNTCPV4;
|
for (auto it = m_Addresses->begin (); it != m_Addresses->end ();)
|
||||||
for (size_t i = 0; i < m_Addresses->size (); i++)
|
|
||||||
{
|
{
|
||||||
if ((*m_Addresses)[i]->transportStyle == i2p::data::RouterInfo::eTransportNTCP &&
|
auto addr = *it;
|
||||||
(*m_Addresses)[i]->host.is_v4 ())
|
if (addr->host.is_v4 ())
|
||||||
{
|
it = m_Addresses->erase (it);
|
||||||
m_Addresses->erase (m_Addresses->begin () + i);
|
else
|
||||||
break;
|
it++;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SSU
|
|
||||||
m_SupportedTransports &= ~eSSUV4;
|
|
||||||
for (size_t i = 0; i < m_Addresses->size (); i++)
|
|
||||||
{
|
|
||||||
if ((*m_Addresses)[i]->transportStyle == i2p::data::RouterInfo::eTransportSSU &&
|
|
||||||
(*m_Addresses)[i]->host.is_v4 ())
|
|
||||||
{
|
|
||||||
m_Addresses->erase (m_Addresses->begin () + i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <list>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include "Identity.h"
|
#include "Identity.h"
|
||||||
|
@ -105,7 +106,7 @@ namespace data
|
||||||
return !(*this == other);
|
return !(*this == other);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
typedef std::vector<std::shared_ptr<Address> > Addresses;
|
typedef std::list<std::shared_ptr<Address> > Addresses;
|
||||||
|
|
||||||
RouterInfo ();
|
RouterInfo ();
|
||||||
RouterInfo (const std::string& fullPath);
|
RouterInfo (const std::string& fullPath);
|
||||||
|
|
Loading…
Reference in a new issue