---
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 "serialize.hpp"
#include "name.hpp"
#include <llarp/net/net_int.hpp>

namespace llarp
{
  namespace dns
  {
    using QType_t = uint16_t;
    using QClass_t = uint16_t;

    struct Question : public Serialize
    {
      Question() = default;

      explicit Question(std::string name, QType_t type);

      Question(Question&& other);
      Question(const Question& other);
      bool
      Encode(llarp_buffer_t* buf) const override;

      bool
      Decode(llarp_buffer_t* buf) override;

      std::string
      ToString() const;

      bool
      operator==(const Question& other) const
      {
        return qname == other.qname && qtype == other.qtype && qclass == other.qclass;
      }

      std::string qname;
      QType_t qtype;
      QClass_t qclass;

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

      bool
      IsLocalhost() const;

      bool
      HasSubdomains() const;

      std::string
      Subdomains() const;

      std::string
      Name() const;

      bool
      HasTLD(const std::string& tld) const;

      util::StatusObject
      ToJSON() const override;
    };
  }  // namespace dns
}  // namespace llarp

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


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

Updated on 2023-03-26 at 04:03:14 +0000
