Browse Source

wrap LeaseSet lookups into garlic

pull/8/head
orignal 11 years ago
parent
commit
4f9a977022
  1. 2
      Garlic.cpp
  2. 26
      NetDb.cpp
  3. 6
      NetDb.h

2
Garlic.cpp

@ -109,7 +109,7 @@ namespace garlic
} }
if (msg) // next clove message ifself if presented if (msg) // next clove message ifself if presented
{ {
size += CreateGarlicClove (payload + size, msg, true); size += CreateGarlicClove (payload + size, msg, m_Destination->IsDestination ());
(*numCloves)++; (*numCloves)++;
} }

26
NetDb.cpp

@ -8,6 +8,7 @@
#include "I2NPProtocol.h" #include "I2NPProtocol.h"
#include "Tunnel.h" #include "Tunnel.h"
#include "RouterContext.h" #include "RouterContext.h"
#include "Garlic.h"
#include "NetDb.h" #include "NetDb.h"
namespace i2p namespace i2p
@ -197,15 +198,25 @@ namespace data
LogPrint (deletedCount," routers deleted"); LogPrint (deletedCount," routers deleted");
} }
void NetDb::RequestDestination (const char * b32, const uint8_t * router) void NetDb::RequestDestination (const char * b32)
{ {
uint8_t destination[32]; uint8_t destination[32];
Base32ToByteStream (b32, strlen(b32), destination, 32); Base32ToByteStream (b32, strlen(b32), destination, 32);
RequestDestination (destination, router); RequestDestination (destination, true);
}
void NetDb::RequestDestination (const IdentHash& destination, bool isLeaseSet)
{
auto floodfill= GetRandomNTCPRouter (true);
if (floodfill)
RequestDestination (destination, floodfill, isLeaseSet);
else
LogPrint ("No floodfill routers found");
} }
void NetDb::RequestDestination (const uint8_t * destination, const uint8_t * router) void NetDb::RequestDestination (const IdentHash& destination, const RouterInfo * floodfill, bool isLeaseSet)
{ {
if (!floodfill) return;
i2p::tunnel::OutboundTunnel * outbound = i2p::tunnel::tunnels.GetNextOutboundTunnel (); i2p::tunnel::OutboundTunnel * outbound = i2p::tunnel::tunnels.GetNextOutboundTunnel ();
if (outbound) if (outbound)
{ {
@ -214,7 +225,9 @@ namespace data
{ {
I2NPMessage * msg = i2p::CreateDatabaseLookupMsg (destination, inbound->GetNextIdentHash (), I2NPMessage * msg = i2p::CreateDatabaseLookupMsg (destination, inbound->GetNextIdentHash (),
inbound->GetNextTunnelID ()); inbound->GetNextTunnelID ());
outbound->SendTunnelDataMsg (router, 0, msg); if (isLeaseSet) // wrap lookup message into garlic
msg = i2p::garlic::routing.WrapSingleMessage (floodfill, msg);
outbound->SendTunnelDataMsg (floodfill->GetIdentHash (), 0, msg);
} }
else else
LogPrint ("No inbound tunnels found"); LogPrint ("No inbound tunnels found");
@ -222,11 +235,6 @@ namespace data
else else
LogPrint ("No outbound tunnels found"); LogPrint ("No outbound tunnels found");
} }
void NetDb::RequestDestination (const IdentHash& destination)
{
RequestDestination ((const uint8_t *)destination, GetRandomNTCPRouter (true)->GetIdentHash ());
}
void NetDb::HandleDatabaseStoreMsg (uint8_t * buf, size_t len) void NetDb::HandleDatabaseStoreMsg (uint8_t * buf, size_t len)
{ {

6
NetDb.h

@ -30,9 +30,9 @@ namespace data
RouterInfo * FindRouter (const IdentHash& ident) const; RouterInfo * FindRouter (const IdentHash& ident) const;
LeaseSet * FindLeaseSet (const IdentHash& destination) const; LeaseSet * FindLeaseSet (const IdentHash& destination) const;
void RequestDestination (const char * b32, const uint8_t * router); // in base32 void RequestDestination (const char * b32); // in base32
void RequestDestination (const uint8_t * destination, const uint8_t * router); void RequestDestination (const IdentHash& destination, bool isLeaseSet = false);
void RequestDestination (const IdentHash& destination); void RequestDestination (const IdentHash& destination, const RouterInfo * floodfill, bool isLeaseSet = false);
void HandleDatabaseStoreMsg (uint8_t * buf, size_t len); void HandleDatabaseStoreMsg (uint8_t * buf, size_t len);
void HandleDatabaseSearchReplyMsg (I2NPMessage * msg); void HandleDatabaseSearchReplyMsg (I2NPMessage * msg);

Loading…
Cancel
Save