---
title: llarp/dns/name.hpp

---

# llarp/dns/name.hpp



## Namespaces

| Name           |
| -------------- |
| **[llarp](Namespaces/namespacellarp.md)** <br>[crypto.hpp] |
| **[llarp::dns](Namespaces/namespacellarp_1_1dns.md)**  |




## Source code

```cpp
#pragma once

#include <algorithm>
#include <llarp/net/net_int.hpp>
#include <llarp/util/str.hpp>

#include <string>
#include <optional>
#include <string_view>
#include <vector>
#include <array>

namespace llarp::dns
{

  constexpr auto max_dns_label_size = 63;

  inline bool
  is_lokinet_tld(std::string_view str)
  {
    constexpr std::array lokinet_tlds = {"loki"sv, "snode"sv};
    for (const auto& tld : lokinet_tlds)
    {
      if (string_iequal(tld, str))
        return true;
    }
    return false;
  }

  std::optional<huint128_t>
  DecodePTR(std::string_view name);

  bool
  NameIsReserved(std::string_view name);

  bstring_t
  encode_dns_labels(std::vector<std::string_view> labels);

  bstring_t
  encode_dns_labels(std::vector<std::string> labels);

  bstring_t
  encode_dns_name(std::string_view name);

  std::vector<std::string>
  decode_dns_labels(byte_view_t& buf);

  std::vector<std::string_view>
  decode_dns_label_views(byte_view_t& buf);

  template <typename T>
  auto
  split_dns_name(const T& name)
  {
    return split(name, ".");
  }

}  // namespace llarp::dns
```


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

Updated on 2023-04-27 at 04:17:17 +0000
