mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-10-23 21:32:57 +00:00
don't send datagrams to self
This commit is contained in:
1 parent
8248c75ae1
commit
6176bccc7e
1 file changed
+18
-8
@@ -816,7 +816,7 @@ namespace torrents
|
||||
{
|
||||
memcpy (nodeInfo.data (), nodes.data (), nodeInfo.size ());
|
||||
auto node = std::make_shared<Node>(nodeInfo);
|
||||
if (info && node->VerifyID () && info->AddNode (node))
|
||||
if (info && node->id != m_NodeID && node->VerifyID () && info->AddNode (node))
|
||||
{
|
||||
if (m_HeardFrom.contains (node->id))
|
||||
UpdateNode (node);
|
||||
@@ -855,7 +855,7 @@ namespace torrents
|
||||
{
|
||||
memcpy (nodeInfo.data (), nodes.data (), nodeInfo.size ());
|
||||
auto node = std::make_shared<Node>(nodeInfo);
|
||||
if (info && node->VerifyID () && info->AddNode (node))
|
||||
if (info && node->id != m_NodeID && node->VerifyID () && info->AddNode (node))
|
||||
{
|
||||
if (m_HeardFrom.contains (node->id))
|
||||
UpdateNode (node);
|
||||
@@ -881,9 +881,14 @@ namespace torrents
|
||||
auto dest = m_Tunnel.GetLocalDestination ();
|
||||
if (dest)
|
||||
{
|
||||
auto dgramDest = dest->GetDatagramDestination ();
|
||||
if (dgramDest)
|
||||
dgramDest->SendDatagramTo ((const uint8_t *)msg.data (), msg.size (), toIdent, m_Port, toPort);
|
||||
if (toIdent != dest->GetIdentHash ())
|
||||
{
|
||||
auto dgramDest = dest->GetDatagramDestination ();
|
||||
if (dgramDest)
|
||||
dgramDest->SendDatagramTo ((const uint8_t *)msg.data (), msg.size (), toIdent, m_Port, toPort);
|
||||
}
|
||||
else
|
||||
LogPrint (eLogWarning, "TorrentsDHT: Can't send datagram to self");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -892,9 +897,14 @@ namespace torrents
|
||||
auto dest = m_Tunnel.GetLocalDestination ();
|
||||
if (dest)
|
||||
{
|
||||
auto dgramDest = dest->GetDatagramDestination ();
|
||||
if (dgramDest)
|
||||
dgramDest->SendRawDatagramTo ((const uint8_t *)msg.data (), msg.size (), toIdent, m_Port, toPort);
|
||||
if (toIdent != dest->GetIdentHash ())
|
||||
{
|
||||
auto dgramDest = dest->GetDatagramDestination ();
|
||||
if (dgramDest)
|
||||
dgramDest->SendRawDatagramTo ((const uint8_t *)msg.data (), msg.size (), toIdent, m_Port, toPort);
|
||||
}
|
||||
else
|
||||
LogPrint (eLogWarning, "TorrentsDHT: Can't send raw datagram to self");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user