initial implementation of find intro message for hidden service dht (not done yet)

pull/6/head^2
Jeff Becker 6 years ago
parent c992720718
commit bce3cd85c6

@ -54,6 +54,9 @@ namespace llarp
void
Init(const Key_t& us, llarp_router* router);
const llarp::service::IntroSet*
GetIntroSetByServiceAddress(const llarp::service::Address& addr) const;
void
QueueRouterLookup(llarp_router_lookup_job* job);

@ -14,7 +14,11 @@ namespace llarp
llarp::service::Address S;
uint64_t T = 0;
~FindIntroMessage();
FindIntroMessage(const Key_t& from) : IMessage(from)
{
}
virtual ~FindIntroMessage();
bool
BEncode(llarp_buffer_t* buf) const;
@ -26,6 +30,16 @@ namespace llarp
HandleMessage(llarp_dht_context* ctx,
std::vector< IMessage* >& replies) const;
};
struct RelayedFindIntroMessage : public FindIntroMessage
{
RelayedFindIntroMessage();
~RelayedFindIntroMessage();
bool
HandleMessage(llarp_dht_context* ctx,
std::vector< IMessage* >& replies) const;
};
} // namespace dht
} // namespace llarp
#endif

@ -90,6 +90,16 @@ namespace llarp
}
}
const llarp::service::IntroSet *
Context::GetIntroSetByServiceAddress(
const llarp::service::Address &addr) const
{
auto itr = services->nodes.find(addr.data());
if(itr == services->nodes.end())
return nullptr;
return &itr->second.introset;
}
void
Context::RemovePendingLookup(const Key_t &owner, uint64_t id)
{

@ -37,6 +37,8 @@ namespace llarp
return false;
switch(*strbuf.base)
{
case 'F':
dec->msg = new FindIntroMessage(dec->From);
case 'R':
if(dec->relayed)
dec->msg = new RelayedFindRouterMessage(dec->From);

@ -1,4 +1,6 @@
#include <llarp/dht/context.hpp>
#include <llarp/dht/messages/findintro.hpp>
#include <llarp/dht/messages/gotintro.hpp>
namespace llarp
{
@ -7,5 +9,39 @@ namespace llarp
FindIntroMessage::~FindIntroMessage()
{
}
bool
FindIntroMessage::DecodeKey(llarp_buffer_t k, llarp_buffer_t* val)
{
// TODO: implement me
return false;
}
bool
FindIntroMessage::BEncode(llarp_buffer_t* buf) const
{
/// TODO: implement me
return false;
}
bool
FindIntroMessage::HandleMessage(
llarp_dht_context* ctx,
std::vector< llarp::dht::IMessage* >& replies) const
{
auto& dht = ctx->impl;
auto introset = dht.GetIntroSetByServiceAddress(S);
if(introset)
{
replies.push_back(new GotIntroMessage(T, introset));
return true;
}
else
{
// do lookup
}
return false;
}
} // namespace dht
} // namespace llarp
Loading…
Cancel
Save