---
title: llarp/layers/platform/name_resolver.hpp

---

# llarp/layers/platform/name_resolver.hpp



## Namespaces

| Name           |
| -------------- |
| **[llarp](Namespaces/namespacellarp.md)** <br>[crypto.hpp] |
| **[llarp::layers](Namespaces/namespacellarp_1_1layers.md)**  |
| **[llarp::layers::platform](Namespaces/namespacellarp_1_1layers_1_1platform.md)**  |

## Classes

|                | Name           |
| -------------- | -------------- |
| struct | **[llarp::layers::platform::ResolvedName](Classes/structllarp_1_1layers_1_1platform_1_1ResolvedName.md)** <br>a .loki / .snode name we resolved to a FlowAddr  |
| class | **[llarp::layers::platform::NameResolverJob_Base](Classes/classllarp_1_1layers_1_1platform_1_1NameResolverJob__Base.md)** <br>a one shot job that will resolve a string to a resolved name which we can use to establish a flow to  |




## Source code

```cpp
#pragma once

#include <chrono>
#include <optional>
#include <variant>
#include <llarp/layers/platform/driver_base.hpp>
#include <llarp/util/types.hpp>
#include <llarp/layers/flow/flow_addr.hpp>
#include "llarp/dns/question.hpp"
#include "llarp/dns/rr.hpp"

namespace llarp::layers::platform
{

  using UnresolvedName_t = std::variant<std::string_view, dns::Question>;

  struct ResolvedName
  {
    flow::FlowAddr resolved;
    // todo: if we have any more info we need to add here we should add it otherwise we can get rid
    // of this type
  };

  class NameResolverJob_Base
  {
   protected:
    const TimePoint_t started_at{TimePoint_t::clock::now()};
    const std::string name;
    const Duration_t timeout;

   public:
    template <typename resolution_t, typename rep_t = double>
    NameResolverJob_Base(
        std::string_view name_, std::chrono::duration<rep_t, resolution_t> timeout_)
        : name{name_}, timeout{timeout_} {};

    // handler is passed in here because putting it in the constructor tends to get very messy.
    virtual void
    resolve_async(std::function<void(std::optional<ResolvedName>)> handler);
  };

}  // namespace llarp::layers::platform
```


-------------------------------

Updated on 2023-01-23 at 14:22:33 +0000
