Browse Source

random seelection between NTCP2 and SSU2 priority

pull/1794/head
orignal 2 years ago
parent
commit
0a0c2350f2
  1. 17
      libi2pd/Transports.cpp

17
libi2pd/Transports.cpp

@ -544,7 +544,8 @@ namespace transport @@ -544,7 +544,8 @@ namespace transport
void Transports::SetPriority (Peer& peer) const
{
static const std::vector<i2p::data::RouterInfo::SupportedTransports> ntcp2Priority =
static const std::vector<i2p::data::RouterInfo::SupportedTransports>
ntcp2Priority =
{
i2p::data::RouterInfo::eNTCP2V6,
i2p::data::RouterInfo::eNTCP2V4,
@ -553,13 +554,25 @@ namespace transport @@ -553,13 +554,25 @@ namespace transport
i2p::data::RouterInfo::eNTCP2V6Mesh,
i2p::data::RouterInfo::eSSUV6,
i2p::data::RouterInfo::eSSUV4
},
ssu2Priority =
{
i2p::data::RouterInfo::eSSU2V6,
i2p::data::RouterInfo::eSSU2V4,
i2p::data::RouterInfo::eNTCP2V6,
i2p::data::RouterInfo::eNTCP2V4,
i2p::data::RouterInfo::eNTCP2V6Mesh,
i2p::data::RouterInfo::eSSUV6,
i2p::data::RouterInfo::eSSUV4
};
if (!peer.router) return;
auto compatibleTransports = context.GetRouterInfo ().GetCompatibleTransports (false) &
peer.router->GetCompatibleTransports (true);
peer.numAttempts = 0;
peer.priority.clear ();
for (auto transport: ntcp2Priority)
bool ssu2 = rand () & 1;
const auto& priority = ssu2 ? ssu2Priority : ntcp2Priority;
for (auto transport: priority)
if (transport & compatibleTransports)
peer.priority.push_back (transport);
}

Loading…
Cancel
Save