mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
avoid duplicated addresses. Check presence of netId and version
This commit is contained in:
parent
daf7551e59
commit
1c95c7856f
@ -368,9 +368,10 @@ namespace data
|
||||
}
|
||||
}
|
||||
}
|
||||
if (supportedTransports)
|
||||
if (supportedTransports)
|
||||
{
|
||||
addresses->push_back(address);
|
||||
if (!(m_SupportedTransports & supportedTransports)) // avoid duplicates
|
||||
addresses->push_back(address);
|
||||
m_SupportedTransports |= supportedTransports;
|
||||
}
|
||||
}
|
||||
@ -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,10 +419,14 @@ 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))
|
||||
{
|
||||
LogPrint (eLogError, "RouterInfo: Unexpected ", ROUTER_INFO_PROPERTY_NETID, "=", value);
|
||||
m_IsUnreachable = true;
|
||||
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
|
||||
if (!s) return;
|
||||
}
|
||||
|
||||
if (!m_SupportedTransports)
|
||||
if (!m_SupportedTransports || !isNetId || !m_Version)
|
||||
SetUnreachable (true);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user