Browse Source

send multiple messages

pull/11/merge
orignal 11 years ago
parent
commit
0b079f4723
  1. 44
      NetDb.cpp
  2. 1
      Tunnel.h
  3. 2
      TunnelBase.h

44
NetDb.cpp

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#include "I2PEndian.h"
#include <fstream>
#include <vector>
#include <boost/filesystem.hpp>
#include <cryptopp/gzip.h>
#include "base64.h"
@ -313,6 +314,7 @@ namespace data @@ -313,6 +314,7 @@ namespace data
{
i2p::tunnel::OutboundTunnel * outbound = dest->GetLastOutboundTunnel ();
const i2p::tunnel::InboundTunnel * inbound = dest->GetLastReplyTunnel ();
std::vector<i2p::tunnel::TunnelMessageBlock> msgs;
for (int i = 0; i < num; i++)
{
@ -332,7 +334,11 @@ namespace data @@ -332,7 +334,11 @@ namespace data
RequestedDestination * d1 = CreateRequestedDestination (router, false, false);
d1->SetLastOutboundTunnel (outbound);
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
@ -351,7 +357,11 @@ namespace data @@ -351,7 +357,11 @@ namespace data
{
// request destination
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
@ -361,15 +371,18 @@ namespace data @@ -361,15 +371,18 @@ namespace data
RequestedDestination * d2 = CreateRequestedDestination (router, false, false);
d2->SetLastOutboundTunnel (outbound);
I2NPMessage * msg = d2->CreateRequestMessage (dest->GetLastRouter (), inbound);
outbound->GetTunnelGateway ().PutTunnelDataMsg (
dest->GetLastRouter ()->GetIdentHash (), 0, msg);
msgs.push_back (i2p::tunnel::TunnelMessageBlock
{
i2p::tunnel::eDeliveryTypeRouter,
dest->GetLastRouter ()->GetIdentHash (), 0, msg
});
}
}
}
}
if (outbound)
outbound->GetTunnelGateway ().SendBuffer ();
if (msgs.size () > 0)
outbound->SendTunnelDataMsg (msgs);
}
else
{
@ -399,11 +412,20 @@ namespace data @@ -399,11 +412,20 @@ namespace data
RequestedDestination * dest = CreateRequestedDestination (IdentHash (randomHash), false, true);
dest->SetLastOutboundTunnel (outbound);
outbound->GetTunnelGateway ().PutTunnelDataMsg (floodfill->GetIdentHash (), 0,
CreateDatabaseStoreMsg ()); // tell floodfill about us
outbound->GetTunnelGateway ().PutTunnelDataMsg (floodfill->GetIdentHash (), 0,
dest->CreateRequestMessage (floodfill, inbound)); // explore
outbound->GetTunnelGateway ().SendBuffer ();
std::vector<i2p::tunnel::TunnelMessageBlock> msgs;
msgs.push_back (i2p::tunnel::TunnelMessageBlock
{
i2p::tunnel::eDeliveryTypeRouter,
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

@ -68,7 +68,6 @@ namespace tunnel @@ -68,7 +68,6 @@ namespace tunnel
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; };
size_t GetNumSentBytes () const { return m_Gateway.GetNumSentBytes (); };
// implements TunnelBase

2
TunnelBase.h

@ -23,8 +23,8 @@ namespace tunnel @@ -23,8 +23,8 @@ namespace tunnel
struct TunnelMessageBlock
{
TunnelDeliveryType deliveryType;
uint32_t tunnelID;
i2p::data::IdentHash hash;
uint32_t tunnelID;
I2NPMessage * data;
};

Loading…
Cancel
Save