2022-02-20 13:31:32 +00:00
|
|
|
#[allow(dead_code)]
|
2021-10-19 21:18:54 +00:00
|
|
|
pub(crate) const SERVER_NAME_DNS: &str = "_DNS Resolver Middleware_";
|
|
|
|
|
use net::NetIpAddr;
|
|
|
|
|
use rkyv::{Archive, Deserialize, Serialize};
|
|
|
|
|
|
2022-02-20 13:31:32 +00:00
|
|
|
#[allow(dead_code)]
|
2021-10-19 21:18:54 +00:00
|
|
|
pub(crate) const DNS_NAME_LENGTH_LIMIT: usize = 256;
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
|
pub(crate) const DNS_PKT_MAX_LEN: usize = 512;
|
|
|
|
|
|
|
|
|
|
/// These opcodes can be called by anyone at any time
|
|
|
|
|
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
|
|
|
|
pub(crate) enum Opcode {
|
|
|
|
|
Lookup,
|
|
|
|
|
Flush,
|
|
|
|
|
|
2021-10-20 12:06:08 +00:00
|
|
|
/// used internally to update the TTL field, and eventually expire the cache (unless cache is frozen)
|
|
|
|
|
UpdateTtl,
|
|
|
|
|
|
|
|
|
|
/// issuing this opcode causes all future attempts to change the DNS server configs to be ignored. This also freezes the cache.
|
2021-10-19 21:18:54 +00:00
|
|
|
FreezeConfig,
|
|
|
|
|
/// this allows automatic updates to the DNS server configs based on DHCP. This is the default state.
|
|
|
|
|
ThawConfig,
|
|
|
|
|
|
|
|
|
|
Quit,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive, Archive, Serialize, Deserialize, Copy, Clone)]
|
|
|
|
|
#[repr(u16)]
|
|
|
|
|
pub enum DnsResponseCode {
|
|
|
|
|
NoError = 0,
|
|
|
|
|
FormatError = 1,
|
|
|
|
|
ServerFailure = 2,
|
|
|
|
|
NameError = 3,
|
|
|
|
|
NotImplemented = 4,
|
|
|
|
|
Refused = 5,
|
|
|
|
|
|
|
|
|
|
UnknownError,
|
|
|
|
|
NetworkError,
|
|
|
|
|
NoServerSpecified,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Archive, Serialize, Deserialize, Copy, Clone)]
|
|
|
|
|
pub struct DnsResponse {
|
|
|
|
|
pub addr: Option<NetIpAddr>,
|
|
|
|
|
pub code: DnsResponseCode,
|
|
|
|
|
}
|