2021-03-09 22:24:35 +00:00
|
|
|
#pragma once
|
2018-12-12 02:52:51 +00:00
|
|
|
|
2021-03-09 22:24:35 +00:00
|
|
|
#include "name.hpp"
|
|
|
|
#include "serialize.hpp"
|
|
|
|
#include <llarp/net/net_int.hpp>
|
2018-12-12 00:58:08 +00:00
|
|
|
|
2018-12-03 22:22:59 +00:00
|
|
|
#include <memory>
|
2018-12-12 00:58:08 +00:00
|
|
|
#include <vector>
|
2018-12-03 22:22:59 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace dns
|
|
|
|
{
|
2020-04-07 18:38:56 +00:00
|
|
|
using RRClass_t = uint16_t;
|
|
|
|
using RRType_t = uint16_t;
|
|
|
|
using RR_RData_t = std::vector<byte_t>;
|
|
|
|
using RR_TTL_t = uint32_t;
|
2018-12-03 22:22:59 +00:00
|
|
|
|
|
|
|
struct ResourceRecord : public Serialize
|
|
|
|
{
|
2018-12-04 16:16:43 +00:00
|
|
|
ResourceRecord() = default;
|
|
|
|
ResourceRecord(const ResourceRecord& other);
|
|
|
|
ResourceRecord(ResourceRecord&& other);
|
|
|
|
|
2022-07-18 20:05:39 +00:00
|
|
|
explicit ResourceRecord(std::string name, RRType_t type, RR_RData_t rdata);
|
2021-07-29 20:40:25 +00:00
|
|
|
|
2018-12-03 22:22:59 +00:00
|
|
|
bool
|
|
|
|
Encode(llarp_buffer_t* buf) const override;
|
|
|
|
|
|
|
|
bool
|
|
|
|
Decode(llarp_buffer_t* buf) override;
|
|
|
|
|
2021-07-29 20:40:25 +00:00
|
|
|
util::StatusObject
|
|
|
|
ToJSON() const override;
|
|
|
|
|
2022-07-16 00:41:14 +00:00
|
|
|
std::string
|
|
|
|
ToString() const;
|
2018-12-04 16:16:43 +00:00
|
|
|
|
2020-02-12 20:43:37 +00:00
|
|
|
bool
|
|
|
|
HasCNameForTLD(const std::string& tld) const;
|
|
|
|
|
2022-07-18 20:05:39 +00:00
|
|
|
std::string rr_name;
|
2018-12-03 22:22:59 +00:00
|
|
|
RRType_t rr_type;
|
|
|
|
RRClass_t rr_class;
|
|
|
|
RR_TTL_t ttl;
|
|
|
|
RR_RData_t rData;
|
|
|
|
};
|
|
|
|
} // namespace dns
|
|
|
|
} // namespace llarp
|
2022-07-16 00:41:14 +00:00
|
|
|
|
|
|
|
template <>
|
|
|
|
constexpr inline bool llarp::IsToStringFormattable<llarp::dns::ResourceRecord> = true;
|