From 0a0c2350f2c931b843baa31fbd1cc480b6b805db Mon Sep 17 00:00:00 2001 From: orignal Date: Sat, 1 Oct 2022 19:39:08 -0400 Subject: [PATCH] random seelection between NTCP2 and SSU2 priority --- libi2pd/Transports.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/libi2pd/Transports.cpp b/libi2pd/Transports.cpp index 17b0e80e..b582ce50 100644 --- a/libi2pd/Transports.cpp +++ b/libi2pd/Transports.cpp @@ -544,7 +544,8 @@ namespace transport void Transports::SetPriority (Peer& peer) const { - static const std::vector ntcp2Priority = + static const std::vector + ntcp2Priority = { i2p::data::RouterInfo::eNTCP2V6, i2p::data::RouterInfo::eNTCP2V4, @@ -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); }