mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 08:00:38 +03:00
send multiple messages
This commit is contained in:
parent
91199a9053
commit
30ecf1ef8c
22
Tunnel.cpp
22
Tunnel.cpp
@ -139,11 +139,27 @@ namespace tunnel
|
|||||||
m_Gateway.SendTunnelDataMsg (gwHash, gwTunnel, msg);
|
m_Gateway.SendTunnelDataMsg (gwHash, gwTunnel, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutboundTunnel::SendTunnelDataMsg (i2p::I2NPMessage * msg)
|
void OutboundTunnel::SendTunnelDataMsg (std::vector<TunnelMessageBlock> msgs)
|
||||||
{
|
{
|
||||||
SendTunnelDataMsg (nullptr, 0, msg);
|
for (auto& it : msgs)
|
||||||
|
{
|
||||||
|
switch (it.deliveryType)
|
||||||
|
{
|
||||||
|
case eDeliveryTypeLocal:
|
||||||
|
m_Gateway.SendTunnelDataMsg (nullptr, 0, it.data);
|
||||||
|
break;
|
||||||
|
case eDeliveryTypeTunnel:
|
||||||
|
m_Gateway.SendTunnelDataMsg (it.hash, it.tunnelID, it.data);
|
||||||
|
break;
|
||||||
|
case eDeliveryTypeRouter:
|
||||||
|
m_Gateway.SendTunnelDataMsg (it.hash, 0, it.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LogPrint ("Unexpected delivery type ", (int)it.deliveryType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_Gateway.SendBuffer ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Tunnels tunnels;
|
Tunnels tunnels;
|
||||||
|
|
||||||
|
3
Tunnel.h
3
Tunnel.h
@ -4,6 +4,7 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <cryptopp/modes.h>
|
#include <cryptopp/modes.h>
|
||||||
@ -64,8 +65,8 @@ namespace tunnel
|
|||||||
|
|
||||||
OutboundTunnel (TunnelConfig * config): Tunnel (config), m_Gateway (this) {};
|
OutboundTunnel (TunnelConfig * config): Tunnel (config), m_Gateway (this) {};
|
||||||
|
|
||||||
void SendTunnelDataMsg (i2p::I2NPMessage * msg); //local
|
|
||||||
void SendTunnelDataMsg (const uint8_t * gwHash, uint32_t gwTunnel, i2p::I2NPMessage * msg);
|
void SendTunnelDataMsg (const uint8_t * gwHash, uint32_t gwTunnel, i2p::I2NPMessage * msg);
|
||||||
|
void SendTunnelDataMsg (std::vector<TunnelMessageBlock> msgs); // multiple messages
|
||||||
|
|
||||||
TunnelGateway& GetTunnelGateway () { return m_Gateway; };
|
TunnelGateway& GetTunnelGateway () { return m_Gateway; };
|
||||||
size_t GetNumSentBytes () const { return m_Gateway.GetNumSentBytes (); };
|
size_t GetNumSentBytes () const { return m_Gateway.GetNumSentBytes (); };
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include "Timestamp.h"
|
#include "Timestamp.h"
|
||||||
#include "I2NPProtocol.h"
|
#include "I2NPProtocol.h"
|
||||||
|
#include "Identity.h"
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
@ -23,7 +24,7 @@ namespace tunnel
|
|||||||
{
|
{
|
||||||
TunnelDeliveryType deliveryType;
|
TunnelDeliveryType deliveryType;
|
||||||
uint32_t tunnelID;
|
uint32_t tunnelID;
|
||||||
uint8_t hash[32];
|
i2p::data::IdentHash hash;
|
||||||
I2NPMessage * data;
|
I2NPMessage * data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -41,12 +41,12 @@ namespace tunnel
|
|||||||
LogPrint ("Delivery type tunnel");
|
LogPrint ("Delivery type tunnel");
|
||||||
m.tunnelID = be32toh (*(uint32_t *)fragment);
|
m.tunnelID = be32toh (*(uint32_t *)fragment);
|
||||||
fragment += 4; // tunnelID
|
fragment += 4; // tunnelID
|
||||||
memcpy (m.hash, fragment, 32);
|
m.hash = i2p::data::IdentHash (fragment);
|
||||||
fragment += 32; // hash
|
fragment += 32; // hash
|
||||||
break;
|
break;
|
||||||
case eDeliveryTypeRouter: // 2
|
case eDeliveryTypeRouter: // 2
|
||||||
LogPrint ("Delivery type router");
|
LogPrint ("Delivery type router");
|
||||||
memcpy (m.hash, fragment, 32);
|
m.hash = i2p::data::IdentHash (fragment);
|
||||||
fragment += 32; // to hash
|
fragment += 32; // to hash
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user