mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
send multiple messages
This commit is contained in:
parent
30ecf1ef8c
commit
0b079f4723
48
NetDb.cpp
48
NetDb.cpp
@ -1,5 +1,6 @@
|
|||||||
#include "I2PEndian.h"
|
#include "I2PEndian.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <vector>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <cryptopp/gzip.h>
|
#include <cryptopp/gzip.h>
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
@ -313,7 +314,8 @@ namespace data
|
|||||||
{
|
{
|
||||||
i2p::tunnel::OutboundTunnel * outbound = dest->GetLastOutboundTunnel ();
|
i2p::tunnel::OutboundTunnel * outbound = dest->GetLastOutboundTunnel ();
|
||||||
const i2p::tunnel::InboundTunnel * inbound = dest->GetLastReplyTunnel ();
|
const i2p::tunnel::InboundTunnel * inbound = dest->GetLastReplyTunnel ();
|
||||||
|
std::vector<i2p::tunnel::TunnelMessageBlock> msgs;
|
||||||
|
|
||||||
for (int i = 0; i < num; i++)
|
for (int i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
uint8_t * router = buf + 33 + i*32;
|
uint8_t * router = buf + 33 + i*32;
|
||||||
@ -332,7 +334,11 @@ namespace data
|
|||||||
RequestedDestination * d1 = CreateRequestedDestination (router, false, false);
|
RequestedDestination * d1 = CreateRequestedDestination (router, false, false);
|
||||||
d1->SetLastOutboundTunnel (outbound);
|
d1->SetLastOutboundTunnel (outbound);
|
||||||
auto msg = d1->CreateRequestMessage (dest->GetLastRouter (), dest->GetLastReplyTunnel ());
|
auto msg = d1->CreateRequestMessage (dest->GetLastRouter (), dest->GetLastReplyTunnel ());
|
||||||
outbound->GetTunnelGateway ().PutTunnelDataMsg (dest->GetLastRouter ()->GetIdentHash (), 0, msg);
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock
|
||||||
|
{
|
||||||
|
i2p::tunnel::eDeliveryTypeRouter,
|
||||||
|
dest->GetLastRouter ()->GetIdentHash (), 0, msg
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -351,7 +357,11 @@ namespace data
|
|||||||
{
|
{
|
||||||
// request destination
|
// request destination
|
||||||
auto msg = dest->CreateRequestMessage (r, dest->GetLastReplyTunnel ());
|
auto msg = dest->CreateRequestMessage (r, dest->GetLastReplyTunnel ());
|
||||||
outbound->GetTunnelGateway ().PutTunnelDataMsg (r->GetIdentHash (), 0, msg);
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock
|
||||||
|
{
|
||||||
|
i2p::tunnel::eDeliveryTypeRouter,
|
||||||
|
r->GetIdentHash (), 0, msg
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -361,15 +371,18 @@ namespace data
|
|||||||
RequestedDestination * d2 = CreateRequestedDestination (router, false, false);
|
RequestedDestination * d2 = CreateRequestedDestination (router, false, false);
|
||||||
d2->SetLastOutboundTunnel (outbound);
|
d2->SetLastOutboundTunnel (outbound);
|
||||||
I2NPMessage * msg = d2->CreateRequestMessage (dest->GetLastRouter (), inbound);
|
I2NPMessage * msg = d2->CreateRequestMessage (dest->GetLastRouter (), inbound);
|
||||||
outbound->GetTunnelGateway ().PutTunnelDataMsg (
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock
|
||||||
dest->GetLastRouter ()->GetIdentHash (), 0, msg);
|
{
|
||||||
|
i2p::tunnel::eDeliveryTypeRouter,
|
||||||
|
dest->GetLastRouter ()->GetIdentHash (), 0, msg
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outbound)
|
if (msgs.size () > 0)
|
||||||
outbound->GetTunnelGateway ().SendBuffer ();
|
outbound->SendTunnelDataMsg (msgs);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -398,12 +411,21 @@ namespace data
|
|||||||
rnd.GenerateBlock (randomHash, 32);
|
rnd.GenerateBlock (randomHash, 32);
|
||||||
RequestedDestination * dest = CreateRequestedDestination (IdentHash (randomHash), false, true);
|
RequestedDestination * dest = CreateRequestedDestination (IdentHash (randomHash), false, true);
|
||||||
dest->SetLastOutboundTunnel (outbound);
|
dest->SetLastOutboundTunnel (outbound);
|
||||||
|
|
||||||
outbound->GetTunnelGateway ().PutTunnelDataMsg (floodfill->GetIdentHash (), 0,
|
std::vector<i2p::tunnel::TunnelMessageBlock> msgs;
|
||||||
CreateDatabaseStoreMsg ()); // tell floodfill about us
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock
|
||||||
outbound->GetTunnelGateway ().PutTunnelDataMsg (floodfill->GetIdentHash (), 0,
|
{
|
||||||
dest->CreateRequestMessage (floodfill, inbound)); // explore
|
i2p::tunnel::eDeliveryTypeRouter,
|
||||||
outbound->GetTunnelGateway ().SendBuffer ();
|
floodfill->GetIdentHash (), 0,
|
||||||
|
CreateDatabaseStoreMsg () // tell floodfill about us
|
||||||
|
});
|
||||||
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock
|
||||||
|
{
|
||||||
|
i2p::tunnel::eDeliveryTypeRouter,
|
||||||
|
floodfill->GetIdentHash (), 0,
|
||||||
|
dest->CreateRequestMessage (floodfill, inbound) // explore
|
||||||
|
});
|
||||||
|
outbound->SendTunnelDataMsg (msgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
Tunnel.h
1
Tunnel.h
@ -68,7 +68,6 @@ namespace tunnel
|
|||||||
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
|
void SendTunnelDataMsg (std::vector<TunnelMessageBlock> msgs); // multiple messages
|
||||||
|
|
||||||
TunnelGateway& GetTunnelGateway () { return m_Gateway; };
|
|
||||||
size_t GetNumSentBytes () const { return m_Gateway.GetNumSentBytes (); };
|
size_t GetNumSentBytes () const { return m_Gateway.GetNumSentBytes (); };
|
||||||
|
|
||||||
// implements TunnelBase
|
// implements TunnelBase
|
||||||
|
@ -23,8 +23,8 @@ namespace tunnel
|
|||||||
struct TunnelMessageBlock
|
struct TunnelMessageBlock
|
||||||
{
|
{
|
||||||
TunnelDeliveryType deliveryType;
|
TunnelDeliveryType deliveryType;
|
||||||
uint32_t tunnelID;
|
|
||||||
i2p::data::IdentHash hash;
|
i2p::data::IdentHash hash;
|
||||||
|
uint32_t tunnelID;
|
||||||
I2NPMessage * data;
|
I2NPMessage * data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user