mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-17 15:25:35 +00:00
273270916e
This commit reflects changes to clang-format rules. Unfortunately, these rule changes create a massive change to the codebase, which causes an apparent rewrite of git history. Git blame's --ignore-rev flag can be used to ignore this commit when attempting to `git blame` some code.
62 lines
1.3 KiB
C++
62 lines
1.3 KiB
C++
#ifndef LLARP_DNS_QUESTION_HPP
|
|
#define LLARP_DNS_QUESTION_HPP
|
|
|
|
#include <dns/serialize.hpp>
|
|
#include <dns/name.hpp>
|
|
#include <net/net_int.hpp>
|
|
|
|
namespace llarp
|
|
{
|
|
namespace dns
|
|
{
|
|
using QType_t = uint16_t;
|
|
using QClass_t = uint16_t;
|
|
|
|
struct Question : public Serialize
|
|
{
|
|
Question() = default;
|
|
Question(Question&& other);
|
|
Question(const Question& other);
|
|
bool
|
|
Encode(llarp_buffer_t* buf) const override;
|
|
|
|
bool
|
|
Decode(llarp_buffer_t* buf) override;
|
|
|
|
std::ostream&
|
|
print(std::ostream& stream, int level, int spaces) const;
|
|
|
|
bool
|
|
operator==(const Question& other) const
|
|
{
|
|
return qname == other.qname && qtype == other.qtype && qclass == other.qclass;
|
|
}
|
|
|
|
Name_t qname;
|
|
QType_t qtype;
|
|
QClass_t qclass;
|
|
|
|
/// determine if we match a name
|
|
bool
|
|
IsName(const std::string& other) const;
|
|
|
|
/// return qname with no trailing .
|
|
std::string
|
|
Name() const;
|
|
|
|
/// determine if we are using this TLD
|
|
bool
|
|
HasTLD(const std::string& tld) const;
|
|
};
|
|
|
|
inline std::ostream&
|
|
operator<<(std::ostream& out, const Question& q)
|
|
{
|
|
q.print(out, -1, -1);
|
|
return out;
|
|
}
|
|
} // namespace dns
|
|
} // namespace llarp
|
|
|
|
#endif
|