Crates.io | cdns-rs |
lib.rs | cdns-rs |
version | 0.3.0 |
source | src |
created_at | 2021-11-07 02:11:14.327395 |
updated_at | 2024-10-30 00:41:37.655303 |
description | A native Sync/Async Rust implementation of client DNS resolver. |
homepage | |
repository | https://repo.4neko.org/4NEKO/cdns-rs |
max_upload_size | |
id | 477922 |
size | 385,927 |
v 0.3 unstable
An implementation of client side DNS query library which also is able to look for host name in /etc/hosts
.
Also it is able to /etc/resolv.conf
and uses options from this file to configure itself. So it acts like libc's gethostbyname(3)
or gethostbyaddr(3)
. The configuration can be overriden.
This library supports both async and sync code. At the moment async part is not available because:
poll(2)
to achieve the parallel name resolutionParse /etc/nsswitch.conf
DNSSEC
DNS-over-TLS
OPT_NO_CHECK_NAMES
resolv.conf (search, domain, sortlist)
Usage:
Simple Example:
use cdns_rs::sync::{QDns, QuerySetup, QType, request, caches::CACHE};
fn main()
{
// a, aaaa
let res_a = request::resolve_fqdn("protonmail.com", None).unwrap();
println!("A/AAAA:");
for a in res_a
{
println!("\t{}", a);
}
}
Custom query:
use cdns_rs::sync::{QDns, QuerySetup, QType, request, caches::CACHE};
fn main()
{
// soa
let mut dns_req =
QDns::make_empty(resolvers, 1, QuerySetup::default());
dns_req.add_request(QType::SOA, "protonmail.com");
// sending request and receiving results
let res = dns_req.query();
println!("SOA:");
if res.is_results() == true
{
let inner = res.into_inner().unwrap();
for i in inner
{
for r in i.get_responses()
{
println!("\t{}", r);
}
}
}
else
{
println!("\tNo SOA found!")
}
}