2021-03-09 22:24:35 +00:00
|
|
|
#pragma once
|
2019-04-21 16:44:27 +00:00
|
|
|
|
2021-03-09 22:24:35 +00:00
|
|
|
#include <llarp/routing/dht_message.hpp>
|
|
|
|
#include "intro_set.hpp"
|
|
|
|
#include "lookup.hpp"
|
2019-04-21 16:44:27 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace service
|
|
|
|
{
|
2021-06-17 12:08:46 +00:00
|
|
|
/// interval for which we will add to lookup timeout interval
|
|
|
|
constexpr auto IntrosetLookupGraceInterval = 20s;
|
|
|
|
|
2019-04-21 16:44:27 +00:00
|
|
|
struct Endpoint;
|
|
|
|
struct HiddenServiceAddressLookup : public IServiceLookup
|
|
|
|
{
|
2020-01-27 21:30:41 +00:00
|
|
|
const PubKey rootkey;
|
2020-02-14 18:06:19 +00:00
|
|
|
uint64_t relayOrder;
|
2020-01-27 21:30:41 +00:00
|
|
|
const dht::Key_t location;
|
2021-03-27 18:54:09 +00:00
|
|
|
using HandlerFunc = std::function<bool(
|
2021-06-02 19:50:14 +00:00
|
|
|
const Address&, std::optional<IntroSet>, const RouterID&, llarp_time_t, uint64_t)>;
|
2019-04-21 16:44:27 +00:00
|
|
|
HandlerFunc handle;
|
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
HiddenServiceAddressLookup(
|
|
|
|
Endpoint* p,
|
|
|
|
HandlerFunc h,
|
|
|
|
const dht::Key_t& location,
|
|
|
|
const PubKey& rootkey,
|
2021-05-01 12:59:56 +00:00
|
|
|
const RouterID& routerAsked,
|
2020-04-07 18:38:56 +00:00
|
|
|
uint64_t relayOrder,
|
2021-03-27 18:54:09 +00:00
|
|
|
uint64_t tx,
|
|
|
|
llarp_time_t timeout);
|
2019-04-21 16:44:27 +00:00
|
|
|
|
2019-07-30 23:42:13 +00:00
|
|
|
~HiddenServiceAddressLookup() override = default;
|
2019-04-21 16:44:27 +00:00
|
|
|
|
2021-06-03 15:40:01 +00:00
|
|
|
virtual bool
|
|
|
|
IsFor(EndpointBase::AddressVariant_t addr) const override
|
|
|
|
{
|
|
|
|
if (const auto* ptr = std::get_if<Address>(&addr))
|
|
|
|
{
|
|
|
|
return Address{rootkey} == *ptr;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-04-21 16:44:27 +00:00
|
|
|
bool
|
2020-09-17 19:18:08 +00:00
|
|
|
HandleIntrosetResponse(const std::set<EncryptedIntroSet>& results) override;
|
2019-04-21 16:44:27 +00:00
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
std::shared_ptr<routing::IMessage>
|
2019-07-30 23:42:13 +00:00
|
|
|
BuildRequestMessage() override;
|
2019-04-21 16:44:27 +00:00
|
|
|
};
|
|
|
|
} // namespace service
|
|
|
|
} // namespace llarp
|