1#ifndef NEFORCE_NETWORK_DNS_DNS_MESSAGE_HPP__
2#define NEFORCE_NETWORK_DNS_DNS_MESSAGE_HPP__
23NEFORCE_BEGIN_NAMESPACE__
225class dns_exception final :
public network_exception {
244 network_exception(
what.
data(), static_type, static_cast<int>(
code)) {}
259 return {
"Network error: " + detail,
code};
269 static constexpr auto static_type =
"dns_exception";
406struct dns_srv_record {
412 dns_srv_record() =
default;
426struct dns_soa_record {
440NEFORCE_END_NAMESPACE__
static dns_exception network_error(const string &detail, const code code=code::NETWORK_ERROR)
创建网络错误异常
static dns_exception parse_error(const string &detail)
创建解析错误异常
static dns_exception timeout()
创建超时异常
unsigned char uint8_t
8位无符号整数类型
unsigned int uint32_t
32位无符号整数类型
unsigned short uint16_t
16位无符号整数类型
@ NOT_IMPLEMENTED
未实现,服务器不支持该查询类型
@ FORMAT_ERROR
格式错误,服务器无法解析查询
@ SERVER_FAILURE
服务器失败,无法处理查询
duration< int64_t, milli > milliseconds
毫秒持续时间
duration< int64_t > seconds
秒持续时间
constexpr Iterator2 move(Iterator1 first, Iterator1 last, Iterator2 result) noexcept(noexcept(inner::__move_aux(first, last, result)))
移动范围元素
constexpr decltype(auto) data(Container &cont) noexcept(noexcept(cont.data()))
获取容器的底层数据指针
constexpr uint8_t VERSION
EDNS版本号
constexpr uint16_t DO_BIT
DNSSEC OK标志位
constexpr uint8_t MAX_UDP_RETRIES
UDP最大重试次数
constexpr uint16_t OPT_TYPE
OPT伪资源记录类型
constexpr uint8_t EXT_RCODE_SHIFT
扩展RCODE在TTL字段中的偏移
constexpr uint16_t MAX_UDP_PAYLOAD
最大UDP载荷大小
constexpr uint8_t VERSION_SHIFT
EDNS版本在TTL字段中的偏移
constexpr seconds NEGATIVE_CACHE_TTL
否定缓存TTL(RFC 2308)
constexpr uint16_t DEFAULT_UDP_PAYLOAD
默认UDP载荷大小(RFC 6891 建议值)
bool dnssec_ok
服务器支持DNSSEC(DO标志位)
milliseconds query_time
查询耗时
uint16_t udp_payload_size
服务器支持的UDP载荷大小(EDNS0)
vector< dns_record > authorities
权威记录
uint16_t full_rcode() const noexcept
获取完整响应码(含EDNS0扩展位)
uint8_t extended_rcode
扩展响应码(EDNS0,RFC 6891)
bool recursive_available
递归查询是否可用
bool authoritative
权威应答(AA标志位)
vector< dns_record > additional
附加记录
bool is_success() const noexcept
检查查询是否成功
uint8_t edns_version
EDNS版本号
dns_response response_code
响应码
vector< dns_record > answers
答案记录
dns_record(string n, const raw t, const dns_class c, const uint32_t ttl_val, string d) noexcept
构造函数
dns_record()=default
默认构造函数
DNS SOA(Start of Authority)资源记录
uint16_t weight
权重(同优先级下负载均衡)
uint16_t priority
优先级(越低越优先)
const char * what() const noexcept
获取错误信息
static constexpr auto static_type
静态类型字符串