mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
initial implementation of find intro message for hidden service dht (not done yet)
This commit is contained in:
parent
c992720718
commit
bce3cd85c6
|
@ -54,6 +54,9 @@ namespace llarp
|
||||||
void
|
void
|
||||||
Init(const Key_t& us, llarp_router* router);
|
Init(const Key_t& us, llarp_router* router);
|
||||||
|
|
||||||
|
const llarp::service::IntroSet*
|
||||||
|
GetIntroSetByServiceAddress(const llarp::service::Address& addr) const;
|
||||||
|
|
||||||
void
|
void
|
||||||
QueueRouterLookup(llarp_router_lookup_job* job);
|
QueueRouterLookup(llarp_router_lookup_job* job);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,11 @@ namespace llarp
|
||||||
llarp::service::Address S;
|
llarp::service::Address S;
|
||||||
uint64_t T = 0;
|
uint64_t T = 0;
|
||||||
|
|
||||||
~FindIntroMessage();
|
FindIntroMessage(const Key_t& from) : IMessage(from)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~FindIntroMessage();
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BEncode(llarp_buffer_t* buf) const;
|
BEncode(llarp_buffer_t* buf) const;
|
||||||
|
@ -26,6 +30,16 @@ namespace llarp
|
||||||
HandleMessage(llarp_dht_context* ctx,
|
HandleMessage(llarp_dht_context* ctx,
|
||||||
std::vector< IMessage* >& replies) const;
|
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 dht
|
||||||
} // namespace llarp
|
} // namespace llarp
|
||||||
#endif
|
#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
|
void
|
||||||
Context::RemovePendingLookup(const Key_t &owner, uint64_t id)
|
Context::RemovePendingLookup(const Key_t &owner, uint64_t id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,6 +37,8 @@ namespace llarp
|
||||||
return false;
|
return false;
|
||||||
switch(*strbuf.base)
|
switch(*strbuf.base)
|
||||||
{
|
{
|
||||||
|
case 'F':
|
||||||
|
dec->msg = new FindIntroMessage(dec->From);
|
||||||
case 'R':
|
case 'R':
|
||||||
if(dec->relayed)
|
if(dec->relayed)
|
||||||
dec->msg = new RelayedFindRouterMessage(dec->From);
|
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/findintro.hpp>
|
||||||
|
#include <llarp/dht/messages/gotintro.hpp>
|
||||||
|
|
||||||
namespace llarp
|
namespace llarp
|
||||||
{
|
{
|
||||||
|
@ -7,5 +9,39 @@ namespace llarp
|
||||||
FindIntroMessage::~FindIntroMessage()
|
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 dht
|
||||||
} // namespace llarp
|
} // namespace llarp
|
Loading…
Reference in a new issue