mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-02 06:54:15 +00:00
random seelection between NTCP2 and SSU2 priority
This commit is contained in:
parent
cef2263a7f
commit
0a0c2350f2
@ -544,7 +544,8 @@ namespace transport
|
|||||||
|
|
||||||
void Transports::SetPriority (Peer& peer) const
|
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::eNTCP2V6,
|
||||||
i2p::data::RouterInfo::eNTCP2V4,
|
i2p::data::RouterInfo::eNTCP2V4,
|
||||||
@ -553,13 +554,25 @@ namespace transport
|
|||||||
i2p::data::RouterInfo::eNTCP2V6Mesh,
|
i2p::data::RouterInfo::eNTCP2V6Mesh,
|
||||||
i2p::data::RouterInfo::eSSUV6,
|
i2p::data::RouterInfo::eSSUV6,
|
||||||
i2p::data::RouterInfo::eSSUV4
|
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;
|
if (!peer.router) return;
|
||||||
auto compatibleTransports = context.GetRouterInfo ().GetCompatibleTransports (false) &
|
auto compatibleTransports = context.GetRouterInfo ().GetCompatibleTransports (false) &
|
||||||
peer.router->GetCompatibleTransports (true);
|
peer.router->GetCompatibleTransports (true);
|
||||||
peer.numAttempts = 0;
|
peer.numAttempts = 0;
|
||||||
peer.priority.clear ();
|
peer.priority.clear ();
|
||||||
for (auto transport: ntcp2Priority)
|
bool ssu2 = rand () & 1;
|
||||||
|
const auto& priority = ssu2 ? ssu2Priority : ntcp2Priority;
|
||||||
|
for (auto transport: priority)
|
||||||
if (transport & compatibleTransports)
|
if (transport & compatibleTransports)
|
||||||
peer.priority.push_back (transport);
|
peer.priority.push_back (transport);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user