mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-07 11:54:16 +00:00
don't try to connect directy by SSU2 to unnconfirmed router if direct NTCP2 is presented
This commit is contained in:
parent
6ce2c30522
commit
de673464d1
@ -629,11 +629,18 @@ namespace transport
|
|||||||
auto directTransports = compatibleTransports & peer.router->GetPublishedTransports ();
|
auto directTransports = compatibleTransports & peer.router->GetPublishedTransports ();
|
||||||
peer.numAttempts = 0;
|
peer.numAttempts = 0;
|
||||||
peer.priority.clear ();
|
peer.priority.clear ();
|
||||||
bool ssu2 = peer.router->GetProfile ()->IsReal () ? (rand () & 1) : false; // try NTCP2 if router is not confirmed real
|
bool isReal = peer.router->GetProfile ()->IsReal ();
|
||||||
|
bool ssu2 = isReal ? (rand () & 1) : false; // try NTCP2 if router is not confirmed real
|
||||||
const auto& priority = ssu2 ? ssu2Priority : ntcp2Priority;
|
const auto& priority = ssu2 ? ssu2Priority : ntcp2Priority;
|
||||||
if (directTransports)
|
if (directTransports)
|
||||||
{
|
{
|
||||||
// direct connections have higher priority
|
// direct connections have higher priority
|
||||||
|
if (!isReal && (directTransports & (i2p::data::RouterInfo::eNTCP2V4 | i2p::data::RouterInfo::eNTCP2V6)))
|
||||||
|
{
|
||||||
|
// Non-confirmed router and a NTCP2 direct connection is presented
|
||||||
|
compatibleTransports &= ~directTransports; // exclude SSU2 direct connections
|
||||||
|
directTransports &= (i2p::data::RouterInfo::eSSU2V4 | i2p::data::RouterInfo::eSSU2V6);
|
||||||
|
}
|
||||||
for (auto transport: priority)
|
for (auto transport: priority)
|
||||||
if (transport & directTransports)
|
if (transport & directTransports)
|
||||||
peer.priority.push_back (transport);
|
peer.priority.push_back (transport);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user