Working on client'
This commit is contained in:
parent
bbbc2d4bf9
commit
88145aac5c
|
@ -16,15 +16,14 @@ use trust_dns_client::op::DnsResponse;
|
||||||
use trust_dns_client::rr::{DNSClass, Name, RData, Record, RecordType};
|
use trust_dns_client::rr::{DNSClass, Name, RData, Record, RecordType};
|
||||||
|
|
||||||
|
|
||||||
#[tokio::main]
|
fn main() {
|
||||||
async fn main() {
|
|
||||||
|
|
||||||
let address = "127.0.0.1:12323".parse().unwrap();
|
let address = "127.0.0.1:12323".parse().unwrap();
|
||||||
let conn = UdpClientConnection::new(address).unwrap();
|
let conn = UdpClientConnection::new(address).unwrap();
|
||||||
let client = SyncClient::new(conn);
|
let client = SyncClient::new(conn);
|
||||||
|
|
||||||
// Specify the name, note the final '.' which specifies it's an FQDN
|
// 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
|
// NOTE: see 'Setup a connection' example above
|
||||||
// Send the query and get a message response, see RecordType for all supported options
|
// 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.
|
// 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 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
|
// In this case we are interested in A, IPv4 address
|
||||||
if let &RData::A(ref ip) = answers[0].rdata() {
|
println!("found: {:?}", answers[0].rdata())
|
||||||
assert_eq!(*ip, Ipv4Addr::new(93, 184, 216, 34))
|
|
||||||
} else {
|
|
||||||
assert!(false, "unexpected result")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue