mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
send update local RouterInfo
This commit is contained in:
parent
605ccf3e02
commit
3bef6383d9
@ -1169,9 +1169,9 @@ namespace transport
|
||||
}
|
||||
}
|
||||
|
||||
void NTCP2Session::SendLocalRouterInfo ()
|
||||
void NTCP2Session::SendLocalRouterInfo (bool update)
|
||||
{
|
||||
if (!IsOutgoing ()) // we send it in SessionConfirmed
|
||||
if (update || !IsOutgoing ()) // we send it in SessionConfirmed for ougoing session
|
||||
m_Server.GetService ().post (std::bind (&NTCP2Session::SendRouterInfo, shared_from_this ()));
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ namespace transport
|
||||
void ClientLogin (); // Alice
|
||||
void ServerLogin (); // Bob
|
||||
|
||||
void SendLocalRouterInfo (); // after handshake
|
||||
void SendLocalRouterInfo (bool update); // after handshake or by update
|
||||
void SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs);
|
||||
|
||||
private:
|
||||
|
@ -161,6 +161,29 @@ namespace transport
|
||||
m_Server.GetService ().post (std::bind (&SSU2Session::Terminate, shared_from_this ()));
|
||||
}
|
||||
|
||||
void SSU2Session::SendLocalRouterInfo (bool update)
|
||||
{
|
||||
if (update || !IsOutgoing ())
|
||||
{
|
||||
auto s = shared_from_this ();
|
||||
m_Server.GetService ().post ([s]()
|
||||
{
|
||||
if (!s->IsEstablished ()) return;
|
||||
uint8_t payload[SSU2_MAX_PAYLOAD_SIZE];
|
||||
size_t payloadSize = s->CreateRouterInfoBlock (payload, SSU2_MAX_PAYLOAD_SIZE - 32, i2p::context.GetSharedRouterInfo ());
|
||||
if (payloadSize)
|
||||
{
|
||||
if (payloadSize < SSU2_MAX_PAYLOAD_SIZE)
|
||||
payloadSize += s->CreatePaddingBlock (payload + payloadSize, SSU2_MAX_PAYLOAD_SIZE - payloadSize);
|
||||
s->SendData (payload, payloadSize);
|
||||
}
|
||||
else
|
||||
s->SendFragmentedMessage (CreateDatabaseStoreMsg ());
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SSU2Session::SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs)
|
||||
{
|
||||
m_Server.GetService ().post (std::bind (&SSU2Session::PostI2NPMessages, shared_from_this (), msgs));
|
||||
|
@ -173,6 +173,7 @@ namespace transport
|
||||
void CleanUp (uint64_t ts);
|
||||
void FlushData ();
|
||||
void Done () override;
|
||||
void SendLocalRouterInfo (bool update) override;
|
||||
void SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs) override;
|
||||
void Resend (uint64_t ts);
|
||||
bool IsEstablished () const { return m_State == eSSU2SessionStateEstablished; };
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2020, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2022, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@ -96,7 +96,7 @@ namespace transport
|
||||
bool IsTerminationTimeoutExpired (uint64_t ts) const
|
||||
{ return ts >= m_LastActivityTimestamp + GetTerminationTimeout (); };
|
||||
|
||||
virtual void SendLocalRouterInfo () { SendI2NPMessages ({ CreateDatabaseStoreMsg () }); };
|
||||
virtual void SendLocalRouterInfo (bool update = false) { SendI2NPMessages ({ CreateDatabaseStoreMsg () }); };
|
||||
virtual void SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs) = 0;
|
||||
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user