Working on client'

This commit is contained in:
notplants 2021-05-10 13:23:57 +02:00
parent bbbc2d4bf9
commit 88145aac5c
1 changed files with 3 additions and 8 deletions

View File

@ -16,15 +16,14 @@ use trust_dns_client::op::DnsResponse;
use trust_dns_client::rr::{DNSClass, Name, RData, Record, RecordType};
#[tokio::main]
async fn main() {
fn main() {
let address = "127.0.0.1:12323".parse().unwrap();
let conn = UdpClientConnection::new(address).unwrap();
let client = SyncClient::new(conn);
// Specify the name, note the final '.' which specifies it's an FQDN
let name = Name::from_str("www.example.com.").unwrap();
let name = Name::from_str("peach.dyn.commoninternet.net").unwrap();
// NOTE: see 'Setup a connection' example above
// Send the query and get a message response, see RecordType for all supported options
@ -39,9 +38,5 @@ async fn main() {
// Records are generic objects which can contain any data.
// In order to access it we need to first check what type of record it is
// In this case we are interested in A, IPv4 address
if let &RData::A(ref ip) = answers[0].rdata() {
assert_eq!(*ip, Ipv4Addr::new(93, 184, 216, 34))
} else {
assert!(false, "unexpected result")
}
println!("found: {:?}", answers[0].rdata())
}