#include #include #include #include namespace llarp { namespace service { HiddenServiceAddressLookup::HiddenServiceAddressLookup( Endpoint* p, HandlerFunc h, const dht::Key_t& l, const PubKey& k, uint64_t order, uint64_t tx) : IServiceLookup(p, tx, "HSLookup") , rootkey(k) , relayOrder(order) , location(l) , handle(std::move(h)) {} bool HiddenServiceAddressLookup::HandleIntrosetResponse(const std::set& results) { std::optional found; const Address remote(rootkey); if (results.size() > 0) { EncryptedIntroSet selected; for (const auto& introset : results) { if (selected.OtherIsNewer(introset)) selected = introset; } const auto maybe = selected.MaybeDecrypt(rootkey); if (maybe) { LogInfo("found result for ", remote.ToString()); found = *maybe; } } return handle(remote, found, endpoint); } std::shared_ptr HiddenServiceAddressLookup::BuildRequestMessage() { auto msg = std::make_shared(); msg->M.emplace_back(std::make_unique(txid, location, relayOrder)); return msg; } } // namespace service } // namespace llarp