mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
don't request relay tag for every session if we have enough introducers
This commit is contained in:
parent
4178ac8eac
commit
0b97b4294c
@ -72,6 +72,7 @@ namespace transport
|
||||
bool IsSupported (const boost::asio::ip::address& addr) const;
|
||||
uint16_t GetPort (bool v4) const;
|
||||
std::mt19937& GetRng () { return m_Rng; }
|
||||
bool IsMaxNumIntroducers (bool v4) const { return (v4 ? m_Introducers.size () : m_IntroducersV6.size ()) >= SSU2_MAX_NUM_INTRODUCERS; }
|
||||
bool IsSyncClockFromPeers () const { return m_IsSyncClockFromPeers; };
|
||||
void AdjustTimeOffset (int64_t offset, std::shared_ptr<const i2p::data::IdentityEx> from);
|
||||
|
||||
|
@ -679,12 +679,16 @@ namespace transport
|
||||
htobe32buf (payload + 3, (ts + 500)/1000);
|
||||
size_t payloadSize = 7;
|
||||
if (GetRouterStatus () == eRouterStatusFirewalled && m_Address->IsIntroducer ())
|
||||
{
|
||||
if (!m_Server.IsMaxNumIntroducers (m_RemoteEndpoint.address ().is_v4 ()) ||
|
||||
m_Server.GetRng ()() & 0x01) // request tag with probability 1/2 if we have enough introducers
|
||||
{
|
||||
// relay tag request
|
||||
payload[payloadSize] = eSSU2BlkRelayTagRequest;
|
||||
memset (payload + payloadSize + 1, 0, 2); // size = 0
|
||||
payloadSize += 3;
|
||||
}
|
||||
}
|
||||
payloadSize += CreatePaddingBlock (payload + payloadSize, 40 - payloadSize, 1);
|
||||
// KDF for session request
|
||||
m_NoiseState->MixHash ({ {header.buf, 16}, {headerX, 16} }); // h = SHA256(h || header)
|
||||
|
Loading…
Reference in New Issue
Block a user