lokinet/llarp/service/hidden_service_address_lookup.hpp

51 lines
1.3 KiB
C++
Raw Normal View History

#pragma once
#include <llarp/routing/path_dht_message.hpp>
#include "intro_set.hpp"
#include "lookup.hpp"
namespace llarp::service
{
/// interval for which we will add to lookup timeout interval
constexpr auto IntrosetLookupGraceInterval = 20s;
2021-06-17 12:08:46 +00:00
struct Endpoint;
struct HiddenServiceAddressLookup : public IServiceLookup
{
const PubKey rootkey;
uint64_t relayOrder;
const dht::Key_t location;
using HandlerFunc = std::function<bool(
const Address&, std::optional<IntroSet>, const RouterID&, llarp_time_t, uint64_t)>;
HandlerFunc handle;
HiddenServiceAddressLookup(
Endpoint* p,
HandlerFunc h,
const dht::Key_t& location,
const PubKey& rootkey,
const RouterID& routerAsked,
uint64_t relayOrder,
uint64_t tx,
llarp_time_t timeout);
~HiddenServiceAddressLookup() override = default;
bool
IsFor(EndpointBase::AddressVariant_t addr) const override
{
if (const auto* ptr = std::get_if<Address>(&addr))
{
return Address{rootkey} == *ptr;
}
return false;
}
bool
HandleIntrosetResponse(const std::set<EncryptedIntroSet>& results) override;
std::shared_ptr<routing::AbstractRoutingMessage>
BuildRequestMessage() override;
};
} // namespace llarp::service