2021-03-09 22:24:35 +00:00
|
|
|
#pragma once
|
2019-04-21 16:44:27 +00:00
|
|
|
|
2023-08-31 16:28:02 +00:00
|
|
|
#include <llarp/routing/path_dht_message.hpp>
|
2021-03-09 22:24:35 +00:00
|
|
|
#include "intro_set.hpp"
|
|
|
|
#include "lookup.hpp"
|
2019-04-21 16:44:27 +00:00
|
|
|
|
2023-08-31 16:28:02 +00:00
|
|
|
namespace llarp::service
|
2019-04-21 16:44:27 +00:00
|
|
|
{
|
2023-08-31 16:28:02 +00:00
|
|
|
/// interval for which we will add to lookup timeout interval
|
|
|
|
constexpr auto IntrosetLookupGraceInterval = 20s;
|
2021-06-17 12:08:46 +00:00
|
|
|
|
2023-08-31 16:28:02 +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
|
2019-04-21 16:44:27 +00:00
|
|
|
{
|
2023-08-31 16:28:02 +00:00
|
|
|
if (const auto* ptr = std::get_if<Address>(&addr))
|
2021-06-03 15:40:01 +00:00
|
|
|
{
|
2023-08-31 16:28:02 +00:00
|
|
|
return Address{rootkey} == *ptr;
|
2021-06-03 15:40:01 +00:00
|
|
|
}
|
2023-08-31 16:28:02 +00:00
|
|
|
return false;
|
|
|
|
}
|
2021-06-03 15:40:01 +00:00
|
|
|
|
2023-08-31 16:28:02 +00:00
|
|
|
bool
|
|
|
|
HandleIntrosetResponse(const std::set<EncryptedIntroSet>& results) override;
|
2019-04-21 16:44:27 +00:00
|
|
|
|
2023-08-31 16:28:02 +00:00
|
|
|
std::shared_ptr<routing::AbstractRoutingMessage>
|
|
|
|
BuildRequestMessage() override;
|
|
|
|
};
|
|
|
|
} // namespace llarp::service
|