Browse Source

avoid duplicated addresses. Check presence of netId and version

pull/1717/head
orignal 3 years ago
parent
commit
1c95c7856f
  1. 11
      libi2pd/RouterInfo.cpp

11
libi2pd/RouterInfo.cpp

@ -370,6 +370,7 @@ namespace data @@ -370,6 +370,7 @@ namespace data
}
if (supportedTransports)
{
if (!(m_SupportedTransports & supportedTransports)) // avoid duplicates
addresses->push_back(address);
m_SupportedTransports |= supportedTransports;
}
@ -384,6 +385,8 @@ namespace data @@ -384,6 +385,8 @@ namespace data
s.read ((char *)&numPeers, sizeof (numPeers)); if (!s) return;
s.seekg (numPeers*32, std::ios_base::cur); // TODO: read peers
// read properties
m_Version = 0;
bool isNetId = false;
uint16_t size, r = 0;
s.read ((char *)&size, sizeof (size)); if (!s) return;
size = be16toh (size);
@ -416,11 +419,15 @@ namespace data @@ -416,11 +419,15 @@ namespace data
}
}
// check netId
else if (!strcmp (key, ROUTER_INFO_PROPERTY_NETID) && atoi (value) != i2p::context.GetNetID ())
else if (!strcmp (key, ROUTER_INFO_PROPERTY_NETID))
{
isNetId = true;
if (atoi (value) != i2p::context.GetNetID ())
{
LogPrint (eLogError, "RouterInfo: Unexpected ", ROUTER_INFO_PROPERTY_NETID, "=", value);
m_IsUnreachable = true;
}
}
// family
else if (!strcmp (key, ROUTER_INFO_PROPERTY_FAMILY))
{
@ -439,7 +446,7 @@ namespace data @@ -439,7 +446,7 @@ namespace data
if (!s) return;
}
if (!m_SupportedTransports)
if (!m_SupportedTransports || !isNetId || !m_Version)
SetUnreachable (true);
}

Loading…
Cancel
Save