1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-11 13:27:52 +00:00

separate class TransitTunnelBuildMsgHandler for tunnel build messages

This commit is contained in:
orignal 2024-11-16 16:05:46 -05:00
parent 3c608ec07c
commit 0c5f39ad81
4 changed files with 23 additions and 8 deletions

View File

@ -122,7 +122,7 @@ namespace tunnel
}
}
void HandleShortTransitTunnelBuildMsg (std::shared_ptr<I2NPMessage> msg)
void TransitTunnelBuildMsgHandler::HandleShortTransitTunnelBuildMsg (std::shared_ptr<I2NPMessage>&& msg)
{
if (!msg) return;
uint8_t * buf = msg->GetPayload();
@ -275,7 +275,7 @@ namespace tunnel
}
}
static bool HandleBuildRequestRecords (int num, uint8_t * records, uint8_t * clearText)
bool TransitTunnelBuildMsgHandler::HandleBuildRequestRecords (int num, uint8_t * records, uint8_t * clearText)
{
for (int i = 0; i < num; i++)
{
@ -362,7 +362,7 @@ namespace tunnel
return false;
}
void HandleVariableTransitTunnelBuildMsg (std::shared_ptr<I2NPMessage> msg)
void TransitTunnelBuildMsgHandler::HandleVariableTransitTunnelBuildMsg (std::shared_ptr<I2NPMessage>&& msg)
{
if (!msg) return;
uint8_t * buf = msg->GetPayload();

View File

@ -109,8 +109,20 @@ namespace tunnel
const i2p::crypto::AESKey& layerKey, const i2p::crypto::AESKey& ivKey,
bool isGateway, bool isEndpoint);
void HandleShortTransitTunnelBuildMsg (std::shared_ptr<I2NPMessage> msg);
void HandleVariableTransitTunnelBuildMsg (std::shared_ptr<I2NPMessage> msg);
class TransitTunnelBuildMsgHandler
{
public:
void Start () {};
void Stop () {};
void HandleShortTransitTunnelBuildMsg (std::shared_ptr<I2NPMessage>&& msg);
void HandleVariableTransitTunnelBuildMsg (std::shared_ptr<I2NPMessage>&& msg);
private:
bool HandleBuildRequestRecords (int num, uint8_t * records, uint8_t * clearText);
};
}
}

View File

@ -482,10 +482,12 @@ namespace tunnel
{
m_IsRunning = true;
m_Thread = new std::thread (std::bind (&Tunnels::Run, this));
m_TransitTunnelBuildMsgHandler.Start ();
}
void Tunnels::Stop ()
{
m_TransitTunnelBuildMsgHandler.Stop ();
m_IsRunning = false;
m_Queue.WakeUp ();
if (m_Thread)
@ -654,7 +656,7 @@ namespace tunnel
return;
}
else
i2p::tunnel::HandleShortTransitTunnelBuildMsg (msg);
m_TransitTunnelBuildMsgHandler.HandleShortTransitTunnelBuildMsg (std::move (msg));
}
void Tunnels::HandleVariableTunnelBuildMsg (std::shared_ptr<I2NPMessage> msg)
@ -677,7 +679,7 @@ namespace tunnel
}
}
else
i2p::tunnel::HandleVariableTransitTunnelBuildMsg (msg);
m_TransitTunnelBuildMsgHandler.HandleVariableTransitTunnelBuildMsg (std::move (msg));
}
void Tunnels::HandleTunnelBuildReplyMsg (std::shared_ptr<I2NPMessage> msg, bool isShort)

View File

@ -314,7 +314,8 @@ namespace tunnel
double m_TunnelCreationSuccessRate;
int m_TunnelCreationAttemptsNum;
std::mt19937 m_Rng;
TransitTunnelBuildMsgHandler m_TransitTunnelBuildMsgHandler;
public:
// for HTTP only