Skip to content

Commit

Permalink
feat: support CNAME record
Browse files Browse the repository at this point in the history
Digs now able to query CNAME record
  • Loading branch information
azzamsa committed Feb 22, 2021
1 parent 2b39738 commit 4ce3318
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ use trust_dns_client::op::DnsResponse;
use trust_dns_client::rr::{DNSClass, Name, RecordType};
use trust_dns_client::udp::UdpClientConnection;

// Record Types
/// Record Types
#[derive(Debug, Clone, Copy)]
pub enum RTypes {
A,
AAAA,
CNAME,
MX,
NS,
SOA,
Expand All @@ -23,6 +24,7 @@ impl FromStr for RTypes {
match s {
"A" => Ok(RTypes::A),
"AAAA" => Ok(RTypes::AAAA),
"CNAME" => Ok(RTypes::CNAME),
"MX" => Ok(RTypes::MX),
"NS" => Ok(RTypes::NS),
"SOA" => Ok(RTypes::SOA),
Expand All @@ -36,13 +38,15 @@ fn get_rtype(rtype: RTypes) -> RecordType {
match rtype {
RTypes::A => RecordType::A,
RTypes::AAAA => RecordType::AAAA,
RTypes::CNAME => RecordType::CNAME,
RTypes::MX => RecordType::MX,
RTypes::NS => RecordType::NS,
RTypes::SOA => RecordType::SOA,
RTypes::TXT => RecordType::TXT,
}
}
// Parse address string

/// Parse address string
fn get_address(nameserver: &str) -> std::net::SocketAddr {
let address = format!("{}:53", nameserver).parse::<std::net::SocketAddr>();
match address {
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn main() {
)
.arg(
Arg::new("rtype")
.possible_values(&["A", "AAAA", "MX", "NS", "SOA", "TXT"])
.possible_values(&["A", "AAAA", "CNAME", "MX", "NS", "SOA", "TXT"])
.default_value("A"),
)
.arg(
Expand Down

0 comments on commit 4ce3318

Please sign in to comment.