#![cfg_attr(docsrs, feature(doc_cfg))]
mod error;
mod parser;
mod doq;
use std::net::{IpAddr, Ipv4Addr};
pub use doq::Doq;
pub use error::{Error, Result};
use idns::Answer;
pub use idns::QType;
use smol_str::SmolStr;
#[derive(Debug, Clone)]
pub struct HostIp {
pub host: SmolStr,
pub ip: IpAddr,
}
impl idns::Query for Doq {
type Error = Error;
async fn answer_li(&self, qtype: QType, name: &str) -> Result<Option<Vec<Answer>>> {
self.query(name, qtype).await
}
}
pub const fn host_ip(host: &'static str, a: u8, b: u8, c: u8, d: u8) -> HostIp {
HostIp {
host: SmolStr::new_static(host),
ip: IpAddr::V4(Ipv4Addr::new(a, b, c, d)),
}
}
pub mod dns {
pub const ALIDNS: &str = "dns.alidns.com";
pub const ADGUARD: &str = "unfiltered.adguard-dns.com";
pub const CONTROLD: &str = "p0.freedns.controld.com";
}
pub fn doq_li(li: &[HostIp]) -> Vec<Doq> {
li.iter().map(|s| Doq::new(s.clone())).collect()
}
pub const DOQ_LI: &[HostIp] = &[
host_ip(dns::ADGUARD, 94, 140, 14, 140),
host_ip(dns::ADGUARD, 94, 140, 14, 141),
host_ip(dns::CONTROLD, 76, 76, 2, 11),
host_ip(dns::ALIDNS, 223, 5, 5, 5),
host_ip(dns::ALIDNS, 223, 6, 6, 6),
];