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

---

# llarp/dns/question.hpp



## Namespaces

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

## Classes

|                | Name           |
| -------------- | -------------- |
| struct | **[llarp::dns::Question](Classes/structllarp_1_1dns_1_1Question.md)**  |




## Source code

```cpp
#pragma once

#include "name.hpp"
#include "rr.hpp"

#include <cstdint>
#include <llarp/net/net_int.hpp>
#include <string_view>
#include <vector>

#include <llarp/util/status.hpp>
#include <llarp/util/str.hpp>

namespace llarp::dns
{

  struct Question
  {
    Question() = default;
    Question(const Question&) = default;
    Question(Question&&) = default;

    Question&
    operator=(const Question&) = default;
    Question&
    operator=(Question&&) = default;

    explicit Question(byte_view_t& raw);

    Question(std::string name, RRType type) : Question{split_dns_name(name), type}
    {}

    Question(std::vector<std::string_view> labels, RRType type);

    bstring_t
    encode_dns() const;

    std::string
    ToString() const;

    uint16_t qtype;
    uint16_t qclass;

    std::string
    qname() const;

    bool
    IsName(const std::string& other) const;

    bool
    IsLocalhost() const;

    bool
    HasSubdomains() const;

    std::string
    Subdomains() const;

    std::string
    Domain() const;

    std::string_view
    tld() const;

    inline bool
    HasTLD(std::string_view _tld) const [[deprecated]]
    {
      return tld() == _tld;
    }

    util::StatusObject
    to_json() const;

    bool
    valid() const;

    std::vector<std::string_view>
    view_dns_labels() const;

   private:
    std::vector<std::string> _qname_labels;
  };
}  // namespace llarp::dns

namespace llarp
{
  template <>
  constexpr inline bool IsToStringFormattable<dns::Question> = true;
}
```


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

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